summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/int_math.h
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-11-16 18:56:55 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-11-16 18:56:55 +0000
commit82f9c199e871be3b1214d4fb5a4fa35acbb8aac8 (patch)
treec6e108854428cb08a7bfaed28bb01c28235622b2 /compiler-rt/lib/int_math.h
parent960d55e9ff95eefe0e17447fd09b3336b18f45c4 (diff)
downloadbcm5719-llvm-82f9c199e871be3b1214d4fb5a4fa35acbb8aac8.tar.gz
bcm5719-llvm-82f9c199e871be3b1214d4fb5a4fa35acbb8aac8.zip
lib/int_math: Some versions of GCC don't provide __builtin_isfinite. Support
them. llvm-svn: 144810
Diffstat (limited to 'compiler-rt/lib/int_math.h')
-rw-r--r--compiler-rt/lib/int_math.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/compiler-rt/lib/int_math.h b/compiler-rt/lib/int_math.h
index b472f1a962e..d6b4bdae162 100644
--- a/compiler-rt/lib/int_math.h
+++ b/compiler-rt/lib/int_math.h
@@ -21,12 +21,29 @@
#ifndef INT_MATH_H
#define INT_MATH_H
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+
#define CRT_INFINITY __builtin_huge_valf()
-#define crt_isfinite(x) __builtin_isfinite((x))
#define crt_isinf(x) __builtin_isinf((x))
#define crt_isnan(x) __builtin_isnan((x))
+/* Define crt_isfinite in terms of the builtin if available, otherwise provide
+ * an alternate version in terms of our other functions. This supports some
+ * versions of GCC which didn't have __builtin_isfinite.
+ */
+#if __has_builtin(__builtin_isfinite)
+# define crt_isfinite(x) __builtin_isfinite((x))
+#else
+# define crt_isfinite(x) \
+ __extension__(({ \
+ __typeof((x)) x_ = (x); \
+ !crt_isinf(x_) && !crt_isnan(x_); \
+ }))
+#endif
+
#define crt_copysign(x, y) __builtin_copysign((x), (y))
#define crt_copysignf(x, y) __builtin_copysignf((x), (y))
#define crt_copysignl(x, y) __builtin_copysignl((x), (y))
OpenPOWER on IntegriCloud