File tree Expand file tree Collapse file tree 11 files changed +64
-52
lines changed Expand file tree Collapse file tree 11 files changed +64
-52
lines changed Original file line number Diff line number Diff line change 22FFI 100: PHP symbols
33--SKIPIF--
44<?php require_once ('skipif.inc ' ); ?>
5+ <?php require_once ('utils.inc ' ); ?>
56<?php
67try {
7- FFI :: cdef ("extern void *zend_printf; " );
8+ ffi_cdef ("extern void *zend_printf; " , ffi_get_php_dll_name () );
89} catch (Throwable $ e ) {
910 die ('skip PHP symbols not available ' );
1011}
1314ffi.enable=1
1415--FILE--
1516<?php
16- // Check if target supports "fastcall" calling convention
17- try {
18- FFI ::cdef ("extern size_t __attribute__((fastcall)) (*zend_printf)(const char *format); " );
19- $ fastcall = "__attribute__((fastcall)) " ;
20- } catch (Throwable $ e ) {
21- $ fastcall = "" ;
22- }
23- $ zend = FFI ::cdef ("
17+ require_once ('utils.inc ' );
18+ $ fastcall = ffi_get_fastcall_specifier ();
19+ $ zend = ffi_cdef ("
2420 const char *get_zend_version(void);
2521 //char *get_zend_version(void);
2622 extern size_t (*zend_printf)(const char *format, ...);
@@ -29,7 +25,7 @@ $zend = FFI::cdef("
2925
3026 void $ fastcall zend_str_tolower(char *str, size_t length);
3127
32- " );
28+ ", ffi_get_php_dll_name () );
3329var_dump (trim (explode ("\n" ,$ zend ->get_zend_version ())[0 ]));
3430//var_dump(trim(FFI::string($zend->get_zend_version())));
3531var_dump ($ zend ->zend_printf );
Original file line number Diff line number Diff line change 22FFI 101: PHP symbols (function address)
33--SKIPIF--
44<?php require_once ('skipif.inc ' ); ?>
5+ <?php require_once ('utils.inc ' ); ?>
56<?php
67try {
7- FFI :: cdef ("extern void *zend_printf; " );
8+ ffi_cdef ("extern void *zend_printf; " , ffi_get_php_dll_name () );
89} catch (Throwable $ e ) {
910 die ('skip PHP symbols not available ' );
1011}
1314ffi.enable=1
1415--FILE--
1516<?php
16- // Check if target supports "fastcall" calling convention
17- try {
18- FFI ::cdef ("extern size_t __attribute__((fastcall)) (*zend_printf)(const char *format); " );
19- $ fastcall = "__attribute__((fastcall)) " ;
20- } catch (Throwable $ e ) {
21- $ fastcall = "" ;
22- }
23- $ zend = FFI ::cdef ("
17+ require_once ('utils.inc ' );
18+ $ fastcall = ffi_get_fastcall_specifier ();
19+ $ zend = ffi_cdef ("
2420 const char *get_zend_version(void);
2521 //char *get_zend_version(void);
2622 extern size_t (*zend_printf)(const char *format, ...);
@@ -29,7 +25,7 @@ $zend = FFI::cdef("
2925
3026 void $ fastcall zend_str_tolower(char *str, size_t length);
3127
32- " );
28+ ", ffi_get_php_dll_name () );
3329$ f = $ zend ->get_zend_version ;
3430var_dump (trim (explode ("\n" ,$ f ())[0 ]));
3531//var_dump(trim(FFI::string($zend->get_zend_version())));
Original file line number Diff line number Diff line change 22FFI 200: PHP callbacks
33--SKIPIF--
44<?php require_once ('skipif.inc ' ); ?>
5+ <?php require_once ('utils.inc ' ); ?>
56<?php
67try {
7- FFI ::cdef ("void* zend_write; " );
8+ FFI ::cdef ("void* zend_write; " , ffi_get_php_dll_name () );
89} catch (Throwable $ e ) {
910 die ('skip PHP symbols not available ' );
1011}
@@ -13,10 +14,11 @@ try {
1314ffi.enable=1
1415--FILE--
1516<?php
17+ require_once ('utils.inc ' );
1618$ zend = FFI ::cdef ("
1719 typedef int (*zend_write_func_t)(const char *str, size_t str_length);
1820 extern zend_write_func_t zend_write;
19- " );
21+ ", ffi_get_php_dll_name () );
2022
2123echo "Hello World! \n" ;
2224
Original file line number Diff line number Diff line change @@ -7,10 +7,11 @@ FFI 301: FFI loading on Windows
77ffi.enable=1
88--FILE--
99<?php
10+ require_once ('utils.inc ' );
1011$ fn = __DIR__ . "/300-win32.h " ;
1112$ cont = str_replace (
1213 "PHP_DLL_NAME " ,
13- " php " . PHP_MAJOR_VERSION . ( PHP_ZTS ? " ts " : "" ) . ( PHP_DEBUG ? " _debug " : "" ) . " .dll " ,
14+ ffi_get_php_dll_name () ,
1415 file_get_contents ("$ fn.in " )
1516 );
1617file_put_contents ($ fn , $ cont );
Original file line number Diff line number Diff line change @@ -3,8 +3,9 @@ Bug #77632 (FFI function pointers with variadics)
33--SKIPIF--
44<?php
55require_once ('skipif.inc ' );
6+ require_once ('utils.inc ' );
67try {
7- FFI ::cdef ("extern void *zend_printf; " );
8+ FFI ::cdef ("extern void *zend_printf; " , ffi_get_php_dll_name () );
89} catch (Throwable $ _ ) {
910 die ('skip PHP symbols not available ' );
1011}
1314ffi.enable=1
1415--FILE--
1516<?php
16- $ libc = FFI ::cdef ("extern size_t (*zend_printf)(const char *format, ...); " );
17+ require_once ('utils.inc ' );
18+ $ libc = FFI ::cdef ("extern size_t (*zend_printf)(const char *format, ...); " , ffi_get_php_dll_name ());
1719$ args = ["test from zend_printf \n" ];
1820($ libc ->zend_printf )(...$ args );
1921$ args2 = ["Hello, %s from zend_printf \n" , "world " ];
Original file line number Diff line number Diff line change @@ -5,26 +5,26 @@ FR #78270 (Usage of __vectorcall convention with FFI)
55require_once ('skipif.inc ' );
66if (substr (PHP_OS , 0 , 3 ) != 'WIN ' ) die ("skip this test is for Windows platforms only " );
77
8+ require_once ('utils.inc ' );
89ob_start ();
910phpinfo (INFO_GENERAL );
1011$ info = ob_get_clean ();
1112if (preg_match ('/Compiler => .*clang.*/ ' , $ info )) die ("skip not for clang " );
1213
13- $ dll = 'php7 ' . (PHP_ZTS ? 'ts ' : '' ) . (PHP_DEBUG ? '_debug ' : '' ) . '.dll ' ;
1414try {
1515 FFI ::cdef (<<<EOC
1616 __vectorcall int zend_atoi(const char *str, size_t str_len);
17- EOC , $ dll );
17+ EOC , ffi_get_php_dll_name () );
1818} catch (FFI \ParserException $ ex ) {
1919 die ('skip __vectorcall not supported ' );
2020}
2121?>
2222--FILE--
2323<?php
24- $ dll = ' php7 ' . ( PHP_ZTS ? ' ts ' : '' ) . ( PHP_DEBUG ? ' _debug ' : '' ) . ' .dll ' ;
24+ require_once ( ' utils.inc ' ) ;
2525$ ffi = FFI ::cdef (<<<EOC
2626 __vectorcall int zend_atoi(const char *str, size_t str_len);
27- EOC , $ dll );
27+ EOC , ffi_get_php_dll_name () );
2828var_dump ($ ffi ->zend_atoi ("17.4 " , 4 ));
2929?>
3030--EXPECT--
Original file line number Diff line number Diff line change @@ -5,11 +5,11 @@ FR #78270 (Usage of __vectorcall convention with FFI)
55require_once ('skipif.inc ' );
66if (substr (PHP_OS , 0 , 3 ) != 'WIN ' ) die ("skip this test is for Windows platforms only " );
77
8- $ dll = ' php7 ' . ( PHP_ZTS ? ' ts ' : '' ) . ( PHP_DEBUG ? ' _debug ' : '' ) . ' .dll ' ;
8+ require_once ( ' utils.inc ' ) ;
99try {
1010 FFI ::cdef (<<<EOC
1111 __vectorcall int zend_atoi(const char *str, size_t str_len);
12- EOC , $ dll );
12+ EOC , ffi_get_php_dll_name () );
1313} catch (FFI \ParserException $ ex ) {
1414 die ('skip __vectorcall not supported ' );
1515}
Original file line number Diff line number Diff line change @@ -6,13 +6,9 @@ Bug #78714 (funcs returning pointer can't use call convention spec)
66ffi.enable=1
77--FILE--
88<?php
9+ require_once ('utils.inc ' );
910$ def = 'char * __cdecl get_zend_version(void); ' ;
10- if (substr (PHP_OS , 0 , 3 ) != 'WIN ' ) {
11- $ ffi = FFI ::cdef ($ def );
12- } else {
13- $ dll = 'php7 ' . (PHP_ZTS ? 'ts ' : '' ) . (PHP_DEBUG ? '_debug ' : '' ) . '.dll ' ;
14- $ ffi = FFI ::cdef ($ def , $ dll );
15- }
11+ $ ffi = ffi_cdef ($ def , ffi_get_php_dll_name ());
1612echo substr (FFI ::string ($ ffi ->get_zend_version ()), 0 , 4 ) . "\n" ;
1713?>
1814--EXPECT--
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ if (!extension_loaded('zend-test')) die('skip zend-test extension not available'
77?>
88--FILE--
99<?php
10+ require_once ('utils.inc ' );
1011$ header = <<<HEADER
1112struct bug79096 {
1213 uint64_t a;
@@ -22,8 +23,7 @@ if (PHP_OS_FAMILY !== 'Windows') {
2223 try {
2324 $ ffi = FFI ::cdef ($ header , 'php_zend_test.dll ' );
2425 } catch (FFI \Exception $ ex ) {
25- $ dll = $ dll = 'php7 ' . (PHP_ZTS ? 'ts ' : '' ) . (PHP_DEBUG ? '_debug ' : '' ) . '.dll ' ;
26- $ ffi = FFI ::cdef ($ header , $ dll );
26+ $ ffi = FFI ::cdef ($ header , ffi_get_php_dll_name ());
2727 }
2828}
2929
Original file line number Diff line number Diff line change 11<?php
2- if (substr (PHP_OS , 0 , 3 ) == 'WIN ' ) {
3- $ fn = __DIR__ . "/300-win32.h " ;
4- $ cont = str_replace (
5- "PHP_DLL_NAME " ,
6- "php " . PHP_MAJOR_VERSION . (PHP_ZTS ? "ts " : "" ) . (PHP_DEBUG ? "_debug " : "" ) . ".dll " ,
7- file_get_contents ("$ fn.in " )
8- );
9- file_put_contents ($ fn , $ cont );
10- $ ffi = FFI ::load ($ fn );
11- /* Test should cleanup this. */
12- } else {
13- FFI ::load (__DIR__ . "/300.h " );
14- }
2+
3+ FFI ::load (__DIR__ . "/300.h " );
You can’t perform that action at this time.
0 commit comments