This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Fwd: Fix libffi failure on SPARC 32-bit]


--- Begin Message ---
It's exactly PR 32843 but for SPARC 32-bit: the patch

http://gcc.gnu.org/ml/gcc-cvs/2007-07/msg00336.html

caused

FAIL: libffi.call/return_sc.c -O0 -W -Wall execution test

Fixed by doing what Andrew did for x86, tested on sparc-sun-solaris2.9, 
applied on the mainline and 4.3 branch.


2008-11-21  Eric Botcazou  <ebotcazou@adacore.com>

	* src/sparc/ffi.c (ffi_prep_cif_machdep): Add support for
	signed/unsigned int8/16 return values.
	* src/sparc/v8.S (ffi_call_v8): Likewise.
	(ffi_closure_v8): Likewise.


-- 
Eric Botcazou
Index: src/sparc/ffi.c
===================================================================
--- src/sparc/ffi.c	(revision 141915)
+++ src/sparc/ffi.c	(working copy)
@@ -307,14 +307,24 @@ ffi_status ffi_prep_cif_machdep(ffi_cif 
 	cif->flags = FFI_TYPE_STRUCT;
       break;
 
+    case FFI_TYPE_SINT8:
+    case FFI_TYPE_UINT8:
+    case FFI_TYPE_SINT16:
+    case FFI_TYPE_UINT16:
+      if (cif->abi == FFI_V9)
+	cif->flags = FFI_TYPE_INT;
+      else
+	cif->flags = cif->rtype->type;
+      break;
+
     case FFI_TYPE_SINT64:
     case FFI_TYPE_UINT64:
-      if (cif->abi != FFI_V9)
-	{
-	  cif->flags = FFI_TYPE_SINT64;
-	  break;
-	}
-      /* FALLTHROUGH */
+      if (cif->abi == FFI_V9)
+	cif->flags = FFI_TYPE_INT;
+      else
+	cif->flags = FFI_TYPE_SINT64;
+      break;
+
     default:
       cif->flags = FFI_TYPE_INT;
       break;
Index: src/sparc/v8.S
===================================================================
--- src/sparc/v8.S	(revision 141915)
+++ src/sparc/v8.S	(working copy)
@@ -72,21 +72,63 @@ _ffi_call_v8:
 	be,a	done
 	st	%f0, [%i4+0]	! (delay)
 
+	cmp	%i3, FFI_TYPE_DOUBLE
+	be,a	double
+	st	%f0, [%i4+0]	! (delay)
+
+	cmp	%i3, FFI_TYPE_SINT8
+	be,a	sint8
+	sll	%o0, 24, %o0	! (delay)
+
+	cmp	%i3, FFI_TYPE_UINT8
+	be,a	uint8
+	sll	%o0, 24, %o0	! (delay)
+
+	cmp	%i3, FFI_TYPE_SINT16
+	be,a	sint16
+	sll	%o0, 16, %o0	! (delay)
+
+	cmp	%i3, FFI_TYPE_UINT16
+	be,a	uint16
+	sll	%o0, 16, %o0	! (delay)
+
 	cmp	%i3, FFI_TYPE_SINT64
-	be	longlong
+	be,a	longlong
+	st	%o0, [%i4+0]	! (delay)
+done:
+	ret
+	restore
 
-	cmp	%i3, FFI_TYPE_DOUBLE
-	bne	done
-	nop
-	st	%f0, [%i4+0]
+double:
 	st	%f1, [%i4+4]
-	
-done:
 	ret
 	restore
 
-longlong:
+sint8:
+	sra	%o0, 24, %o0
 	st	%o0, [%i4+0]
+	ret
+	restore
+
+uint8:
+	srl	%o0, 24, %o0
+	st	%o0, [%i4+0]
+	ret
+	restore
+
+sint16:
+	sra	%o0, 16, %o0
+	st	%o0, [%i4+0]
+	ret
+	restore
+
+uint16:
+	srl	%o0, 16, %o0
+	st	%o0, [%i4+0]
+	ret
+	restore
+
+longlong:
 	st	%o1, [%i4+4]
 	ret
 	restore
@@ -147,7 +189,8 @@ ffi_closure_v8:
 	be	done1
 
 	cmp	%o0, FFI_TYPE_INT
-	be	integer
+	be	done1
+	 ld	[%fp-8], %i0
 
 	cmp	%o0, FFI_TYPE_FLOAT
 	be,a	done1
@@ -165,13 +208,11 @@ ffi_closure_v8:
 	cmp	%o0, FFI_TYPE_STRUCT
 	be	done2
 
-	! FFI_TYPE_SINT64
-	! FFI_TYPE_UINT64
-	ld	[%fp-4], %i1
+	cmp	%o0, FFI_TYPE_SINT64
+	be,a	done1
+	 ldd	[%fp-8], %i0
 
-integer:
 	ld	[%fp-8], %i0
-
 done1:
 	jmp	%i7+8
 	 restore

--- End Message ---

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]