This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
libffi fixes
- From: Alan Hourihane <alanh at fairlite dot co dot uk>
- To: libffi-discuss at sourceware dot org
- Date: Thu, 19 Jan 2012 10:35:27 +0000
- Subject: libffi fixes
Hello,
I've been porting libffi to an alternative m68k platform and bumped into
a couple of generic issues.
Andreas Schwab has found one problem with the 68881 detection. Patch
attached.
A second problem, also attached is to fix the err_bad_abi.c test on m68k.
And finally a third patch is to fix the return_sc.c test when using GCC
optimizations on m68k.
I'll be cleaning up the new ABI soon and submitting that as well.
Let me know if there's any issues with these.
Many thanks,
Alan.
--- a/src/m68k/sysv.S
+++ b/src/m68k/sysv.S
@@ -109,7 +109,7 @@ retlongint:
retfloat:
btst #2,%d2
jbeq retdouble
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.s %fp0,(%a1)
#else
move.l %d0,(%a1)
@@ -119,7 +119,7 @@ retfloat:
retdouble:
btst #3,%d2
jbeq retlongdouble
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.d %fp0,(%a1)
#else
move.l %d0,(%a1)+
@@ -130,7 +130,7 @@ retdouble:
retlongdouble:
btst #4,%d2
jbeq retpointer
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.x %fp0,(%a1)
#else
move.l %d0,(%a1)+
@@ -199,7 +199,7 @@ ffi_closure_SYSV:
move.l (%a0),%d1
jra .Lcls_epilogue
.Lcls_ret_float:
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.s (%a0),%fp0
#else
move.l (%a0),%d0
@@ -209,7 +209,7 @@ ffi_closure_SYSV:
lsr.l #2,%d0
jne 1f
jcs .Lcls_ret_ldouble
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.d (%a0),%fp0
#else
move.l (%a0)+,%d0
@@ -217,7 +217,7 @@ ffi_closure_SYSV:
#endif
jra .Lcls_epilogue
.Lcls_ret_ldouble:
-#if defined(__MC68881__)
+#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.x (%a0),%fp0
#else
move.l (%a0)+,%d0
--- src/m68k/ffi.c.old 2012-01-16 12:35:40.383137560 +0000
+++ src/m68k/ffi.c 2012-01-16 12:36:10.036224809 +0000
@@ -261,7 +261,8 @@
void *user_data,
void *codeloc)
{
- FFI_ASSERT (cif->abi == FFI_SYSV);
+ if (cif->abi != FFI_SYSV)
+ return FFI_BAD_ABI;
*(unsigned short *)closure->tramp = 0x207c;
*(void **)(closure->tramp + 2) = codeloc;
--- testsuite/libffi.call/return_sc.c.old 2012-01-19 10:33:52.589474817 +0000
+++ testsuite/libffi.call/return_sc.c 2012-01-19 10:34:00.752759788 +0000
@@ -30,7 +30,7 @@
sc < (signed char) 127; sc++)
{
ffi_call(&cif, FFI_FN(return_sc), &rint, values);
- CHECK(rint == (ffi_arg) sc);
+ CHECK((signed char)rint == sc);
}
exit(0);
}