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]

Re: Another endianess problem on Solaris


Tom> I looked at writing the proposed fix tonight.

What do you think of this?
I imagine the implementation of ffi_promoted_type needs tweaking.
I don't know the details for every platform though.

Tom

Index: README
===================================================================
RCS file: /cvs/gcc/gcc/libffi/README,v
retrieving revision 1.2
diff -u -r1.2 README
--- README 2000/05/11 18:20:33 1.2
+++ README 2002/02/18 05:25:11
@@ -190,6 +190,16 @@
 at RVALUE.
 
 
+ffi_type *ffi_promoted_type (ffi_type *type)
+
+	 TYPE is a pointer to an ffi_type structure that represents
+	      the return type of a function.
+
+On some platforms, return values are promoted depending on their
+width; for instance a `short' return value might be promoted to `int'.
+This function returns the actual return type corresponding to TYPE;
+frequently this is TYPE itself.
+
 
 	An Example
 	----------
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
--- include/ffi.h.in 2002/01/17 16:04:20 1.12
+++ include/ffi.h.in 2002/02/18 05:25:12
@@ -479,6 +479,8 @@
 	      /*@out@*/ void *rvalue, 
 	      /*@dependent@*/ void **avalue);
 
+ffi_type *ffi_promoted_type (ffi_type *type);
+
 /* Useful for eliminating compiler warnings */
 #define FFI_FN(f) ((void (*)())f)
 
Index: src/types.c
===================================================================
RCS file: /cvs/gcc/gcc/libffi/src/types.c,v
retrieving revision 1.4
diff -u -r1.4 types.c
--- src/types.c 2001/03/27 02:39:16 1.4
+++ src/types.c 2002/02/18 05:25:12
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   types.c - Copyright (c) 1996, 1998  Cygnus Solutions
+   types.c - Copyright (c) 1996, 1998, 2002  Cygnus Solutions
    
    Predefined ffi_types needed by libffi.
 
@@ -121,3 +121,18 @@
 
 #endif
 
+/* Given an integral type, return the type that a function declared to
+   return that type will actually return.  */
+ffi_type *
+ffi_promoted_type (ffi_type *type)
+{
+  if (type->elements != NULL || type->type == FFI_TYPE_VOID)
+    return type;
+
+  /* By default, anything narrower than the platforms `int' is
+     promoted to `int'.  FIXME: allow platform-specific overrides.  */
+  if (type->size < ffi_type_uint.size)
+    return &ffi_type_uint;
+
+  return type;
+}


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