summary refs log tree commit diff
path: root/math
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-08-31 16:39:25 +0000
committerJoseph Myers <joseph@codesourcery.com>2017-08-31 16:39:25 +0000
commitc0c49d60cfeff3b2aa801d6598143a073989654a (patch)
tree248bd1a808a8f2e27396ddfd1c04e5362d7e5da2 /math
parent5ef1b2138d4236bb3616e612c5bc4dc328a9ffb2 (diff)
downloadglibc-c0c49d60cfeff3b2aa801d6598143a073989654a.tar.gz
glibc-c0c49d60cfeff3b2aa801d6598143a073989654a.tar.xz
glibc-c0c49d60cfeff3b2aa801d6598143a073989654a.zip
Simplify NAN definitions.
Similar to my patches for HUGE_VAL and INFINITY. this patch eliminates
the bits/nan.h headers.  __builtin_nanf ("") is used to define NAN for
GCC 3.3 and later; the fallback is (0.0f / 0.0f), which is a constant
expression for a quiet NaN of type float, but raises a spurious
"invalid" exception outside static initializers, which seems the best
that can be done purely in standard C.  Again, if anyone actually uses
a compiler with its own incompatible extension for producing a
constant quiet NaN, we can add compiler conditionals.

Tested for x86_64.

	*  math/math.h [__USE_ISOC99] (NAN): Define directly here.  Do not
	include <bits/nan.h>.
	* math/Makefile (headers): Remove bits/nan.h.
	* bits/nan.h: Remove.
	* sysdeps/ieee754/bits/nan.h: Likewise.
	* sysdeps/mips/bits/nan.h: Likewise.
Diffstat (limited to 'math')
-rw-r--r--math/Makefile1
-rw-r--r--math/math.h11
2 files changed, 9 insertions, 3 deletions
diff --git a/math/Makefile b/math/Makefile
index b9a06f0ca0..0601f3ac43 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -23,7 +23,6 @@ include ../Makeconfig
 
 # Installed header files.
 headers		:= math.h bits/mathcalls.h bits/mathinline.h \
-		   bits/nan.h \
 		   fpu_control.h complex.h bits/cmathcalls.h fenv.h \
 		   bits/fenv.h bits/fenvinline.h bits/mathdef.h tgmath.h \
 		   bits/math-finite.h bits/math-vector.h \
diff --git a/math/math.h b/math/math.h
index 5f5a498b11..bbc1ab9bfa 100644
--- a/math/math.h
+++ b/math/math.h
@@ -65,8 +65,15 @@ __BEGIN_DECLS
 #  define INFINITY HUGE_VALF
 # endif
 
-/* Get machine-dependent NAN value (returned for some domain errors).  */
-# include <bits/nan.h>
+/* IEEE Not A Number.  */
+# if __GNUC_PREREQ (3, 3)
+#  define NAN (__builtin_nanf (""))
+# else
+/* This will raise an "invalid" exception outside static initializers,
+   but is the best that can be done in ISO C while remaining a
+   constant expression.  */
+#  define NAN (0.0f / 0.0f)
+# endif
 #endif /* __USE_ISOC99 */
 
 #if __GLIBC_USE (IEC_60559_BFP_EXT)