aboutsummaryrefslogtreecommitdiff
path: root/math
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2018-08-01 22:22:00 +0000
committerJoseph Myers <joseph@codesourcery.com>2018-08-01 22:22:00 +0000
commitf6dcefbe607e7c190388c11db0a80a80e6ce9686 (patch)
tree99803e519b2b6558b404e2c4b03bcfcaa59a3e50 /math
parentfa67ba06ee07845a2bac34afa609ee2bbb1e017e (diff)
downloadglibc-f6dcefbe607e7c190388c11db0a80a80e6ce9686.tar
glibc-f6dcefbe607e7c190388c11db0a80a80e6ce9686.tar.gz
glibc-f6dcefbe607e7c190388c11db0a80a80e6ce9686.tar.bz2
glibc-f6dcefbe607e7c190388c11db0a80a80e6ce9686.zip
Fix math/test-misc.c for undefined fenv.h macros.
math/test-misc.c contains some code that uses fenv.h macros FE_UNDERFLOW, FE_OVERFLOW and FE_UPWARD without being conditional on those macros being defined. That would normally break the build for configurations (typically soft-float) not defining those macros. However, the code in question is inside LDBL_MANT_DIG > DBL_MANT_DIG conditionals. And, while we have configurations lacking rounding mode and exception support where LDBL_MANT_DIG > DBL_MANT_DIG (soft-float MIPS64 and RISC-V), those configurations currently define the fenv.h macros in question even for soft-float. There may be some case for defining those macros in cases where a soft-float compilation could use a hard-float libm (where both soft-float and hard-float can use the same ABI, as on ARM and RISC-V, for example). But MIPS is not such a case - the hard-float and soft-float ABIs are incompatible - and thus I am testing a patch to stop defining those macros for soft-float MIPS (motivated by reducing the extent to which architectures need their own definitions of math-tests.h macros - if lack of rounding mode / exception support can be determined by the lack of macros in fenv.h, that avoids the need for math-tests.h to declare that lack as well). Introducing a case of LDBL_MANT_DIG > DBL_MANT_DIG without these macros defined shows up the problem with math/test-misc.c. This patch then fixes that problem by adding appropriate conditionals. Tested for MIPS64 in conjunction with changes to stop defining the macros in question in bits/fenv.h for soft-float. * math/test-misc.c (do_test) [LDBL_MANT_DIG > DBL_MANT_DIG]: Make code using FE_UNDERFLOW conditional on [FE_UNDERFLOW], code using FE_OVERFLOW conditional on [FE_OVERFLOW] and code using FE_UPWARD conditional on [FE_UPWARD].
Diffstat (limited to 'math')
-rw-r--r--math/test-misc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/math/test-misc.c b/math/test-misc.c
index c5cfb342db..963e1e776e 100644
--- a/math/test-misc.c
+++ b/math/test-misc.c
@@ -976,11 +976,13 @@ do_test (void)
puts ("scalbl (LDBL_MIN, 2147483647) returns -Inf");
result = 1;
}
+# ifdef FE_UNDERFLOW
else if (fetestexcept (FE_UNDERFLOW))
{
puts ("scalbl (LDBL_MIN, 2147483647) raises underflow exception");
result = 1;
}
+# endif
feclearexcept (FE_ALL_EXCEPT);
r = scalbl (LDBL_MAX, -2147483647);
@@ -994,11 +996,13 @@ do_test (void)
puts ("scalbl (LDBL_MAX, -2147483647) returns -Inf");
result = 1;
}
+# ifdef FE_OVERFLOW
else if (fetestexcept (FE_OVERFLOW))
{
puts ("scalbl (LDBL_MAX, -2147483647) raises overflow exception");
result = 1;
}
+# endif
}
#endif
@@ -1178,6 +1182,7 @@ do_test (void)
}
}
+# ifdef FE_UPWARD
volatile long double ld7 = nextafterl (0.0L, 1.0L);
volatile double d7;
(void) &ld7;
@@ -1195,6 +1200,7 @@ do_test (void)
else
puts ("ignoring this failure");
}
+# endif
# endif
#endif