diff options
author | uweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-10-08 14:55:03 +0000 |
---|---|---|
committer | uweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-10-08 14:55:03 +0000 |
commit | dd985e54fb2181373c6aa43d6a5a2901e7495f2c (patch) | |
tree | 2bde663dbcb9369746d86132dad0b8213966d892 /libffi/src | |
parent | 983677343759eda637909b4028f31835d790e2b8 (diff) | |
download | gcc-dd985e54fb2181373c6aa43d6a5a2901e7495f2c.tar.gz |
* src/java_raw_api.c (ffi_java_raw_to_ptrarray): Interpret
raw data as _Jv_word values, not ffi_raw.
(ffi_java_ptrarray_to_raw): Likewise.
(ffi_java_rvalue_to_raw): New function.
(ffi_java_raw_call): Call it.
(ffi_java_raw_to_rvalue): New function.
(ffi_java_translate_args): Call it.
* src/ffitest.c (closure_test_fn): Interpret return value
as ffi_arg, not int.
* src/s390/ffi.c (ffi_prep_cif_machdep): Add missing
FFI_TYPE_POINTER case.
(ffi_closure_helper_SYSV): Likewise. Also, assume return
values extended to word size.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@57926 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libffi/src')
-rw-r--r-- | libffi/src/ffitest.c | 2 | ||||
-rw-r--r-- | libffi/src/java_raw_api.c | 91 | ||||
-rw-r--r-- | libffi/src/s390/ffi.c | 22 |
3 files changed, 86 insertions, 29 deletions
diff --git a/libffi/src/ffitest.c b/libffi/src/ffitest.c index 8d72df1cc03..163c4a8c36e 100644 --- a/libffi/src/ffitest.c +++ b/libffi/src/ffitest.c @@ -262,7 +262,7 @@ static test_structure_9 struct9 (test_structure_9 ts) static void closure_test_fn(ffi_cif* cif,void* resp,void** args, void* userdata) { - *(int*)resp = *(int*)args[0] + (int)(*(float*)args[1]) + (int)(long)userdata; + *(ffi_arg*)resp = *(int*)args[0] + (int)(*(float*)args[1]) + (int)(long)userdata; } typedef int (*closure_test_type)(int, float); diff --git a/libffi/src/java_raw_api.c b/libffi/src/java_raw_api.c index 55c3d132d53..cb5dd67a78e 100644 --- a/libffi/src/java_raw_api.c +++ b/libffi/src/java_raw_api.c @@ -81,21 +81,14 @@ ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args) { case FFI_TYPE_UINT8: case FFI_TYPE_SINT8: - *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 1); + *args = (void*) ((char*)(raw++) + 3); break; case FFI_TYPE_UINT16: case FFI_TYPE_SINT16: - *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 2); + *args = (void*) ((char*)(raw++) + 2); break; -#if SIZEOF_ARG >= 4 - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 4); - break; -#endif - #if SIZEOF_ARG == 8 case FFI_TYPE_UINT64: case FFI_TYPE_SINT64: @@ -157,31 +150,54 @@ ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw) switch ((*tp)->type) { case FFI_TYPE_UINT8: +#if WORDS_BIGENDIAN + *(UINT32*)(raw++) = *(UINT8*) (*args); +#else (raw++)->uint = *(UINT8*) (*args); +#endif break; case FFI_TYPE_SINT8: +#if WORDS_BIGENDIAN + *(SINT32*)(raw++) = *(SINT8*) (*args); +#else (raw++)->sint = *(SINT8*) (*args); +#endif break; case FFI_TYPE_UINT16: +#if WORDS_BIGENDIAN + *(UINT32*)(raw++) = *(UINT16*) (*args); +#else (raw++)->uint = *(UINT16*) (*args); +#endif break; case FFI_TYPE_SINT16: +#if WORDS_BIGENDIAN + *(SINT32*)(raw++) = *(SINT16*) (*args); +#else (raw++)->sint = *(SINT16*) (*args); +#endif break; -#if SIZEOF_ARG >= 4 case FFI_TYPE_UINT32: +#if WORDS_BIGENDIAN + *(UINT32*)(raw++) = *(UINT32*) (*args); +#else (raw++)->uint = *(UINT32*) (*args); +#endif break; case FFI_TYPE_SINT32: +#if WORDS_BIGENDIAN + *(SINT32*)(raw++) = *(SINT32*) (*args); +#else (raw++)->sint = *(SINT32*) (*args); - break; #endif - case FFI_TYPE_FLOAT: + break; + + case FFI_TYPE_FLOAT: (raw++)->flt = *(FLOAT32*) (*args); break; @@ -211,6 +227,55 @@ ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw) #if !FFI_NATIVE_RAW_API +static void +ffi_java_rvalue_to_raw (ffi_cif *cif, void *rvalue) +{ +#if WORDS_BIGENDIAN && SIZEOF_ARG == 8 + switch (cif->rtype->type) + { + case FFI_TYPE_UINT8: + case FFI_TYPE_UINT16: + case FFI_TYPE_UINT32: + *(UINT64 *)rvalue <<= 32; + break; + + case FFI_TYPE_SINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_INT: + *(SINT64 *)rvalue <<= 32; + break; + + default: + break; + } +#endif +} + +static void +ffi_java_raw_to_rvalue (ffi_cif *cif, void *rvalue) +{ +#if WORDS_BIGENDIAN && SIZEOF_ARG == 8 + switch (cif->rtype->type) + { + case FFI_TYPE_UINT8: + case FFI_TYPE_UINT16: + case FFI_TYPE_UINT32: + *(UINT64 *)rvalue >>= 32; + break; + + case FFI_TYPE_SINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_INT: + *(SINT64 *)rvalue >>= 32; + break; + + default: + break; + } +#endif +} /* This is a generic definition of ffi_raw_call, to be used if the * native system does not provide a machine-specific implementation. @@ -227,6 +292,7 @@ void ffi_java_raw_call (/*@dependent@*/ ffi_cif *cif, void **avalue = (void**) alloca (cif->nargs * sizeof (void*)); ffi_java_raw_to_ptrarray (cif, raw, avalue); ffi_call (cif, fn, rvalue, avalue); + ffi_java_rvalue_to_raw (cif, rvalue); } #if FFI_CLOSURES /* base system provides closures */ @@ -240,6 +306,7 @@ ffi_java_translate_args (ffi_cif *cif, void *rvalue, ffi_java_ptrarray_to_raw (cif, avalue, raw); (*cl->fun) (cif, rvalue, raw, cl->user_data); + ffi_java_raw_to_rvalue (cif, rvalue); } /* Again, here is the generic version of ffi_prep_raw_closure, which diff --git a/libffi/src/s390/ffi.c b/libffi/src/s390/ffi.c index b40bdd43fc9..9e7d16954f6 100644 --- a/libffi/src/s390/ffi.c +++ b/libffi/src/s390/ffi.c @@ -369,6 +369,7 @@ ffi_prep_cif_machdep(ffi_cif *cif) cif->flags = FFI390_RET_INT64; break; + case FFI_TYPE_POINTER: case FFI_TYPE_INT: case FFI_TYPE_UINT32: case FFI_TYPE_SINT32: @@ -682,29 +683,18 @@ ffi_closure_helper_SYSV (ffi_closure *closure, #endif break; + case FFI_TYPE_POINTER: case FFI_TYPE_UINT32: - p_gpr[0] = *(unsigned int *) rvalue; + case FFI_TYPE_UINT16: + case FFI_TYPE_UINT8: + p_gpr[0] = *(unsigned long *) rvalue; break; case FFI_TYPE_INT: case FFI_TYPE_SINT32: - p_gpr[0] = *(signed int *) rvalue; - break; - - case FFI_TYPE_UINT16: - p_gpr[0] = *(unsigned short *) rvalue; - break; - case FFI_TYPE_SINT16: - p_gpr[0] = *(signed short *) rvalue; - break; - - case FFI_TYPE_UINT8: - p_gpr[0] = *(unsigned char *) rvalue; - break; - case FFI_TYPE_SINT8: - p_gpr[0] = *(signed char *) rvalue; + p_gpr[0] = *(signed long *) rvalue; break; default: |