This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

SH 3e and 4-single-only problems with 32-bit doubles


On sh-elf, when compiling with -m3e or -m4-single-only, float and
double are 32-bits wide, and long double is 64-bits wide.  The problem
is that some of the LDBL_ constants defined in float.h are rounded to
32-bits, since they're double unless explicitly specified otherwise.
This patch fixes this problem.  I'm checking this in.

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* config/float-sh.h (LDBL_EPSILON, LDBL_MIN, LDBL_MAX): Prevent
	truncation to 32-bit doubles on -m3e and -m4-single-only.

Index: gcc/config/float-sh.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/float-sh.h,v
retrieving revision 1.4
diff -u -p -r1.4 float-sh.h
--- gcc/config/float-sh.h 2001/01/31 19:49:00 1.4
+++ gcc/config/float-sh.h 2001/02/02 17:54:40
@@ -99,6 +99,9 @@
 
 #endif
 
+/* Because -m3e and -m4-single-only have 32-bit doubles, we append L
+   to the doubles below, so that they're not truncated.  */
+
    /* Number of base-FLT_RADIX digits in the significand of a long double */
 #undef LDBL_MANT_DIG
 #define LDBL_MANT_DIG 53
@@ -107,13 +110,13 @@
 #define LDBL_DIG 15
    /* Difference between 1.0 and the minimum long double greater than 1.0 */
 #undef LDBL_EPSILON
-#define LDBL_EPSILON 2.2204460492503131e-16
+#define LDBL_EPSILON 2.2204460492503131e-16L
    /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */
 #undef LDBL_MIN_EXP
 #define LDBL_MIN_EXP (-1021)
    /* Minimum normalised long double */
 #undef LDBL_MIN
-#define LDBL_MIN 2.2250738585072014e-308
+#define LDBL_MIN 2.2250738585072014e-308L
    /* Minimum int x such that 10**x is a normalised long double */
 #undef LDBL_MIN_10_EXP
 #define LDBL_MIN_10_EXP (-307)
@@ -122,7 +125,7 @@
 #define LDBL_MAX_EXP 1024
    /* Maximum long double */
 #undef LDBL_MAX
-#define LDBL_MAX 1.7976931348623157e+308
+#define LDBL_MAX 1.7976931348623157e+308L
    /* Maximum int x such that 10**x is a representable long double */
 #undef LDBL_MAX_10_EXP
 #define LDBL_MAX_10_EXP 308

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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