1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 19:23:22 +02:00
Files
archived-php-src/ext/ffi/tests/bug78270_2.phpt
T
Christoph M. Becker 280485adc1 Improve FFI test suite for Windows
We add Windows support to four existing test cases, extract some useful
utility functions, and use them to simplify further test cases.

We also remove the Windows specific code from preload.inc, since
preloading isn't supported on Windows anyway.
2020-03-18 16:53:06 +01:00

46 lines
1.3 KiB
PHP

--TEST--
FR #78270 (Usage of __vectorcall convention with FFI)
--SKIPIF--
<?php
require_once('skipif.inc');
if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms only");
require_once('utils.inc');
try {
FFI::cdef(<<<EOC
__vectorcall int zend_atoi(const char *str, size_t str_len);
EOC, ffi_get_php_dll_name());
} catch (FFI\ParserException $ex) {
die('skip __vectorcall not supported');
}
?>
--FILE--
<?php
$x86 = (PHP_INT_SIZE === 4);
$arglists = array(
'int, int, int, int, int, int, int' => true,
'double, int, int, int, int, int, int' => !$x86,
'int, double, int, int, int, int, int' => !$x86,
'int, int, double, int, int, int, int' => !$x86,
'int, int, int, double, int, int, int' => !$x86,
'int, int, int, int, double, int, int' => false,
'int, int, int, int, int, double, int' => false,
'int, int, int, int, int, int, double' => true,
);
foreach ($arglists as $arglist => $allowed) {
$signature = "__vectorcall void foobar($arglist);";
try {
$ffi = FFI::cdef($signature);
} catch (FFI\ParserException $ex) {
if ($allowed) {
echo "($arglist): unexpected ParserException\n";
}
} catch (FFI\Exception $ex) {
if (!$allowed) {
echo "($arglist): unexpected Exception\n";
}
}
}
?>
--EXPECT--