aboutsummaryrefslogtreecommitdiff
path: root/math/math.h
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2016-10-21 18:26:53 +0200
committerFlorian Weimer <fweimer@redhat.com>2016-10-21 18:26:53 +0200
commitb3918c44db615637b26d919ce599cd86592316b3 (patch)
tree23c031ee3aaf2e2fccce583920cafb40eacdce3f /math/math.h
parent0f04fc07f6a36e761ec76100043798ea5c7a590c (diff)
downloadglibc-b3918c44db615637b26d919ce599cd86592316b3.zip
glibc-b3918c44db615637b26d919ce599cd86592316b3.tar.gz
glibc-b3918c44db615637b26d919ce599cd86592316b3.tar.bz2
math: Define iszero as a function template for C++ [BZ #20715]
This increases compatibility with C++ code which is forced to compile with _GNU_SOURCE.
Diffstat (limited to 'math/math.h')
-rw-r--r--math/math.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/math/math.h b/math/math.h
index 880b4a0..0220d08 100644
--- a/math/math.h
+++ b/math/math.h
@@ -335,11 +335,25 @@ enum
# define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL)
/* Return nonzero value if X is zero. */
-# ifdef __SUPPORT_SNAN__
-# define iszero(x) (fpclassify (x) == FP_ZERO)
-# else
-# define iszero(x) (((__typeof (x)) (x)) == 0)
-# endif
+# ifndef __cplusplus
+# ifdef __SUPPORT_SNAN__
+# define iszero(x) (fpclassify (x) == FP_ZERO)
+# else
+# define iszero(x) (((__typeof (x)) (x)) == 0)
+# endif
+# else /* __cplusplus */
+__END_DECLS
+template <class __T> inline bool
+iszero (__T __val)
+{
+# ifdef __SUPPORT_SNAN__
+ return fpclassify (__val) == FP_ZERO;
+# else
+ return __val == 0;
+# endif
+}
+__BEGIN_DECLS
+# endif /* __cplusplus */
#endif /* Use IEC_60559_BFP_EXT. */
#ifdef __USE_MISC