summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Smith <brad@comstyle.com>2013-10-17 23:22:02 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2013-11-01 20:14:33 -0400
commit8ef7e0d18e00291da14c69d3034896235875d019 (patch)
tree266dd98a24bf71c0b5d0beb0514a3270972c265d
parent3c2f4b651747c1ac484c39d5128cae5483094342 (diff)
Fix pixman build with older GCC releases
The following patch fixes building pixman with older GCC releases such as GCC 3.3 and older (OpenBSD; some older archs use GCC 3.3.6) by changing the method of detecting the presence of __builtin_clz to utilizing an autoconf check to determine its presence. Compilers that pretend to be GCC, implement __builtin_clz and are already utilizing the intrinsic include LLVM/Clang, Open64, EKOPath and PCC.
-rw-r--r--configure.ac16
-rw-r--r--pixman/pixman-matrix.c2
2 files changed, 17 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 8a3b6226..5ccc267c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1044,6 +1044,22 @@ fi
AC_MSG_RESULT($support_for_float128)
+dnl =====================================
+dnl __builtin_clz
+
+support_for_builtin_clz=no
+
+AC_MSG_CHECKING(for __builtin_clz)
+AC_LINK_IFELSE([AC_LANG_SOURCE([[
+unsigned int x = 11; int main (void) { return __builtin_clz(x); }
+]])], support_for_builtin_clz=yes)
+
+if test x$support_for_builtin_clz = xyes; then
+ AC_DEFINE([HAVE_BUILTIN_CLZ], [], [Whether the compiler supports __builtin_clz])
+fi
+
+AC_MSG_RESULT($support_for_builtin_clz)
+
dnl ==================
dnl libpng
diff --git a/pixman/pixman-matrix.c b/pixman/pixman-matrix.c
index 89b96826..4032c137 100644
--- a/pixman/pixman-matrix.c
+++ b/pixman/pixman-matrix.c
@@ -37,7 +37,7 @@
static force_inline int
count_leading_zeros (uint32_t x)
{
-#ifdef __GNUC__
+#ifdef HAVE_BUILTIN_CLZ
return __builtin_clz (x);
#else
int n = 0;