From: Anthony Green Date: Mon, 7 Jan 2013 11:14:53 +0000 (-0500) Subject: m68k fixes for signed 8 and 16-bit calls. X-Git-Tag: v3.0.12~54 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f4772f383abd71cfa141c8a70ba11c1aa4ebe2c;p=platform%2Fupstream%2Flibffi.git m68k fixes for signed 8 and 16-bit calls. --- diff --git a/ChangeLog b/ChangeLog index a5885dd..42c6397 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-01-07 Thorsten Glaser + + * src/m68k/ffi.c (CIF_FLAGS_SINT8, CIF_FLAGS_SINT16): Define. + (ffi_prep_cif_machdep): Fix 8-bit and 16-bit signed calls. + * src/m68k/sysv.S (ffi_call_SYSV, ffi_closure_SYSV): Ditto. + 2013-01-04 Anthony Green * Makefile.am (AM_CFLAGS): Don't automatically add -fexceptions diff --git a/src/m68k/ffi.c b/src/m68k/ffi.c index 37a0784..0dee938 100644 --- a/src/m68k/ffi.c +++ b/src/m68k/ffi.c @@ -123,6 +123,8 @@ ffi_prep_args (void *stack, extended_cif *ecif) #define CIF_FLAGS_POINTER 32 #define CIF_FLAGS_STRUCT1 64 #define CIF_FLAGS_STRUCT2 128 +#define CIF_FLAGS_SINT8 256 +#define CIF_FLAGS_SINT16 512 /* Perform machine dependent cif processing */ ffi_status @@ -200,6 +202,14 @@ ffi_prep_cif_machdep (ffi_cif *cif) cif->flags = CIF_FLAGS_DINT; break; + case FFI_TYPE_SINT16: + cif->flags = CIF_FLAGS_SINT16; + break; + + case FFI_TYPE_SINT8: + cif->flags = CIF_FLAGS_SINT8; + break; + default: cif->flags = CIF_FLAGS_INT; break; diff --git a/src/m68k/sysv.S b/src/m68k/sysv.S index f6f4ef9..9504c6a 100644 --- a/src/m68k/sysv.S +++ b/src/m68k/sysv.S @@ -2,9 +2,10 @@ sysv.S - Copyright (c) 2012 Alan Hourihane Copyright (c) 1998, 2012 Andreas Schwab - Copyright (c) 2008 Red Hat, Inc. - - m68k Foreign Function Interface + Copyright (c) 2008 Red Hat, Inc. + Copyright (c) 2012 Thorsten Glaser + + m68k Foreign Function Interface Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -168,8 +169,22 @@ retstruct1: retstruct2: btst #7,%d2 - jbeq noretval + jbeq retsint8 move.w %d0,(%a1) + jbra epilogue + +retsint8: + btst #8,%d2 + jbeq retsint16 + extb.l %d0 + move.l %d0,(%a1) + jbra epilogue + +retsint16: + btst #9,%d2 + jbeq noretval + ext.l %d0 + move.l %d0,(%a1) noretval: epilogue: @@ -201,8 +216,10 @@ CALLFUNC(ffi_closure_SYSV): lsr.l #1,%d0 jne 1f jcc .Lcls_epilogue + | CIF_FLAGS_INT move.l -12(%fp),%d0 .Lcls_epilogue: + | no CIF_FLAGS_* unlk %fp rts 1: @@ -210,6 +227,7 @@ CALLFUNC(ffi_closure_SYSV): lsr.l #2,%d0 jne 1f jcs .Lcls_ret_float + | CIF_FLAGS_DINT move.l (%a0)+,%d0 move.l (%a0),%d1 jra .Lcls_epilogue @@ -224,6 +242,7 @@ CALLFUNC(ffi_closure_SYSV): lsr.l #2,%d0 jne 1f jcs .Lcls_ret_ldouble + | CIF_FLAGS_DOUBLE #if defined(__MC68881__) || defined(__HAVE_68881__) fmove.d (%a0),%fp0 #else @@ -242,17 +261,31 @@ CALLFUNC(ffi_closure_SYSV): jra .Lcls_epilogue 1: lsr.l #2,%d0 - jne .Lcls_ret_struct2 + jne 1f jcs .Lcls_ret_struct1 + | CIF_FLAGS_POINTER move.l (%a0),%a0 move.l %a0,%d0 jra .Lcls_epilogue .Lcls_ret_struct1: move.b (%a0),%d0 jra .Lcls_epilogue -.Lcls_ret_struct2: +1: + lsr.l #2,%d0 + jne 1f + jcs .Lcls_ret_sint8 + | CIF_FLAGS_STRUCT2 move.w (%a0),%d0 jra .Lcls_epilogue +.Lcls_ret_sint8: + move.l (%a0),%d0 + extb.l %d0 + jra .Lcls_epilogue +1: + | CIF_FLAGS_SINT16 + move.l (%a0),%d0 + ext.l %d0 + jra .Lcls_epilogue CFI_ENDPROC() .size CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV)