[v3,2/3] math: let architectures classify without comparing
Checks
| Context |
Check |
Description |
| redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
| linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Test passed
|
Commit Message
A <bits/fpclassify.h> that defines __MATH_CLASSIFY_NO_COMPARE to 1 says that
comparisons cannot classify a value on this machine. The generic header
defines it to 0. iszero is the one classification macro not defined in that
header, since it needs no compiler builtin, so define it in terms of
fpclassify there, as is already done for -fsignaling-nans.
---
v3: Define __MATH_CLASSIFY_NO_COMPARE to 0 in the generic header and test
its value, rather than testing whether it is defined.
bits/fpclassify.h | 5 +++++
math/math.h | 7 ++++---
2 files changed, 9 insertions(+), 3 deletions(-)
@@ -20,6 +20,11 @@
# error "Never use <bits/fpclassify.h> directly; include <math.h> instead."
#endif
+/* Machines where a floating-point comparison cannot classify a value
+ define this to 1 in their own <bits/fpclassify.h> and define the
+ classification macros without comparing. */
+#define __MATH_CLASSIFY_NO_COMPARE 0
+
/* GCC bug 66462 means we cannot use the math builtins with -fsignaling-nan,
so disable builtins if this is enabled. When fixed in a newer GCC,
the __SUPPORT_SNAN__ check may be skipped for those versions. */
@@ -1162,16 +1162,17 @@ inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
/* Return nonzero value if X is subnormal. */
# define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL)
-/* Return nonzero value if X is zero. */
+/* Return nonzero value if X is zero. Machines that define
+ __MATH_CLASSIFY_NO_COMPARE to 1 cannot classify by comparing. */
# ifndef __cplusplus
-# ifdef __SUPPORT_SNAN__
+# if defined __SUPPORT_SNAN__ || __MATH_CLASSIFY_NO_COMPARE
# define iszero(x) (fpclassify (x) == FP_ZERO)
# else
# define iszero(x) (((__typeof (x)) (x)) == 0)
# endif
# else /* __cplusplus */
extern "C++" {
-# ifdef __SUPPORT_SNAN__
+# if defined __SUPPORT_SNAN__ || __MATH_CLASSIFY_NO_COMPARE
inline int
iszero (float __val)
{