PATCH: libffi vs. SPARC (again)

Bryce McKinlay bryce@waitaki.otago.ac.nz
Fri Oct 5 12:37:00 GMT 2001


Jeff Sturm wrote

>Libffi does promote sub-word return values, regardless of rtype.  (It does
>not assume arguments are similarly promoted by the caller, which seems
>like an inconsistency.)
>

Okay, I misunderstood the problem. The only problem with libffi is that 
this behaviour isn't documented  other than in the ffitest source. I 
agree its an inconsistency, but does make some sense, since it would 
presumably it would make the big-endian ports more complex and less 
efficient to not to promote the return value. And it isn't hard to deal 
with as long as you're aware of it.

>Yes.  _Jv_CallAnyMethodA passed a (struct jvalue *) to ffi_call, then
>looks at (result->b).  It is the same as if it passed a (jbyte *) to
>ffi_call.  In other words, _Jv_CallAnyMethodA assumes the return value is
>_not_ promoted.
>

... and therein lies the problem. A classic endian bug!

>For that matter, the return value is not always 32-bit (i.e. "jint") as
>Hans pointed out.  A "long" return value would suffice for most targets
>including LP64, but not P64 (which Microsoft is using for their 64-bit OS,
>unfortunately).  In any case, "double", "float" and "long long" need
>special treatment, and we need a portable way to declare a return value
>with the correct wordsize.
>

I'm not sure I follow. The rule is that types that are smaller than int 
will get promoted to int. Types that are equal/larger than int will be 
stored in the native way. As long as all 64-bit CPUs are little endian 
then there is no problem! Or am I missing something?

Anyway, here's my take on a fix. What do you think?

regards

Bryce.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: libjava-invoke.patch
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20011005/3a078308/attachment.ksh>


More information about the Java-patches mailing list