[Patch] libffi: Fixes for MIPS n32 ABI.

David Daney ddaney@avtrex.com
Thu Nov 29 07:09:00 GMT 2007


The initial patches for mips64/n32 ABI support passed the libffi
testsuite, however the java_raw_api support that is used by libjava
still contained several problems.  This patch attempts to correct them. 
With the patch applied we now have zero failures in the libjava
testsuite (down from around 30).

The problem was that libffi and libjava's interpreter use different
union definitions to describe stack elements.  In the case of
mips64/n32, these unions had different sizes (8 vs. 4 bytes).  This
caused most interpreter method calls to fail.

My patch adds a new macro FFI_SIZEOF_RAW that can be set by a libffi
target as well as allowing the target to define its own ffi_raw union. 
If the target does not override these the FFI_SIZEOF_RAW is set to
FFI_SIZEOF_ARG, and the default definition of the ffi_raw union is
used.  The code in java_raw_api, was changed to use FFI_SIZEOF_RAW in
most places it was using FFI_SIZEOF_ARG.  In addition special handling
was added for pointer return values where FFI_SIZEOF_RAW != FFI_SIZEOF_ARG.

There were several places where the alignment of the raw pointer was
adjusted all using different but equivalent size calculations.  I change
thse so that they all use sizeof(ffi_raw) as that seemed more correct.

Tested on mips64-linux-gnu/n32  and x86_64-pc-linux-gnu{m64,m32} with no
regressions.  I will also test it on mipsel-linux.

OK to commit?
2007-11-28  David Daney  <ddaney@avtrex.com>

    * include/ffi.h.in (FFI_SIZEOF_RAW): Define ifndef.
    (ffi_raw): Make declaration conditional on FFI_RAW_DEFINED.  Make
    length of data element FFI_SIZEOF_RAW.
    * src/java_raw_api.c (ffi_java_raw_size): Replace FFI_SIZEOF_ARG
    with FFI_SIZEOF_RAW.
    (ffi_java_raw_to_ptrarray): ReplaceFFI_SIZEOF_ARG with
    FFI_SIZEOF_RAW.  Use  sizeof(ffi_raw) for alignment calculations.
    (ffi_java_ptrarray_to_raw): Same.
    (ffi_java_rvalue_to_raw): Add special handling for FFI_TYPE_POINTER
    if FFI_SIZEOF_RAW == 4.
    (ffi_java_raw_to_rvalue): Same.
    * src/mips/ffitarget.h (FFI_SIZEOF_RAW): Define for N32 and N64 ABIs.
    (ffi_raw_arg, ffi_raw_sarg, ffi_raw) Declare for N32 ABI.
    (FFI_RAW_DEFINED): Define for N32 ABI.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffi.diff
Type: text/x-patch
Size: 4694 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20071129/cc26e797/attachment.bin>


More information about the Java-patches mailing list