This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Two bugs in unix64.S


Hi Dan,

On Thu, Oct 14, 2010 at 7:57 PM, Dan Witte <dwitte@mozilla.com> wrote:
> That's actually a bug in ffi_call_win32. It's a (apparently little-known) contract of the API that the return value pointer, for integral types, should be declared ffi_arg -- which is the size of the largest integral value.
>
> ffi_call is supposed to sign- or zero-extend the return value into this size.

I see, sorry for not having really searched earlier in the docs.
Reading e.g. http://linux.die.net/man/3/ffi_call , it says indeed that
ffi_call expects a pointer to a whole ffi_arg for the return value.
However it does not clearly say that ffi_call() is supposed to fill it
completely.  My guess is that any project that has, so far, needed the
feature has found out by trial-and-error that ffi_call() does *not*
fill it completely (e.g. by running it on win32, or by noticing the
wrong sign- vs. zero-extension done by unix64), and just assumed that
only the lower bits are valid.  I suppose it can be fixed in the
various .S files supporting ffi_call(); I can try to propose tests to
cover this case, and a patch for unix64.S and possibly win32.S.


A bientôt,

Armin.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]