[Mesa-dev] [PATCH] gallium/util: Don't use __builtin_clrsb in util_last_bit().

Erik Faye-Lund kusmabite at gmail.com
Tue Feb 3 06:13:04 PST 2015


On Tue, Feb 3, 2015 at 2:28 AM, Matt Turner <mattst88 at gmail.com> wrote:
> Unclear circumstances lead to undefined symbols on x86.
>
> Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=536916

A comment[1] on the gentoo bug-tracker suggest doing something along
these lines instead (untested)...

[1]: https://bugs.gentoo.org/show_bug.cgi?id=536916#c5

diff --git a/configure.ac b/configure.ac
index c2d775e..e6daf40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -175,6 +175,7 @@ fi
 dnl Check for compiler builtins
 AX_GCC_BUILTIN([__builtin_bswap32])
 AX_GCC_BUILTIN([__builtin_bswap64])
+AX_GCC_BUILTIN([__builtin_clrsb])
 AX_GCC_BUILTIN([__builtin_clz])
 AX_GCC_BUILTIN([__builtin_clzll])
 AX_GCC_BUILTIN([__builtin_ctz])
diff --git a/src/gallium/auxiliary/util/u_math.h
b/src/gallium/auxiliary/util/u_math.h
index 19c7343..4591830 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -561,7 +561,7 @@ util_last_bit(unsigned u)
 static INLINE unsigned
 util_last_bit_signed(int i)
 {
-#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 407)
&& !defined(__INTEL_COMPILER)
+#if defined(HAVE___BUILTIN_CLRSB)
    return 31 - __builtin_clrsb(i);
 #else
    if (i >= 0)


More information about the mesa-dev mailing list