summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Lowe <richlowe@richlowe.net>2019-04-27 02:09:06 +0000
committerRichard Lowe <richlowe@richlowe.net>2019-05-09 19:37:40 +0000
commitf26364c965228a50041eda19745fc8573312c654 (patch)
treed102bb39014ad1abfb610a05e35e14aa2c81616a
parent9938df9efd1c845888adf3e046421db350cf1088 (diff)
downloadillumos-joyent-f26364c965228a50041eda19745fc8573312c654.tar.gz
10881 more C99 math macros should be compiler builtins
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Gergő Doma <domag02@gmail.com> Reviewed by: Robert Mustacchi <rm@joyent.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/head/iso/math_c99.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/usr/src/head/iso/math_c99.h b/usr/src/head/iso/math_c99.h
index cf568267cb..36cf150d1a 100644
--- a/usr/src/head/iso/math_c99.h
+++ b/usr/src/head/iso/math_c99.h
@@ -36,6 +36,17 @@
extern "C" {
#endif
+#undef FP_ZERO
+#define FP_ZERO 0
+#undef FP_SUBNORMAL
+#define FP_SUBNORMAL 1
+#undef FP_NORMAL
+#define FP_NORMAL 2
+#undef FP_INFINITE
+#define FP_INFINITE 3
+#undef FP_NAN
+#define FP_NAN 4
+
#if defined(_STDC_C99) || _XOPEN_SOURCE - 0 >= 600 || defined(__C99FEATURES__)
#if defined(__GNUC__)
#undef HUGE_VAL
@@ -57,7 +68,12 @@ extern "C" {
#if __GNUC__ >= 4
#define isnan(x) __builtin_isnan(x)
#define isinf(x) __builtin_isinf(x)
-#else
+#define fpclassify(x) __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, \
+ FP_SUBNORMAL, FP_ZERO, x)
+#define isfinite(x) __builtin_isfinite(x)
+#define isnormal(x) __builtin_isnormal(x)
+#define signbit(x) __builtin_signbit(x)
+#else /* __GNUC__ >= 4 */
#define isnan(x) __extension__( \
{ __typeof(x) __x_n = (x); \
__builtin_isunordered(__x_n, __x_n); })
@@ -65,7 +81,6 @@ extern "C" {
{ __typeof(x) __x_i = (x); \
__x_i == (__typeof(__x_i)) INFINITY || \
__x_i == (__typeof(__x_i)) (-INFINITY); })
-#endif
#undef isfinite
#define isfinite(x) __extension__( \
{ __typeof(x) __x_f = (x); \
@@ -99,7 +114,8 @@ extern "C" {
sizeof (__x_s) == sizeof (double) ? \
(int)(((unsigned *)&__x_s)[1] >> 31) : \
(int)(((unsigned short *)&__x_s)[4] >> 15)); })
-#endif
+#endif /* defined(_BIG_ENDIAN) */
+#endif /* __GNUC__ >= 4 */
/*
* C99 7.12.14 comparison macros
@@ -182,17 +198,6 @@ typedef long double float_t;
typedef long double double_t;
#endif
-#undef FP_ZERO
-#define FP_ZERO 0
-#undef FP_SUBNORMAL
-#define FP_SUBNORMAL 1
-#undef FP_NORMAL
-#define FP_NORMAL 2
-#undef FP_INFINITE
-#define FP_INFINITE 3
-#undef FP_NAN
-#define FP_NAN 4
-
#undef FP_ILOGB0
#define FP_ILOGB0 (-2147483647)
#undef FP_ILOGBNAN