[PATCH 2/3] math: let architectures classify without comparing

Matt Turner mattst88@gmail.com
Thu Sep 10 02:47:11 GMT 2026


A <bits/fpclassify.h> that defines __MATH_CLASSIFY_NO_COMPARE says that
comparisons cannot classify a value on this machine.  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.
---
 math/math.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git ./math/math.h ./math/math.h
index 0926b418a5..4f7a52e673 100644
--- ./math/math.h
+++ ./math/math.h
@@ -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 whose <bits/fpclassify.h>
+   defines __MATH_CLASSIFY_NO_COMPARE cannot classify by comparing.  */
 # ifndef __cplusplus
-#  ifdef __SUPPORT_SNAN__
+#  if defined __SUPPORT_SNAN__ || defined __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__ || defined __MATH_CLASSIFY_NO_COMPARE
 inline int
 iszero (float __val)
 {
-- 
2.54.0



More information about the Libc-alpha mailing list