This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Another endianess problem on Solaris
- From: Tom Tromey <tromey at redhat dot com>
- To: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- Cc: martin dot kahlert at infineon dot com, Jeff Sturm <jsturm at one-point dot com>, Java Patch List <java-patches at gcc dot gnu dot org>, Anthony Green <green at redhat dot com>
- Date: 17 Feb 2002 22:54:25 -0700
- Subject: Re: Another endianess problem on Solaris
- References: <20020208144406.A8584@keksy.muc.infineon.com> <Pine.LNX.4.10.10202080943260.3535-100000@mars.deadcafe.org> <20020213112539.A5412@keksy.muc.infineon.com> <3C6A421D.5040506@waitaki.otago.ac.nz> <878z9rcpuz.fsf@creche.redhat.com>
- Reply-to: tromey at redhat dot com
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;
+}