about summary refs log tree commit diff
path: root/math/basic-test.c
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/basic-test.c
parent64d063b80005674a856ae4fee638a739137f6775 (diff)
downloadglibc-777b0332c0598ebba46685b41ea5846640751c19.tar.gz
glibc-777b0332c0598ebba46685b41ea5846640751c19.tar.xz
glibc-777b0332c0598ebba46685b41ea5846640751c19.zip
Use GCC's builtins for generating NaNs.
Diffstat (limited to 'math/basic-test.c')
-rw-r--r--math/basic-test.c31
1 files changed, 16 insertions, 15 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