Skip to content

Commit ffeff8a

Browse files
committed
JIT/FFI add tet for closure call
1 parent 99db26c commit ffeff8a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
FFI/JIT 040: Function call
3+
--EXTENSIONS--
4+
ffi
5+
--INI--
6+
ffi.enable=1
7+
;opcache.jit=tracing
8+
opcache.jit_hot_loop=1
9+
opcache.jit_hot_func=0
10+
opcache.jit_hot_return=0
11+
opcache.jit_hot_side_exit=0
12+
;opcache.jit_debug=0x180005
13+
--SKIPIF--
14+
<?php
15+
try {
16+
$libc = FFI::cdef("void printf(void);", 'libc.so.6');
17+
} catch (Throwable $_) {
18+
die('skip libc.so.6 not available');
19+
}
20+
?>
21+
--FILE--
22+
<?php
23+
function test($name) {
24+
$ffi = FFI::cdef(<<<EOF
25+
int printf(char *, ...);
26+
typedef struct {
27+
int (*f)(char *, ...);
28+
} T;
29+
EOF, 'libc.so.6');
30+
$x = $ffi->new("T");
31+
$x->f = $ffi->printf;
32+
for ($i = 0; $i < 5; $i++) {
33+
($x->f)("Hello %s\n", $name);
34+
}
35+
}
36+
test("FFI");
37+
?>
38+
--EXPECT--
39+
Hello FFI
40+
Hello FFI
41+
Hello FFI
42+
Hello FFI
43+
Hello FFI

0 commit comments

Comments
 (0)