summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/imports.c
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/mesa/main/imports.c
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/mesa/main/imports.c')
-rw-r--r--src/mesa/main/imports.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 2c2d11e35ac..b8c75481516 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -217,7 +217,7 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize,
/*@{*/
-#ifndef __GNUC__
+#ifndef HAVE___BUILTIN_FFS
/**
* Find the first bit set in a word.
*/
@@ -246,8 +246,9 @@ ffs(int i)
}
return bit;
}
+#endif
-
+#ifndef HAVE___BUILTIN_FFSLL
/**
* Find position of first bit set in given value.
* XXX Warning: this function can only be used on 64-bit systems!
@@ -271,11 +272,10 @@ ffsll(long long int val)
return 0;
}
-#endif /* __GNUC__ */
+#endif
-#if !defined(__GNUC__) ||\
- ((__GNUC__ * 100 + __GNUC_MINOR__) < 304) /* Not gcc 3.4 or later */
+#ifndef HAVE___BUILTIN_POPCOUNT
/**
* Return number of bits set in given GLuint.
*/
@@ -288,7 +288,9 @@ _mesa_bitcount(unsigned int n)
}
return bits;
}
+#endif
+#ifndef HAVE___BUILTIN_POPCOUNTLL
/**
* Return number of bits set in given 64-bit uint.
*/