[Patch] libffi: Fixes for MIPS n32 ABI.

David Daney ddaney@avtrex.com
Mon Dec 3 18:56:00 GMT 2007


Richard Sandiford wrote:
> David Daney <ddaney@avtrex.com> writes:
>   
>> Richard Sandiford wrote:
>>     
>>> ...you're talking about ffi_raw vs. _Jv_word, right?
>>>       
>> Correct.
>>
>>     
>>> As far as
>>> reviewing the patch goes, I'll sign off on the former being 8 bytes
>>> and the latter being 4,
>>>       
>> That was the state for n32 before the patch and the cause of the problems.
>>     
>
> Right.  Sorry for being ambiguous (twice in two days!).  I meant:
> I agree that the problem you describe exists for n32, and that it
> needs to be fixed.  (As far as I could tell, that was the only really
> target-specific item of interest here, so I thought it was the only
> reviewing input I was qualified to give.)
>
>   
>>> But why doesn't the ffi_java_raw_* API use a separate union that matches
>>> the layout of _Jv_Word on all targets? 
>>>       
>> That is what my new patch will do.
>>     
And here it is:

This patch defines a new type ffi_java_raw that agrees with the size of
_Jv_Word.  It is mostly a mechanical patch except for one place in
java_raw_api.c where a change was needed to extract pointers from the
return value on big-endian systems with a FFI_SIZEOF_ARG
FFI_SIZEOF_JAVA_RAW size disagreement.

Is this version preferable to the previous version?

Tested on mips64-linux/n32 and x86_64-pc-linux-gnu{-m64,-m32} I will
also be testing on mipsel-linux.

2007-12-3  David Daney  <ddaney@avtrex.com>

    * include/ffi.h.in (FFI_SIZEOF_JAVA_RAW): Define if not    already
    defined.
    (ffi_java_raw): New typedef.
    (ffi_java_raw_call, ffi_java_ptrarray_to_raw,
    ffi_java_raw_to_ptrarray): Change parameter types from ffi_raw to
    ffi_java_raw.
    (ffi_java_raw_closure) : Same.
    (ffi_prep_java_raw_closure, ffi_prep_java_raw_closure_loc): Change
    parameter types.
    * src/java_raw_api.c (ffi_java_raw_size):  Replace FFI_SIZEOF_ARG with
    FFI_SIZEOF_JAVA_RAW.
    (ffi_java_raw_to_ptrarray): Change type of raw to ffi_java_raw.
    Replace FFI_SIZEOF_ARG with FFI_SIZEOF_JAVA_RAW. Use
    sizeof(ffi_java_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_JAVA_RAW == 4.
    (ffi_java_raw_to_rvalue): Same.
    (ffi_java_raw_call): Change type of raw to ffi_java_raw.
    (ffi_java_translate_args): Same.
    (ffi_prep_java_raw_closure_loc, ffi_prep_java_raw_closure): Change
    parameter types.
    * src/mips/ffitarget.h (FFI_SIZEOF_JAVA_RAW): Define for N32 ABI.

2007-12-3  David Daney  <ddaney@avtrex.com>

    * interpret.cc: Replace ffi_raw with INTERP_FFI_RAW_TYPE throughout.
    (ncode_closure, ffi_closure_fun): Define versions for
    non-FFI_NATIVE_RAW_API case.
    * include/java-interp.h (INTERP_FFI_RAW_TYPE): Define and use to
    replace    ffi_raw throughout.
    * jni.cc, interpret-run.cc: Replace ffi_raw with INTERP_FFI_RAW_TYPE
    throughout.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffi-1.diff
Type: text/x-patch
Size: 16587 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20071203/77377ef0/attachment.bin>


More information about the Gcc-patches mailing list