diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2013-02-28 22:30:18 +0100 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2013-03-15 19:10:20 +0100 |
commit | 777b0332c0598ebba46685b41ea5846640751c19 (patch) | |
tree | e778f11d315ede62106259a283e621f05d18a500 /sysdeps | |
parent | 64d063b80005674a856ae4fee638a739137f6775 (diff) | |
download | glibc-777b0332c0598ebba46685b41ea5846640751c19.tar.gz glibc-777b0332c0598ebba46685b41ea5846640751c19.tar.xz glibc-777b0332c0598ebba46685b41ea5846640751c19.zip |
Use GCC's builtins for generating NaNs.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/powerpc/fpu/test-powerpc-snan.c | 64 |
1 files changed, 9 insertions, 55 deletions
diff --git a/sysdeps/powerpc/fpu/test-powerpc-snan.c b/sysdeps/powerpc/fpu/test-powerpc-snan.c index f8b5595d8c..6ec9414e79 100644 --- a/sysdeps/powerpc/fpu/test-powerpc-snan.c +++ b/sysdeps/powerpc/fpu/test-powerpc-snan.c @@ -34,56 +34,10 @@ char *dest_address; double value = 123.456; double zero = 0.0; -float SNANf; -double SNAN; -long double SNANl; - static sigjmp_buf sigfpe_buf; -void -init_signaling_nan (void) -{ - union { - double _ld16; - double _d8; - unsigned int _ui4[4]; - float _f4; - } nan_temp; - - nan_temp._ui4[0] = 0x7fa00000; - SNANf = nan_temp._f4; - - nan_temp._ui4[0] = 0x7ff40000; - nan_temp._ui4[1] = 0x00000000; - SNAN = nan_temp._d8; - - nan_temp._ui4[0] = 0x7ff40000; - nan_temp._ui4[1] = 0x00000000; - nan_temp._ui4[2] = 0x00000000; - nan_temp._ui4[3] = 0x00000000; - SNANl = nan_temp._ld16; -} - -static float -snan_float (void) -{ - return SNANf; -} - -static double -snan_double (void) -{ - return SNAN; -} - typedef long double ldouble; -static ldouble -snan_ldouble (void) -{ - return SNANl; -} - void myFPsighandler(int signal, @@ -130,19 +84,21 @@ check (const char *testname, int result) } } -#define TEST_FUNC(NAME, FLOAT) \ +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ static void \ NAME (void) \ { \ /* Variables are declared volatile to forbid some compiler \ optimizations. */ \ - volatile FLOAT Inf_var, qNaN_var, zero_var, one_var, sNaN_var; \ + volatile FLOAT Inf_var, qNaN_var, zero_var, one_var; \ + /* A sNaN is only guaranteed to be representable in variables with */ \ + /* static (or thread-local) storage duration. */ \ + static volatile FLOAT sNaN_var = __builtin_nans ## SUFFIX (""); \ fenv_t saved_fenv; \ \ zero_var = 0.0; \ one_var = 1.0; \ - qNaN_var = zero_var / zero_var; \ - sNaN_var = snan_##FLOAT (); \ + qNaN_var = __builtin_nan ## SUFFIX (""); \ Inf_var = one_var / zero_var; \ \ (void) &zero_var; \ @@ -358,17 +314,15 @@ NAME (void) \ remove_sigaction_FP(); \ } -TEST_FUNC (float_test, float) -TEST_FUNC (double_test, double) +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) #ifndef NO_LONG_DOUBLE -TEST_FUNC (ldouble_test, ldouble) +TEST_FUNC (ldouble_test, ldouble, l) #endif static int do_test (void) { - init_signaling_nan(); - float_test(); double_test(); #ifndef NO_LONG_DOUBLE |