This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] java: reading double constants from class files
- From: Jeff Sturm <jsturm at one-point dot com>
- To: java-patches at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 10 Jan 2002 13:59:53 -0500 (EST)
- Subject: [PATCH] java: reading double constants from class files
This fixes a problem reported by Martin Kahlert in
http://gcc.gnu.org/ml/java/2002-01/msg00045.html. Configurations with
FLOAT_WORDS_BIG_ENDIAN and HOST_BITS_PER_WIDE_INT do not correctly convert
double constants read from class files.
Tested on i686-pc-linux-gnu and sparc-sun-solaris2.7 native builds,
along with a i686-linux to sparc-solaris cross build with Martin's test
case.
2001-01-10 Jeff Sturm <jsturm@one-point.com>
Martin Kahlert <martin.kahlert@infineon.com>
* jcf-parse.c (get_constant): Don't swap lo/hi for big
endian targets when HOST_BITS_PER_WIDE_INT >= 64.
Index: jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.99
diff -u -p -r1.99 jcf-parse.c
--- jcf-parse.c 2001/12/16 16:23:49 1.99
+++ jcf-parse.c 2002/01/10 18:25:17
@@ -325,7 +325,15 @@ get_constant (jcf, index)
lshift_double (num[0], 0, 32, 64, &lo, &hi, 0);
num[0] = JPOOL_INT (jcf, index+1);
add_double (lo, hi, num[0], 0, &lo, &hi);
- if (FLOAT_WORDS_BIG_ENDIAN)
+
+ /* Since ereal_from_double expects an array of HOST_WIDE_INT
+ in the target's format, we swap the elements for big endian
+ targets, unless HOST_WIDE_INT is sufficiently large to
+ contain a target double, in which case the 2nd element
+ is ignored.
+
+ FIXME: Is this always right for cross targets? */
+ if (FLOAT_WORDS_BIG_ENDIAN && sizeof(num[0]) < 8)
{
num[0] = hi;
num[1] = lo;