1<?php 2 3function ffi_cdef($code, $lib) 4{ 5 if (isset($lib)) { 6 return FFI::cdef($code, $lib); 7 } else { 8 return FFI::cdef($code); 9 } 10} 11 12function ffi_get_php_dll_name() 13{ 14 if (PHP_OS_FAMILY === 'Windows') { 15 return "php" . PHP_MAJOR_VERSION . (PHP_ZTS ? "ts" : "") . (PHP_DEBUG ? "_debug" : "") . ".dll"; 16 } else { 17 return null; 18 } 19} 20 21function ffi_get_fastcall_specifier() 22{ 23 foreach (['__attribute__((fastcall))', '__fastcall', '__vectorcall'] as $spec) { 24 try { 25 ffi_cdef("extern size_t $spec zend_list_insert(void *ptr, int type);", ffi_get_php_dll_name()); 26 return "$spec "; 27 } catch (Throwable $e) {} 28 } 29 return ""; 30} 31