This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


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

[PATCH RFA] utils.c should not assume that sizeof(long) == 32


The following patch fixes a problem on IA-64 where I was seeing the
following behavior...

    (gdb) print 3.0 * 4.0
    $1 = 24
    (gdb) print 2.0
    $2 = 4

This bug was also responsible for a number of testsuite failures.

May I check this in?

	* utils.c (floatformat_from_doublest): Don't assume that a long
	will be exactly 32 bits in length.
	
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.4
diff -u -p -r1.4 utils.c
--- utils.c	2000/03/04 02:23:06	1.4
+++ utils.c	2000/03/18 21:43:59
@@ -2771,7 +2771,7 @@ floatformat_from_doublest (fmt, from, to
       mant_bits = mant_bits_left < 32 ? mant_bits_left : 32;
 
       mant *= 4294967296.0;
-      mant_long = (unsigned long) mant;
+      mant_long = ((unsigned long) mant) & 0xffffffffL;
       mant -= mant_long;
 
       /* If the integer bit is implicit, then we need to discard it.
@@ -2782,6 +2782,7 @@ floatformat_from_doublest (fmt, from, to
 	  && fmt->intbit == floatformat_intbit_no)
 	{
 	  mant_long <<= 1;
+	  mant_long &= 0xffffffffL;
 	  mant_bits -= 1;
 	}
 


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