summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2014-09-21 17:25:49 -0700
committerMatt Turner <[email protected]>2014-09-25 13:52:55 -0700
commit4a96df73e770bcca6396d3c8ffe3fd1693c73e50 (patch)
tree6f0d990309a36c1b62b091fd17c0dd93645c186d /src/util
parent3e0082261959762460dde18553ce0615df5c7a0a (diff)
mesa: Replace a priori knowledge of gcc builtins with configure tests.
Presumbly this will let clang and other compilers use the built-ins as well. Notice two changes specifically: - in _mesa_next_pow_two_64(), always use __builtin_clzll and add a static assertion that this is safe. - in macros.h, remove the clang-specific definition since it should be able to detect __builtin_unreachable in configure. Reviewed-by: Jason Ekstrand <[email protected]> [C bits] Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/macros.h14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/util/macros.h b/src/util/macros.h
index ee05e05a4a8..2e2f90f587c 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -33,12 +33,12 @@
/**
* __builtin_expect macros
*/
-#if !defined(__GNUC__)
+#if !defined(HAVE___BUILTIN_EXPECT)
# define __builtin_expect(x, y) (x)
#endif
#ifndef likely
-# ifdef __GNUC__
+# ifdef HAVE___BUILTIN_EXPECT
# define likely(x) __builtin_expect(!!(x), 1)
# define unlikely(x) __builtin_expect(!!(x), 0)
# else
@@ -63,20 +63,12 @@
* Unreachable macro. Useful for suppressing "control reaches end of non-void
* function" warnings.
*/
-#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5
+#ifdef HAVE___BUILTIN_UNREACHABLE
#define unreachable(str) \
do { \
assert(!str); \
__builtin_unreachable(); \
} while (0)
-#elif (defined(__clang__) && defined(__has_builtin))
-# if __has_builtin(__builtin_unreachable)
-# define unreachable(str) \
-do { \
- assert(!str); \
- __builtin_unreachable(); \
-} while (0)
-# endif
#endif
#ifndef unreachable