diff options
author | Manuel A. Fernandez Montecelo <manuel.montezelo@gmail.com> | 2016-05-27 14:35:40 +0100 |
---|---|---|
committer | Manuel A. Fernandez Montecelo <manuel.montezelo@gmail.com> | 2016-05-27 14:35:40 +0100 |
commit | b1de003dac299705a7f01c997d2b866bafe39926 (patch) | |
tree | 1cc16a3877e945116387a380f7f3023f81fa36e4 /tests/test-signbit.c | |
parent | 752fd7247bc223bcea35bd89cf56d1c08ead9ba6 (diff) | |
parent | 3590c846d4c2febbc05b4ad6b14a06edc549e453 (diff) |
Merge tag 'upstream/0.9.6+really0.9.6'
Upstream version 0.9.6+really0.9.6
Diffstat (limited to 'tests/test-signbit.c')
-rw-r--r-- | tests/test-signbit.c | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/tests/test-signbit.c b/tests/test-signbit.c index 9581190..80e9a08 100644 --- a/tests/test-signbit.c +++ b/tests/test-signbit.c @@ -1,5 +1,5 @@ /* Test of signbit() substitute. - Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2007-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,34 +28,14 @@ #include <float.h> #include <limits.h> +#include "minus-zero.h" +#include "infinity.h" #include "macros.h" float zerof = 0.0f; double zerod = 0.0; long double zerol = 0.0L; -/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f. - So we use -zerof instead. */ - -/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. - So we use -zerod instead. */ - -/* On HP-UX 10.20, negating 0.0L does not yield -0.0L. - So we use minus_zerol instead. - IRIX cc can't put -0.0L into .data, but can compute at runtime. - Note that the expression -LDBL_MIN * LDBL_MIN does not work on other - platforms, such as when cross-compiling to PowerPC on MacOS X 10.5. */ -#if defined __hpux || defined __sgi -static long double -compute_minus_zerol (void) -{ - return -LDBL_MIN * LDBL_MIN; -} -# define minus_zerol compute_minus_zerol () -#else -long double minus_zerol = -0.0L; -#endif - static void test_signbitf () { @@ -68,13 +48,13 @@ test_signbitf () ASSERT (signbit (-2.718e-30f)); /* Zeros. */ ASSERT (!signbit (0.0f)); - if (1.0f / -zerof < 0) - ASSERT (signbit (-zerof)); + if (1.0f / minus_zerof < 0) + ASSERT (signbit (minus_zerof)); else - ASSERT (!signbit (-zerof)); + ASSERT (!signbit (minus_zerof)); /* Infinite values. */ - ASSERT (!signbit (1.0f / 0.0f)); - ASSERT (signbit (-1.0f / 0.0f)); + ASSERT (!signbit (Infinityf ())); + ASSERT (signbit (- Infinityf ())); /* Quiet NaN. */ (void) signbit (zerof / zerof); #if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT @@ -113,13 +93,13 @@ test_signbitd () ASSERT (signbit (-2.718e-30)); /* Zeros. */ ASSERT (!signbit (0.0)); - if (1.0 / -zerod < 0) - ASSERT (signbit (-zerod)); + if (1.0 / minus_zerod < 0) + ASSERT (signbit (minus_zerod)); else - ASSERT (!signbit (-zerod)); + ASSERT (!signbit (minus_zerod)); /* Infinite values. */ - ASSERT (!signbit (1.0 / 0.0)); - ASSERT (signbit (-1.0 / 0.0)); + ASSERT (!signbit (Infinityd ())); + ASSERT (signbit (- Infinityd ())); /* Quiet NaN. */ (void) signbit (zerod / zerod); #if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT @@ -161,8 +141,8 @@ test_signbitl () else ASSERT (!signbit (minus_zerol)); /* Infinite values. */ - ASSERT (!signbit (1.0L / 0.0L)); - ASSERT (signbit (-1.0L / 0.0L)); + ASSERT (!signbit (Infinityl ())); + ASSERT (signbit (- Infinityl ())); /* Quiet NaN. */ (void) signbit (zerol / zerol); #if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT @@ -171,6 +151,16 @@ test_signbitl () #define NWORDS \ ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { long double value; unsigned int word[NWORDS]; } memory_long_double; + +#if defined __powerpc__ && LDBL_MANT_DIG == 106 + /* This is PowerPC "double double", a pair of two doubles. Inf and Nan are + represented as the corresponding 64-bit IEEE values in the first double; + the second is ignored. Manipulate only the first double. */ + #undef NWORDS + #define NWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +#endif + memory_long_double m; m.value = zerol / zerol; # if LDBL_EXPBIT0_BIT > 0 |