From 4a96df73e770bcca6396d3c8ffe3fd1693c73e50 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sun, 21 Sep 2014 17:25:49 -0700 Subject: 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 [C bits] Reviewed-by: Ian Romanick --- src/util/macros.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/util') 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 -- cgit v1.2.3