This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: Cosure return value issue on Linux PPC64
- From: Tom Tromey <tom at tromey dot com>
- To: "Kaz Kylheku \(libffi\)" <382-725-6798 at kylheku dot com>
- Cc: libffi-discuss at sourceware dot org
- Date: Mon, 29 May 2017 06:31:11 -0600
- Subject: Re: Cosure return value issue on Linux PPC64
- Authentication-results: sourceware.org; auth=none
- References: <53985e874a349c551e7943677d21c766@mail.kylheku.com>
Kaz> Is this documented somewhere?
A while back I tried to document all these little oddities in the
manual. It's difficult and ABI-breaking to fix libffi to be more in
line with user expectation, but at least in the meantime the docs can be
correct...
The closure docs say:
@item ret
[...]
Otherwise, @var{fun} must fill the object to which this points,
following the same special promotion behavior as @code{ffi_call}.
That is, in most cases, @var{ret} points to an object of exactly the
size of the type specified when @var{cif} was constructed. However,
integral types narrower than the system register size are widened. In
these cases your program may assume that @var{ret} points to an
@code{ffi_arg} object.
I hope this helps, but if it's still insufficiently clear, I'd
appreciate suggestions for how to improve it.
>From your other note:
Kaz> I'm not a complete idiot; I was taken for a ride by the simple
Kaz> example from some (perhaps outdated?) libffi texinfo
Kaz> documentation. This one:
You're definitely not an idiot, this has bitten many people, has been
asked on StackOverflow, has been filed as a bug in github a few times,
etc.
Alan Modra fixed up this documentation example back in 2013, according
to git blame. Seems like libffi is overdue for a release :-)
Anyway, I think the in-tree docs should be a bit clearer here. For
example they mention the promotion behavior now.
Tom