libffi powerpc64-linux long double

Alan Modra amodra@bigpond.net.au
Sat Feb 21 13:45:00 GMT 2004


On Sat, Feb 07, 2004 at 11:26:18PM +1030, Alan Modra wrote:
> Corrects libffi long double function return value and arg handling for
> power64-linux.

Arrgh.  Due to an error on my part, libffi wasn't even compiled with the
version of ffi.c I committed.  The version I committed has a syntax
error, and is missing a fix for long double in ffi_prep_args64.

Also, the testsuite needs to be run with -mlong-double-128 to properly
test long doubles, since we don't yet default to -mlong-double-128.

libffi/ChangeLog
	* src/powerpc/ffi.c (ffi_prep_args64): Correct long double handling.
	(ffi_closure_helper_LINUX64): Fix typo.
	* testsuite/libffi.call/cls_align_longdouble.c: Pass -mlong-double-128
	for powerpc64-*-*.
	* testsuite/libffi.call/float.c: Likewise.
	* testsuite/libffi.call/float2.c: Likewise.

Committing as obvious.

Index: libffi/src/powerpc/ffi.c
===================================================================
RCS file: /cvs/gcc/gcc/libffi/src/powerpc/ffi.c,v
retrieving revision 1.8
diff -u -p -r1.8 ffi.c
--- libffi/src/powerpc/ffi.c	8 Feb 2004 12:11:25 -0000	1.8
+++ libffi/src/powerpc/ffi.c	9 Feb 2004 00:59:02 -0000
@@ -369,10 +369,27 @@ void hidden ffi_prep_args64(extended_cif
 	  FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
 	  break;
 
-	case FFI_TYPE_STRUCT:
 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 	case FFI_TYPE_LONGDOUBLE:
+	  double_tmp = ((double *) *p_argv)[0];
+	  *(double *) next_arg = double_tmp;
+	  if (++next_arg == gpr_end)
+	    next_arg = rest;
+	  if (fparg_count < NUM_FPR_ARG_REGISTERS64)
+	    *fpr_base++ = double_tmp;
+	  fparg_count++;
+	  double_tmp = ((double *) *p_argv)[1];
+	  *(double *) next_arg = double_tmp;
+	  if (++next_arg == gpr_end)
+	    next_arg = rest;
+	  if (fparg_count < NUM_FPR_ARG_REGISTERS64)
+	    *fpr_base++ = double_tmp;
+	  fparg_count++;
+	  FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
+	  break;
 #endif
+
+	case FFI_TYPE_STRUCT:
 	  words = ((*ptr)->size + 7) / 8;
 	  if (next_arg >= gpr_base && next_arg + words > gpr_end)
 	    {
@@ -1079,7 +1096,7 @@ ffi_closure_helper_LINUX64 (ffi_closure 
 
 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 	case FFI_TYPE_LONGDOUBLE:
-	  if (prf + 1 < end_pfr)
+	  if (pfr + 1 < end_pfr)
 	    {
 	      avalue[i] = pfr;
 	      pfr += 2;
Index: libffi/testsuite/libffi.call/cls_align_longdouble.c
===================================================================
RCS file: /cvs/gcc/gcc/libffi/testsuite/libffi.call/cls_align_longdouble.c,v
retrieving revision 1.1
diff -u -p -r1.1 cls_align_longdouble.c
--- libffi/testsuite/libffi.call/cls_align_longdouble.c	4 Dec 2003 17:51:17 -0000	1.1
+++ libffi/testsuite/libffi.call/cls_align_longdouble.c	9 Feb 2004 00:59:02 -0000
@@ -5,6 +5,8 @@
    Originator:	<hos@tamanegi.org> 20031203	 */
 
 /* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
+/* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */
+
 #include "ffitest.h"
 
 typedef struct cls_struct_align {
Index: libffi/testsuite/libffi.call/float.c
===================================================================
RCS file: /cvs/gcc/gcc/libffi/testsuite/libffi.call/float.c,v
retrieving revision 1.1
diff -u -p -r1.1 float.c
--- libffi/testsuite/libffi.call/float.c	4 Sep 2003 14:47:48 -0000	1.1
+++ libffi/testsuite/libffi.call/float.c	9 Feb 2004 00:59:02 -0000
@@ -5,6 +5,8 @@
    Originator:	From the original ffitest.c  */
 
 /* { dg-do run } */
+/* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */
+
 #include "ffitest.h"
 
 static int floating(int a, float b, double c, long double d, int e)
Index: libffi/testsuite/libffi.call/float2.c
===================================================================
RCS file: /cvs/gcc/gcc/libffi/testsuite/libffi.call/float2.c,v
retrieving revision 1.1
diff -u -p -r1.1 float2.c
--- libffi/testsuite/libffi.call/float2.c	4 Sep 2003 14:47:48 -0000	1.1
+++ libffi/testsuite/libffi.call/float2.c	9 Feb 2004 00:59:02 -0000
@@ -5,6 +5,8 @@
    Originator:	From the original ffitest.c  */
 
 /* { dg-do run } */
+/* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */
+
 #include "ffitest.h"
 #include "float.h"
 



More information about the Gcc-patches mailing list