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