[Mesa-dev] [PATCH 4/4] Fix build with gcc 3.3.

Owain G. Ainsworth zerooa at googlemail.com
Sun Apr 18 16:55:39 PDT 2010


From: Matthieu Herrb <matthieu.herrb at laas.fr>

The builtins used here only appeard in gcc 3.4.
---
 src/mesa/main/imports.c |    3 ++-
 src/mesa/main/imports.h |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 1ae0853..65fd476 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -564,7 +564,8 @@ _mesa_ffsll(int64_t val)
 unsigned int
 _mesa_bitcount(unsigned int n)
 {
-#if defined(__GNUC__)
+#if defined(__GNUC__) && \
+	((_GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ >= 4))
    return __builtin_popcount(n);
 #else
    unsigned int bits;
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index d28f4ad..48ffb2b 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -404,7 +404,7 @@ _mesa_is_pow_two(int x)
 static INLINE int32_t
 _mesa_next_pow_two_32(uint32_t x)
 {
-#ifdef __GNUC__
+#if defined(__GNUC__) && ((__GNUC__ == 3 && __GNUC__ >= 4) || __GNUC__ >= 4)
 	uint32_t y = (x != 1);
 	return (1 + y) << ((__builtin_clz(x - y) ^ 31) );
 #else
@@ -422,7 +422,7 @@ _mesa_next_pow_two_32(uint32_t x)
 static INLINE int64_t
 _mesa_next_pow_two_64(uint64_t x)
 {
-#ifdef __GNUC__
+#if defined(__GNUC__) && ((__GNUC__ == 3 && __GNUC__ >= 4) || __GNUC__ >= 4)
 	uint64_t y = (x != 1);
 	if (sizeof(x) == sizeof(long))
 		return (1 + y) << ((__builtin_clzl(x - y) ^ 63));
-- 
1.6.5.7



More information about the mesa-dev mailing list