diff options
Diffstat (limited to 'libffi/src/moxie/ffi.c')
-rw-r--r-- | libffi/src/moxie/ffi.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/libffi/src/moxie/ffi.c b/libffi/src/moxie/ffi.c index 540a042..16d2bb3 100644 --- a/libffi/src/moxie/ffi.c +++ b/libffi/src/moxie/ffi.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (C) 2012, 2013 Anthony Green + ffi.c - Copyright (C) 2012, 2013, 2018 Anthony Green Moxie Foreign Function Interface @@ -100,7 +100,7 @@ void *ffi_prep_args(char *stack, extended_cif *ecif) count += z; } - return (stack + ((count > 24) ? 24 : ALIGN_DOWN(count, 8))); + return (stack + ((count > 24) ? 24 : FFI_ALIGN_DOWN(count, 8))); } /* Perform machine dependent cif processing */ @@ -111,7 +111,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) else cif->flags = cif->rtype->size; - cif->bytes = ALIGN (cif->bytes, 8); + cif->bytes = FFI_ALIGN (cif->bytes, 8); return FFI_OK; } @@ -159,7 +159,7 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3, unsigned arg4, unsigned arg5, unsigned arg6) { /* This function is called by a trampoline. The trampoline stows a - pointer to the ffi_closure object in $r7. We must save this + pointer to the ffi_closure object in $r12. We must save this pointer in a place that will persist while we do our work. */ register ffi_closure *creg __asm__ ("$r12"); ffi_closure *closure = creg; @@ -215,7 +215,18 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3, break; default: /* This is an 8-byte value. */ - avalue[i] = ptr; + if (ptr == (char *) ®ister_args[5]) + { + /* The value is split across two locations */ + unsigned *ip = alloca(8); + avalue[i] = ip; + ip[0] = *(unsigned *) ptr; + ip[1] = *(unsigned *) stack_args; + } + else + { + avalue[i] = ptr; + } ptr += 4; break; } @@ -223,8 +234,10 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3, /* If we've handled more arguments than fit in registers, start looking at the those passed on the stack. */ - if (ptr == ®ister_args[6]) + if (ptr == (char *) ®ister_args[6]) ptr = stack_args; + else if (ptr == (char *) ®ister_args[7]) + ptr = stack_args + 4; } /* Invoke the closure. */ @@ -257,7 +270,7 @@ ffi_prep_closure_loc (ffi_closure* closure, fn = (unsigned long) ffi_closure_eabi; - tramp[0] = 0x01e0; /* ldi.l $r7, .... */ + tramp[0] = 0x01e0; /* ldi.l $r12, .... */ tramp[1] = cls >> 16; tramp[2] = cls & 0xffff; tramp[3] = 0x1a00; /* jmpa .... */ |