about summary refs log tree commit diff
path: root/math
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2013-02-28 22:30:18 +0100
committerThomas Schwinge <thomas@codesourcery.com>2013-03-15 19:10:20 +0100
commit777b0332c0598ebba46685b41ea5846640751c19 (patch)
treee778f11d315ede62106259a283e621f05d18a500 /math
parent64d063b80005674a856ae4fee638a739137f6775 (diff)
downloadglibc-777b0332c0598ebba46685b41ea5846640751c19.tar.gz
glibc-777b0332c0598ebba46685b41ea5846640751c19.tar.xz
glibc-777b0332c0598ebba46685b41ea5846640751c19.zip
Use GCC's builtins for generating NaNs.
Diffstat (limited to 'math')
-rw-r--r--math/basic-test.c31
-rw-r--r--math/libm-test.inc6
2 files changed, 19 insertions, 18 deletions
diff --git a/math/basic-test.c b/math/basic-test.c
index 218c9699fb..ffead2ec0f 100644
--- a/math/basic-test.c
+++ b/math/basic-test.c
@@ -32,7 +32,7 @@ check (const char *testname, int result)
   }
 }
 
-#define TEST_FUNC(NAME, FLOAT, NANFUNC, EPSILON, HUGEVAL)		      \
+#define TEST_FUNC(NAME, FLOAT, SUFFIX, EPSILON, HUGEVAL)		      \
 static void								      \
 NAME (void)								      \
 {									      \
@@ -43,7 +43,7 @@ NAME (void)								      \
 									      \
   zero_var = 0.0;							      \
   one_var = 1.0;							      \
-  qNaN_var = zero_var / zero_var;					      \
+  qNaN_var = __builtin_nan ## SUFFIX ("");				      \
   Inf_var = one_var / zero_var;						      \
 									      \
   (void) &zero_var;							      \
@@ -80,11 +80,12 @@ NAME (void)								      \
   /*									      \
      And again with the value returned by the `nan' function.		      \
    */									      \
-  check (#FLOAT " isnan (nan (\"\"))", isnan (NANFUNC ("")));		      \
-  check (#FLOAT " isnan (-nan (\"\"))", isnan (-NANFUNC ("")));		      \
-  check (#FLOAT " !isinf (nan (\"\"))", !(isinf (NANFUNC (""))));	      \
-  check (#FLOAT " !isinf (-nan (\"\"))", !(isinf (-NANFUNC (""))));	      \
-  check (#FLOAT " nan (\"\") != nan (\"\")", NANFUNC ("") != NANFUNC (""));   \
+  check (#FLOAT " isnan (nan (\"\"))", isnan (nan ## SUFFIX ("")));	      \
+  check (#FLOAT " isnan (-nan (\"\"))", isnan (-nan ## SUFFIX ("")));	      \
+  check (#FLOAT " !isinf (nan (\"\"))", !(isinf (nan ## SUFFIX (""))));	      \
+  check (#FLOAT " !isinf (-nan (\"\"))", !(isinf (-nan ## SUFFIX (""))));     \
+  check (#FLOAT " nan (\"\") != nan (\"\")",				      \
+	 nan ## SUFFIX ("") != nan ## SUFFIX (""));			      \
 									      \
   /* test if EPSILON is ok */						      \
   x1 = 1.0;								      \
@@ -102,7 +103,7 @@ NAME (void)								      \
   check (#FLOAT " isinf (-HUGE_VALx) == -1", isinf (x1) == -1);		      \
 }
 
-#define TEST_TRUNC(NAME, FLOAT, DOUBLE) \
+#define TEST_TRUNC(NAME, FLOAT, DOUBLE, SUFFIX)				      \
 void									      \
 NAME (void)								      \
 {									      \
@@ -111,7 +112,7 @@ NAME (void)								      \
 									      \
   zero_var = 0.0;							      \
   one_var = 1.0;							      \
-  qNaN_var = zero_var / zero_var;					      \
+  qNaN_var = __builtin_nan ## SUFFIX ("");				      \
   Inf_var = one_var / zero_var;						      \
 									      \
   (void) &qNaN_var;							      \
@@ -123,13 +124,13 @@ NAME (void)								      \
   check (" "#FLOAT" x = ("#FLOAT") ("#DOUBLE") Inf", isinf (x2) != 0);	      \
 }
 
-TEST_FUNC (float_test, float, nanf, FLT_EPSILON, HUGE_VALF)
-TEST_FUNC (double_test, double, nan, DBL_EPSILON, HUGE_VAL)
-TEST_TRUNC (truncdfsf_test, float, double)
+TEST_FUNC (float_test, float, f, FLT_EPSILON, HUGE_VALF)
+TEST_FUNC (double_test, double, , DBL_EPSILON, HUGE_VAL)
+TEST_TRUNC (truncdfsf_test, float, double, )
 #ifndef NO_LONG_DOUBLE
-TEST_FUNC (ldouble_test, long double, nanl, LDBL_EPSILON, HUGE_VALL)
-TEST_TRUNC (trunctfsf_test, float, long double)
-TEST_TRUNC (trunctfdf_test, double, long double)
+TEST_FUNC (ldouble_test, long double, l, LDBL_EPSILON, HUGE_VALL)
+TEST_TRUNC (trunctfsf_test, float, long double, l)
+TEST_TRUNC (trunctfdf_test, double, long double, l)
 #endif
 
 int
diff --git a/math/libm-test.inc b/math/libm-test.inc
index ffb781f2b7..00e3d6e7ef 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -10626,10 +10626,10 @@ static void
 initialize (void)
 {
   fpstack_test ("start *init*");
-  plus_zero = 0.0;
-  qnan_value = plus_zero / plus_zero;	/* Suppress GCC warning */
 
-  minus_zero = FUNC(copysign) (0.0, -1.0);
+  plus_zero = 0.0;
+  qnan_value = FUNC (__builtin_nan) ("");
+  minus_zero = FUNC (copysign) (0.0, -1.0);
   plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF,
 		       HUGE_VALL, HUGE_VAL, HUGE_VALF);
   minus_infty = CHOOSE (-HUGE_VALL, -HUGE_VAL, -HUGE_VALF,