|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-09-16 21:26 UTC] cmb@php.net
-Package: ffi
+Package: FFI
[2024-12-25 20:33 UTC] nielsdos@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nielsdos
[2024-12-25 20:33 UTC] nielsdos@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 05:00:01 2025 UTC |
Description: ------------ On a big endian system (in my case, IBM i PASE), the FFI extension, at least for 32-bit integers returned (but likely other types/mechanisms as well from a skimming of the source), will return 0. This is seemingly because the result is stored in a 64-bit word, but FFI accesses it as if it was a 32-bit value. This works on little-endian, but returns the empty part of the word on big-endian. The actual result is from an IBM i PASE system (ppc64be), while the expected result is from an amd64 Fedora system. Test script: --------------- // ffi.c (gcc -o ffi.so (-maix64) -shared ffi.c) long long problem(void) { return 0x1122334455667788; } int problem32(void) { return 0x11223344; } // ffi3.php <?php $ffi = FFI::cdef("long long problem(); int problem32();", "./ffi.so"); echo dechex($ffi->problem()) . "\n"; echo dechex($ffi->problem32()) . "\n"; Expected result: ---------------- 1122334455667788 11223344 Actual result: -------------- 1122334455667788 0