Fix pixman build with older GCC releases
authorBrad Smith <brad@comstyle.com>
Fri, 18 Oct 2013 03:22:02 +0000 (23:22 -0400)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Sat, 2 Nov 2013 00:14:33 +0000 (20:14 -0400)
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.

configure.ac
pixman/pixman-matrix.c

index 8a3b622680e2fe7b577a9503d9d9da0da9f3c5fe..5ccc267c048dab075b2264cd8d21963772685f1e 100644 (file)
@@ -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
 
index 89b96826b8f2882db3ed3fb680c11c5f68e29b48..4032c137a2053fae9435309146e553f83909773f 100644 (file)
@@ -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;