bug78270_2.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. FR #78270 (Usage of __vectorcall convention with FFI)
  3. --EXTENSIONS--
  4. ffi
  5. zend_test
  6. --SKIPIF--
  7. <?php
  8. if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms only");
  9. require_once('utils.inc');
  10. try {
  11. FFI::cdef(<<<EOC
  12. __vectorcall int bug78270(const char *str, size_t str_len);
  13. EOC, "php_zend_test.dll");
  14. } catch (FFI\ParserException $ex) {
  15. die('skip __vectorcall not supported');
  16. }
  17. ?>
  18. --FILE--
  19. <?php
  20. $x86 = (PHP_INT_SIZE === 4);
  21. $arglists = array(
  22. 'int, int, int, int, int, int, int' => true,
  23. 'double, int, int, int, int, int, int' => !$x86,
  24. 'int, double, int, int, int, int, int' => !$x86,
  25. 'int, int, double, int, int, int, int' => !$x86,
  26. 'int, int, int, double, int, int, int' => !$x86,
  27. 'int, int, int, int, double, int, int' => false,
  28. 'int, int, int, int, int, double, int' => false,
  29. 'int, int, int, int, int, int, double' => true,
  30. );
  31. foreach ($arglists as $arglist => $allowed) {
  32. $signature = "__vectorcall void foobar($arglist);";
  33. try {
  34. $ffi = FFI::cdef($signature);
  35. } catch (FFI\ParserException $ex) {
  36. if ($allowed) {
  37. echo "($arglist): unexpected ParserException\n";
  38. }
  39. } catch (FFI\Exception $ex) {
  40. if (!$allowed) {
  41. echo "($arglist): unexpected Exception\n";
  42. }
  43. }
  44. }
  45. ?>
  46. --EXPECT--