Also: problem with return value in ffi_call on PPC64.
Sergei Trofimovich via libffi-discuss
libffi-discuss@sourceware.org
Sun May 28 18:23:00 GMT 2017
On Sat, 27 May 2017 19:15:35 -0700
"Kaz Kylheku (libffi)" <382-725-6798@kylheku.com> wrote:
> > Are users supposed to assume that the return value has been widened to
> > a register-wide (8 byte) value regardless of its declared FFI type?
>
> Indeed, it seems yes.
Confusingly yes. But only for integral types smaller that ffi_arg.
TL;DR:
Instead of just reading out result as *(result_type*)r for any FFI
type you need to use either *(ffi_arg*)r or *(result_type*)r depending
on the type of the result.
A bit vague libffi thread:
https://sourceware.org/ml/libffi-discuss/2010/msg00063.html
I discovered the same a few years ago debugging similar issue on GHC side
https://ghc.haskell.org/trac/ghc/ticket/3516
The awkward fix on GHC side:
https://git.haskell.org/ghc.git/commitdiff/3891512c4c770dadd0372ad84d2dec72b34652d2
Hope that helps.
--
Sergei
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: æøÃÂÃÂþòðàÿþôÿøÃÂàOpenPGP
URL: <http://sourceware.org/pipermail/libffi-discuss/attachments/20170528/b17ce858/attachment.sig>
More information about the Libffi-discuss
mailing list