php-src/ext/ffi/tests/utils.inc
Christoph M. Becker db991bc0f1
FFI: support symbol lookup without specifying lib on Windows
This works similar to `dlsym(RTLD_DEFAULT, …)` with the caveat that
symbols on Windows may not be unique, and are usually qualified by the
module they are exported from.  That means that wrong symbols may be
fetched, potentially causing serious issues; therefore this usage is
not recommended for production purposes, but is a nice simplification
for quick experiments and the ext/ffi test suite.

Closes GH-16351.
2024-10-19 15:36:49 +02:00

12 lines
317 B
PHP

<?php
function ffi_get_fastcall_specifier()
{
foreach (['__attribute__((fastcall))', '__fastcall', '__vectorcall'] as $spec) {
try {
FFI::cdef("extern size_t $spec zend_list_insert(void *ptr, int type);");
return "$spec ";
} catch (Throwable $e) {}
}
return "";
}