This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: libffi stdcall closures
On Nov 13, 2007, at 4:08 PM, Tom Tromey wrote:
"Timothy" == Timothy Wall <twalljava@dev.java.net> writes:
Timothy> Here's the patch for stdcall closures, including a basic
test. The
Timothy> diff is against the JNA repo; I can probably do one
against a gcc
Timothy> checkout if necessary.
I'm not really an x86 expert, so perhaps a port maintainer could look
it over. The test case also looked good at first blush, but Andreas
is really the person for that...
Should I ping him directly?
I have a couple nits to pick, but nothing major.
FWIW there are other areas where you may run into problems. The
biggest one is varargs -- libffi basically doesn't support this at
all. I'm sure there are more obscure ones, too, involving any new ABI
additions... maybe vectors, or decimal float, or I don't know what.
Do you mean varargs out or varargs in closures? I'm not too worried
about varargs in closures, and varargs calls through libffi seem to
work ok in the platforms we've tried so far.
Timothy> +#ifdef X86_WIN32
Timothy> + if (cif->abi == FFI_STDCALL) {
Timothy> + FFI_INIT_TRAMPOLINE_STDCALL (&closure->tramp[0], \
Timothy> + &ffi_closure_STDCALL, \
Timothy> + (void*)closure, cif-
>bytes);
Timothy> + }
Timothy> +#endif
You don't need the backslashes here. I see them elsewhere in the
file, but they are bogus. Also the "{" should be on its own line.
Also, it looks to me as though there's a missing 'else' in
here... shouldn't we call either FFI_INIT_TRAMPOLINE_STDCALL or
FFI_INIT_TRAMPOLINE, but not both?
That's just me trying to avoid intersecting conditional code with
logic constructs.
Following is a better construct, dropping the somewhat useless
ASSERTions:
if (cif->abi == FFI_SYSV)
{
FFI_INIT_TRAMPOLINE (&closure->tramp[0],
&ffi_closure_SYSV,
(void*)closure);
}
#ifdef X86_WIN32
else if (cif->abi == FFI_STDCALL)
{
FFI_INIT_TRAMPOLINE_STDCALL (&closure->tramp[0],
&ffi_closure_STDCALL,
(void*)closure, cif->bytes);
}
#endif
else
{
return FFI_BAD_ABI;
}
I'm looking over the JNA standalone libffi config changes and will
post those separately.