This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch committed] libffi: Fix failure for closure_fn6.c on SH-4
- From: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 18 Feb 2006 09:36:49 +0900 (JST)
- Subject: [patch committed] libffi: Fix failure for closure_fn6.c on SH-4
Hi,
The new ffi test closure_fn6.c reveals a bug in SH-4 port of libffi.
src/sh/ffi.c: ffi_closure_helper_SYSV wrongly updates the pointer to
the area to which the FP register arguments are saved, for the mixture
of double and float arguments. The attached patch is to fix it and
fixes a few compile time warning. I've checked it in on trunk.
Tested on sh4-unknown-linux-gnu and the testresult of libffi is:
=== libffi Summary ===
# of expected passes 266
# of unsupported tests 2
Regards,
kaz
--
2006-02-18 Kaz Kojima <kkojima@gcc.gnu.org>
* src/sh/ffi.c (ffi_closure_helper_SYSV): Remove unused variable
and cast integer to void * if needed. Update the pointer to
the FP register saved area correctly.
diff -uprN ORIG/trunk/libffi/src/sh/ffi.c LOCAL/trunk/libffi/src/sh/ffi.c
--- ORIG/trunk/libffi/src/sh/ffi.c 2005-10-29 06:53:11.000000000 +0900
+++ LOCAL/trunk/libffi/src/sh/ffi.c 2006-02-18 09:11:32.000000000 +0900
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
- ffi.c - Copyright (c) 2002, 2003, 2004, 2005 Kaz Kojima
+ ffi.c - Copyright (c) 2002, 2003, 2004, 2005, 2006 Kaz Kojima
SuperH Foreign Function Interface
@@ -535,7 +535,6 @@ ffi_closure_helper_SYSV (ffi_closure *cl
int freg = 0;
#endif
ffi_cif *cif;
- double temp;
cif = closure->cif;
avalue = alloca(cif->nargs * sizeof(void *));
@@ -544,7 +543,7 @@ ffi_closure_helper_SYSV (ffi_closure *cl
returns the data directly to the caller. */
if (cif->rtype->type == FFI_TYPE_STRUCT && STRUCT_VALUE_ADDRESS_WITH_ARG)
{
- rvalue = *pgr++;
+ rvalue = (void *) *pgr++;
ireg = 1;
}
else
@@ -611,6 +610,8 @@ ffi_closure_helper_SYSV (ffi_closure *cl
{
if (freg + 1 >= NFREGARG)
continue;
+ if (freg & 1)
+ pfr++;
freg = (freg + 1) & ~1;
freg += 2;
avalue[i] = pfr;