[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patches] Simplify bits/mathdef.h files



bits/mathdef.h defines float_t to be the type the compiler uses for 
arithmetic on float values.  This is normally float, except for a few 
processors which don't have proper float arithmetic and use excess 
precision instead.  (The only ones where GCC defines FLT_EVAL_METHOD to 
indicate this are x86 and m68k, so if any other processor uses something 
other than double that's a bug in either GCC or glibc.)

For some processors such as PowerPC, glibc only uses float for float_t if 
__GNUC__ is defined and __STDC__ == 1.  GCC's fixincludes interprets 
__STDC__ == 1 as an idiom for strict conformance mode (as used by some 
compilers defining it to 0 in not-quite-conforming mode) and so changes it 
to defined(__STRICT_ANSI__), meaning that in default mode float_t gets 
wrongly defined to double when using the fixed header.

glibc doesn't actually support pre-standard C at all, and nor has GCC 
supported -traditional for a long time, so the __STDC__ conditionals are 
completely redundant and it's best just to use float for float_t 
unconditionally for these targets.  I've applied this patch to do so, and 
will submit it for FSF glibc.

Index: ChangeLog.eglibc
===================================================================
--- ChangeLog.eglibc	(revision 678)
+++ ChangeLog.eglibc	(working copy)
@@ -1,3 +1,10 @@
+2006-11-13  Joseph S. Myers  <joseph@xxxxxxxxxxxxxxxx>
+
+	* sysdeps/alpha/bits/mathdef.h (float_t): Always define as float.
+	* sysdeps/powerpc/bits/mathdef.h: Likewise.
+	* sysdeps/sh/sh4/bits/mathdef.h: Likewise.
+	* sysdeps/sparc/bits/mathdef.h: Likewise.
+
 2006-11-09  Steven Munroe  <sjmunroe@xxxxxxxxxx>
 	    Joe Kerian  <jkerian@xxxxxxxxxxxxx>
 
Index: sysdeps/powerpc/bits/mathdef.h
===================================================================
--- sysdeps/powerpc/bits/mathdef.h	(revision 678)
+++ sysdeps/powerpc/bits/mathdef.h	(working copy)
@@ -31,32 +31,10 @@
 #if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
 # define _MATH_H_MATHDEF	1
 
-# ifdef __GNUC__
-#  if __STDC__ == 1
-
-/* In GNU or ANSI mode, gcc leaves `float' expressions as-is.  */
-typedef float float_t;		/* `float' expressions are evaluated as
-				   `float'.  */
-typedef double double_t;	/* `double' expressions are evaluated as
-				   `double'.  */
-
-#  else
-
-/* For `gcc -traditional', `float' expressions are evaluated as `double'. */
-typedef double float_t;		/* `float' expressions are evaluated as
-				   `double'.  */
-typedef double double_t;	/* `double' expressions are evaluated as
-				   `double'.  */
-
-#  endif
-# else
-
-/* Wild guess at types for float_t and double_t. */
-typedef double float_t;
+/* PowerPC has both `float' and `double' arithmetic.  */
+typedef float float_t;
 typedef double double_t;
 
-# endif
-
 /* The values returned by `ilogb' for 0 and NaN respectively.  */
 # define FP_ILOGB0	(-2147483647)
 # define FP_ILOGBNAN	(2147483647)
Index: sysdeps/alpha/bits/mathdef.h
===================================================================
--- sysdeps/alpha/bits/mathdef.h	(revision 678)
+++ sysdeps/alpha/bits/mathdef.h	(working copy)
@@ -27,28 +27,10 @@
 #if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
 # define _MATH_H_MATHDEF	1
 
-# ifdef __GNUC__
-#  if __STDC__ == 1
-
-/* In GNU or ANSI mode, gcc leaves `float' expressions as-is.  */
+/* Alpha has both `float' and `double' arithmetic.  */
 typedef float float_t;
 typedef double double_t;
 
-#  else
-
-/* For `gcc -traditional', `float' expressions are evaluated as `double'. */
-typedef double float_t;
-typedef double double_t;
-
-#  endif
-# else
-
-/* Wild guess at types for float_t and double_t. */
-typedef double float_t;
-typedef double double_t;
-
-# endif
-
 /* The values returned by `ilogb' for 0 and NaN respectively.  */
 # define FP_ILOGB0     (-2147483647)
 # define FP_ILOGBNAN   (2147483647)
Index: sysdeps/sparc/bits/mathdef.h
===================================================================
--- sysdeps/sparc/bits/mathdef.h	(revision 678)
+++ sysdeps/sparc/bits/mathdef.h	(working copy)
@@ -29,28 +29,10 @@
 #if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
 # define _MATH_H_MATHDEF	1
 
-# ifdef __GNUC__
-#  if __STDC__ == 1
-
-/* In GNU or ANSI mode, gcc leaves `float' expressions as-is.  */
+/* SPARC has both `float' and `double' arithmetic.  */
 typedef float float_t;
 typedef double double_t;
 
-#  else
-
-/* For `gcc -traditional', `float' expressions are evaluated as `double'. */
-typedef double float_t;
-typedef double double_t;
-
-#  endif
-# else
-
-/* Wild guess at types for float_t and double_t. */
-typedef double float_t;
-typedef double double_t;
-
-# endif
-
 /* The values returned by `ilogb' for 0 and NaN respectively.  */
 # define FP_ILOGB0       (-2147483647)
 # define FP_ILOGBNAN     (2147483647)
Index: sysdeps/sh/sh4/bits/mathdef.h
===================================================================
--- sysdeps/sh/sh4/bits/mathdef.h	(revision 678)
+++ sysdeps/sh/sh4/bits/mathdef.h	(working copy)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1998,1999,2000,2004,2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -30,32 +30,10 @@
 #if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
 # define _MATH_H_MATHDEF	1
 
-# ifdef __GNUC__
-#  if __STDC__ == 1
-
-/* In GNU or ANSI mode, gcc leaves `float' expressions as-is.  */
-typedef float float_t;		/* `float' expressions are evaluated as
-				   `float'.  */
-typedef double double_t;	/* `double' expressions are evaluated as
-				   `double'.  */
-
-#  else
-
-/* For `gcc -traditional', `float' expressions are evaluated as `double'. */
-typedef double float_t;		/* `float' expressions are evaluated as
-				   `double'.  */
-typedef double double_t;	/* `double' expressions are evaluated as
-				   `double'.  */
-
-#  endif
-# else
-
-/* Wild guess at types for float_t and double_t. */
-typedef double float_t;
+/* SH has both `float' and `double' arithmetic.  */
+typedef float float_t;
 typedef double double_t;
 
-# endif
-
 /* The values returned by `ilogb' for 0 and NaN respectively.  */
 # define FP_ILOGB0	0x80000001
 # define FP_ILOGBNAN	0x7fffffff

-- 
Joseph S. Myers
joseph@xxxxxxxxxxxxxxxx