This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java 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]

libffi: new typedef for return value


There are five possibilities for return type of ffi_call:

void
float
double
long long
ffi_arg

the first four are already handled correctly in libffi and libgcj, I
believe.  The last is the promoted type we've been talking about,
ordinarily the register size of the target machine.  It is the minimum
size for promoted integer return types, and we require

sizeof(ffi_arg) == SIZEOF_ARG

Back in _Jv_CallAnyMethodA, I think we can get by allocating a union of

union {
  float f;
  double d;
  long long l;
  ffi_arg a;
}

but I can't see how we can avoid a switch statement for each possible
return type.  At least we can avoid specific target macros as in
ffitest.c.

I'd guess all this ought to be explained in the documentation for
ffi_call.


2002-02-18  Jeff Sturm  <jsturm@one-point.com>

	* include/ffi.h.in: Add typedef for ffi_arg.
	* src/ffitest.c (main): Declare rint with ffi_arg.

Index: include/ffi.h.in
===================================================================
RCS file: /cvs/gcc/gcc/libffi/include/ffi.h.in,v
retrieving revision 1.12
diff -u -r1.12 ffi.h.in
--- ffi.h.in	2002/01/17 16:04:20	1.12
+++ ffi.h.in	2002/02/18 19:24:52
@@ -307,6 +307,16 @@
 
 } ffi_cif;
 
+#if SIZEOF_ARG == 4
+typedef UINT32 ffi_arg;
+#else
+#if SIZEOF_ARG == 8
+typedef UINT64 ffi_arg;
+#else
+-- unsupported configuration
+#endif
+#endif
+
 /* ---- Definitions for the raw API -------------------------------------- */
 
 #if !FFI_NO_RAW_API
Index: src/ffitest.c
===================================================================
RCS file: /cvs/gcc/gcc/libffi/src/ffitest.c,v
retrieving revision 1.5
diff -u -r1.5 ffitest.c
--- ffitest.c	2001/03/27 02:39:16	1.5
+++ ffitest.c	2002/02/18 19:24:53
@@ -222,11 +222,7 @@
   signed int si1;
   signed int si2;
 
-#if defined(ALPHA) || defined(IA64) || defined(SPARC64) || (defined(MIPS) && (_MIPS_SIM == _ABIN32))
-  long long rint;
-#else
-  int rint;
-#endif
+  ffi_arg rint;
   long long rlonglong;
 
   ffi_type ts1_type;


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