[llvm-commits] [compiler-rt] r144810 - /compiler-rt/trunk/lib/int_math.h

Daniel Dunbar daniel at zuster.org
Wed Nov 16 10:56:55 PST 2011


Author: ddunbar
Date: Wed Nov 16 12:56:55 2011
New Revision: 144810

URL: http://llvm.org/viewvc/llvm-project?rev=144810&view=rev
Log:
lib/int_math: Some versions of GCC don't provide __builtin_isfinite. Support
them.

Modified:
    compiler-rt/trunk/lib/int_math.h

Modified: compiler-rt/trunk/lib/int_math.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/int_math.h?rev=144810&r1=144809&r2=144810&view=diff
==============================================================================
--- compiler-rt/trunk/lib/int_math.h (original)
+++ compiler-rt/trunk/lib/int_math.h Wed Nov 16 12:56:55 2011
@@ -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))





More information about the llvm-commits mailing list