[patch 1/3] libffi/m68k: fix numerous test suite failures (original) (raw)

This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC 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]

libffi/ 2007-xx-xx Roman Zippel zippel@linux-m68k.org

* src/m68k/ffi.c (ffi_prep_args,ffi_prep_cif_machdep): Fix
numerous test suite failures.
* src/m68k/sysv.S (ffi_call_SYSV): Likewise.

libffi/src/m68k/ffi.c | 130 +++++++++++++++++++++++++++---------------------- libffi/src/m68k/sysv.S | 35 ++++++++----- 2 files changed, 96 insertions(+), 69 deletions(-)

Index: gcc/libffi/src/m68k/ffi.c

--- gcc.orig/libffi/src/m68k/ffi.c +++ gcc/libffi/src/m68k/ffi.c @@ -8,11 +8,16 @@ #include <ffi_common.h> #include <stdlib.h> + +void ffi_call_SYSV (extended_cif *, + unsigned, unsigned, + void *, void (*fn) ()); +void *ffi_prep_args (void *stack, extended_cif ecif); / ffi_prep_args is called by the assembly routine once stack space has been allocated for the function's arguments. */ -static void * +void * ffi_prep_args (void *stack, extended_cif *ecif) { unsigned int i; @@ -24,7 +33,7 @@ ffi_prep_args (void *stack, extended_cif argp = stack; if (ecif->cif->rtype->type == FFI_TYPE_STRUCT - && ecif->cif->rtype->size > 8) + && !ecif->cif->flags) struct_value_ptr = ecif->rvalue; else struct_value_ptr = NULL; @@ -37,44 +46,47 @@ ffi_prep_args (void stack, extended_cif { size_t z; - / Align if necessary. */ - if (((*p_arg)->alignment - 1) & (unsigned) argp) - argp = (char *) ALIGN (argp, (*p_arg)->alignment);

@@ -86,7 +98,8 @@ ffi_prep_args (void stack, extended_cif #define CIF_FLAGS_DOUBLE 8 #define CIF_FLAGS_LDOUBLE 16 #define CIF_FLAGS_POINTER 32 -#define CIF_FLAGS_STRUCT 64 +#define CIF_FLAGS_STRUCT1 64 +#define CIF_FLAGS_STRUCT2 128 / Perform machine dependent cif processing */ ffi_status @@ -100,12 +113,24 @@ ffi_prep_cif_machdep (ffi_cif *cif) break; case FFI_TYPE_STRUCT: - if (cif->rtype->size > 4 && cif->rtype->size <= 8) - cif->flags = CIF_FLAGS_DINT; - else if (cif->rtype->size <= 4) - cif->flags = CIF_FLAGS_STRUCT; - else - cif->flags = 0; + switch (cif->rtype->size) + { + case 1: + cif->flags = CIF_FLAGS_STRUCT1; + break; + case 2: + cif->flags = CIF_FLAGS_STRUCT2; + break; + case 4: + cif->flags = CIF_FLAGS_INT; + break; + case 8: + cif->flags = CIF_FLAGS_DINT; + break; + default: + cif->flags = 0; + break; + } break; case FFI_TYPE_FLOAT: @@ -137,11 +162,6 @@ ffi_prep_cif_machdep (ffi_cif *cif) return FFI_OK; } -extern void ffi_call_SYSV (void () (void *, extended_cif *), - extended_cif *, - unsigned, unsigned, unsigned, - void *, void (*fn) ());

void ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue) { @@ -149,7 +169,7 @@ ffi_call (ffi_cif *cif, void (*fn) (), v ecif.cif = cif; ecif.avalue = avalue;

@@ -159,13 +179,11 @@ ffi_call (ffi_cif *cif, void (*fn) (), v ecif.rvalue = alloca (cif->rtype->size); else ecif.rvalue = rvalue;

Index: gcc/libffi/src/m68k/sysv.S

--- gcc.orig/libffi/src/m68k/sysv.S +++ gcc/libffi/src/m68k/sysv.S @@ -12,36 +12,40 @@

 .globl	ffi_call_SYSV
 .type	ffi_call_SYSV,@function

@@ -79,19 +83,24 @@ retlongdouble:

retpointer: btst #5,%d2 - jbeq retstruct + jbeq retstruct1 move.l %a0,(%a1) jbra epilogue

-retstruct: +retstruct1: btst #6,%d2 + jbeq retstruct2 + move.b %d0,(%a1) + jbra epilogue + +retstruct2: + btst #7,%d2 jbeq noretval - move.l 24(%fp),%d2 - bfins %d0,(%a1){#0,%d2} + move.w %d0,(%a1)

noretval: epilogue: move.l (%sp)+,%d2 - unlk %a6 + unlk %fp rts .size ffi_call_SYSV,.-ffi_call_SYSV

--


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