pixman: Branch 'master' - 6 commits

M. Joonas Pihlaja joonas at kemper.freedesktop.org
Wed Jul 21 13:53:13 PDT 2010


 configure.ac       |  219 ++++++++++++++++++++++++++++++++++++++---------------
 pixman/Makefile.am |    4 
 test/utils.c       |    2 
 test/utils.h       |    2 
 4 files changed, 164 insertions(+), 63 deletions(-)

New commits:
commit 9399b1a5af69cc9890aa7918cd09318ddeefc05d
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Wed Jul 14 09:51:27 2010 +0300

    Fix thinko in configure.ac's macro to test linking.
    
    Copy-paste carnage.  Renames save_{cflags,libs,ldflags} to
    save_{CFLAGS,LIBS,LDFLAGS}.

diff --git a/configure.ac b/configure.ac
index c97c45d..98c2783 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,9 +105,9 @@ AC_DEFUN([PIXMAN_LINK_WITH_ENV],[dnl
 	else
 		ifelse([$4], , :, [$4])
 	fi
-	CFLAGS="$save_cflags"
-	LDFLAGS="$save_ldflags"
-	LIBS="$save_libs"
+	CFLAGS="$save_CFLAGS"
+	LDFLAGS="$save_LDFLAGS"
+	LIBS="$save_LIBS"
 ])
 
 dnl Find a -Werror for catching warnings.
commit 5537e51cd0ffda53cc392a4bafe05070954fc36d
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sun Jul 11 19:59:01 2010 +0300

    Avoid trailing slashes on automake install dirs.
    
    The install-sh on a Solaris box couldn't copy with
    trailing slashes.

diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index 7538219..a9de19f 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -34,7 +34,7 @@ libpixman_1_la_SOURCES =			\
 	pixman-timer.c				\
 	pixman-matrix.c
 
-libpixmanincludedir = $(includedir)/pixman-1/
+libpixmanincludedir = $(includedir)/pixman-1
 libpixmaninclude_HEADERS = pixman.h pixman-version.h
 noinst_LTLIBRARIES = 
 
commit 1d9c6fa62385c42d67926982704c398d8b495d47
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sat Jul 10 15:36:41 2010 +0300

    Check for specific flags by actually trying to compile and link.
    
    Instead of relying on preprocessor version checks to see if a
    some compiler flags are supported, actually try to compile and
    link a test program with the flags.

diff --git a/configure.ac b/configure.ac
index d6f1d1c..c97c45d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,9 +77,10 @@ AC_CHECK_FUNCS([getisax])
 AC_C_BIGENDIAN
 AC_C_INLINE
 
-dnl PIXMAN_LINK_WITH_ENV(
-dnl	CFLAGS=... LDFLAGS=... LIBS=...,
-dnl	program, true-action, false-action)
+dnl PIXMAN_LINK_WITH_ENV(env-setup, program, true-action, false-action)
+dnl
+dnl Compiles and links the given program in the environment setup by env-setup
+dnl and executes true-action on success and false-action on failure.
 AC_DEFUN([PIXMAN_LINK_WITH_ENV],[dnl
 	save_CFLAGS="$CFLAGS"
 	save_LDFLAGS="$LDFLAGS"
@@ -88,10 +89,55 @@ AC_DEFUN([PIXMAN_LINK_WITH_ENV],[dnl
 	LDFLAGS=""
 	LIBS=""
 	$1
-	AC_LINK_IFELSE([$2], [$3], [$4])
-	CFLAGS="$save_CFLAGS"
-	LDFLAGS="$save_LDFLAGS"
-	LIBS="$save_LIBS"
+	AC_LINK_IFELSE(
+		[$2],
+		[pixman_cc_stderr=`test -f conftest.err && cat conftest.err`
+		 pixman_cc_flag=yes],
+		[pixman_cc_stderr=`test -f conftest.err && cat conftest.err`
+		 pixman_cc_flag=no])
+
+	if test "x$pixman_cc_stderr" != "x"; then
+		pixman_cc_flag=no
+	fi
+
+	if test "x$pixman_cc_flag" = "xyes"; then
+		ifelse([$3], , :, [$3])
+	else
+		ifelse([$4], , :, [$4])
+	fi
+	CFLAGS="$save_cflags"
+	LDFLAGS="$save_ldflags"
+	LIBS="$save_libs"
+])
+
+dnl Find a -Werror for catching warnings.
+WERROR=
+for w in -Werror -errwarn; do
+    if test "z$WERROR" = "z"; then
+        AC_MSG_CHECKING([whether the compiler supports $w])
+        PIXMAN_LINK_WITH_ENV(
+		[CFLAGS=$w],
+		[int main(int c, char **v) { (void)c; (void)v; return 0; }],
+		[WERROR=$w; yesno=yes], [yesno=no])
+	AC_MSG_RESULT($_yesno)
+    fi
+done
+
+dnl PIXMAN_CHECK_CFLAG(flag, [program])
+dnl  Adds flag to CFLAGS if the given program links without warnings or errors.
+AC_DEFUN([PIXMAN_CHECK_CFLAG], [dnl
+	AC_MSG_CHECKING([whether the compiler supports $1])
+	PIXMAN_LINK_WITH_ENV(
+		[CFLAGS="$WERROR $1"],
+		[$2
+		 int main(int c, char **v) { (void)c; (void)v; return 0; }
+		],
+		[_yesno=yes],
+		[_yesno=no])
+	if test "x$_yesno" = xyes; then
+	   CFLAGS="$CFLAGS $1"
+	fi
+	AC_MSG_RESULT($_yesno)
 ])
 
 AC_CHECK_SIZEOF(long)
@@ -134,20 +180,8 @@ AC_SUBST(LT_VERSION_INFO)
 # Check for dependencies
 #PKG_CHECK_MODULES(DEP, x11)
 
-changequote(,)dnl
-if test "x$GCC" = "xyes"; then
-
-  case " $CFLAGS " in
-  *[\ \	]-Wall[\ \	]*) ;;
-  *) CFLAGS="$CFLAGS -Wall" ;;
-  esac 
-
-  case " $CFLAGS " in
-  *[\ \	]-fno-strict-aliasing[\ \	]*) ;;
-  *) CFLAGS="$CFLAGS -fno-strict-aliasing" ;;
-  esac
-
-fi changequote([,])dnl
+PIXMAN_CHECK_CFLAG([-Wall])
+PIXMAN_CHECK_CFLAG([-fno-strict-aliasing])
 
 AC_PATH_PROG(PERL, perl, no)
 if test "x$PERL" = xno; then
@@ -213,35 +247,19 @@ AC_SUBST(OPENMP_CFLAGS)
 dnl =========================================================================
 dnl -fvisibility stuff
 
-have_gcc4=no
-AC_MSG_CHECKING(for -fvisibility)
-AC_COMPILE_IFELSE([
+PIXMAN_CHECK_CFLAG([-fvisibility=hidden], [dnl
 #if defined(__GNUC__) && (__GNUC__ >= 4)
 #else
 error Need GCC 4.0 for visibility
 #endif
-int main () { return 0; } 
-], have_gcc4=yes)
-
-if test "x$have_gcc4" = "xyes"; then
-   CFLAGS="$CFLAGS -fvisibility=hidden"
-fi
-AC_MSG_RESULT($have_gcc4)
+])
 
-have_sunstudio8=no
-AC_MSG_CHECKING([for -xldscope (Sun compilers)])
-AC_COMPILE_IFELSE([
+PIXMAN_CHECK_CFLAG([-xldscope=hidden], [dnl
 #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
 #else
 error Need Sun Studio 8 for visibility
 #endif
-int main () { return 0; } 
-], have_sunstudio8=yes)
-
-if test "x$have_sunstudio8" = "xyes"; then
-   CFLAGS="$CFLAGS -xldscope=hidden"
-fi
-AC_MSG_RESULT($have_sunstudio8)
+])
 
 dnl ===========================================================================
 dnl Check for MMX
commit d95ae7060442712315d29c8b307df131ba9ffce6
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sat Jul 10 02:41:01 2010 +0100

    Check that the OpenMP pragmas don't cause link errors.
    
    This patch adds extra guards around our use of
    OpenMP pragmas and checks that the pragmas won't
    cause link errors.  This fixes the build on
    Tru64 and Solaris with the native compilers and clang.

diff --git a/configure.ac b/configure.ac
index 3c6f01d..d6f1d1c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,9 +77,22 @@ AC_CHECK_FUNCS([getisax])
 AC_C_BIGENDIAN
 AC_C_INLINE
 
-# Check for OpenMP support (only supported by autoconf >=2.62)
-OPENMP_CFLAGS=
-m4_ifdef([AC_OPENMP], [AC_OPENMP], [AC_SUBST(OPENMP_CFLAGS)])
+dnl PIXMAN_LINK_WITH_ENV(
+dnl	CFLAGS=... LDFLAGS=... LIBS=...,
+dnl	program, true-action, false-action)
+AC_DEFUN([PIXMAN_LINK_WITH_ENV],[dnl
+	save_CFLAGS="$CFLAGS"
+	save_LDFLAGS="$LDFLAGS"
+	save_LIBS="$LIBS"
+	CFLAGS=""
+	LDFLAGS=""
+	LIBS=""
+	$1
+	AC_LINK_IFELSE([$2], [$3], [$4])
+	CFLAGS="$save_CFLAGS"
+	LDFLAGS="$save_LDFLAGS"
+	LIBS="$save_LIBS"
+])
 
 AC_CHECK_SIZEOF(long)
 
@@ -143,6 +156,61 @@ fi
 AC_SUBST(PERL)
 
 dnl =========================================================================
+dnl OpenMP for the test suite?
+dnl
+
+# Check for OpenMP support (only supported by autoconf >=2.62)
+OPENMP_CFLAGS=
+m4_ifdef([AC_OPENMP], [AC_OPENMP])
+
+m4_define([openmp_test_program],[dnl
+#include <stdio.h>
+
+extern unsigned int lcg_seed;
+#pragma omp threadprivate(lcg_seed)
+unsigned int lcg_seed;
+
+unsigned function(unsigned a, unsigned b)
+{
+	lcg_seed ^= b;
+	return ((a + b) ^ a ) + lcg_seed;
+}
+
+int main(int argc, char **argv)
+{
+	int i;
+	int n1 = 0, n2 = argc;
+	unsigned checksum = 0;
+	int verbose = argv != NULL;
+	unsigned (*test_function)(unsigned, unsigned);
+	test_function = function;
+    #pragma omp parallel for reduction(+:checksum) default(none) \
+					shared(n1, n2, test_function, verbose)
+	for (i = n1; i < n2; i++)
+    	{
+		unsigned crc = test_function (i, 0);
+		if (verbose)
+			printf ("%d: %08X\n", i, crc);
+		checksum += crc;
+	}
+	printf("%u\n", checksum);
+	return 0;
+}
+])
+
+PIXMAN_LINK_WITH_ENV(
+	[CFLAGS="$OPENMP_CFLAGS" LDFLAGS="$OPENMP_CFLAGS"],
+	[openmp_test_program],
+	[have_openmp=yes],
+	[have_openmp=no])
+if test "x$have_openmp" = "xyes"; then
+   AC_DEFINE(USE_OPENMP, 1, [use OpenMP in the test suite])
+else
+   OPENMP_CFLAGS=""
+fi
+AC_SUBST(OPENMP_CFLAGS)
+
+dnl =========================================================================
 dnl -fvisibility stuff
 
 have_gcc4=no
@@ -585,21 +653,12 @@ main ()
 
 AC_DEFUN([PIXMAN_CHECK_PTHREAD],[dnl
     if test "z$support_for_pthread_setspecific" != "zyes"; then
-	save_CFLAGS="$CFLAGS"
-	save_LDFLAGS="$LDFLAGS"
-	save_LIBS="$LIBS"
-	CFLAGS=""
-	LDFLAGS=""
-	LIBS=""
-	$1
-	AC_LINK_IFELSE([pthread_test_program],
+	PIXMAN_LINK_WITH_ENV(
+		[$1], [pthread_test_program],
 		[PTHREAD_CFLAGS="$CFLAGS"
 		 PTHREAD_LIBS="$LIBS"
 		 PTHREAD_LDFLAGS="$LDFLAGS"
 		 support_for_pthread_setspecific=yes])
-	CFLAGS="$save_CFLAGS"
-	LDFLAGS="$save_LDFLAGS"
-	LIBS="$save_LIBS"
     fi
 ])
 
diff --git a/test/utils.c b/test/utils.c
index e9b29c8..1ee5c9c 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -286,8 +286,10 @@ fuzzer_test_main (const char *test_name,
 	n2 = default_number_of_iterations;
     }
 
+#ifdef USE_OPENMP
     #pragma omp parallel for reduction(+:checksum) default(none) \
 					shared(n1, n2, test_function, verbose)
+#endif
     for (i = n1; i <= n2; i++)
     {
 	uint32_t crc = test_function (i, 0);
diff --git a/test/utils.h b/test/utils.h
index 26a244c..8ec7b17 100644
--- a/test/utils.h
+++ b/test/utils.h
@@ -7,7 +7,9 @@
  */
 
 extern uint32_t lcg_seed;
+#ifdef USE_OPENMP
 #pragma omp threadprivate(lcg_seed)
+#endif
 
 static inline uint32_t
 lcg_rand (void)
commit eb247ac377623d2a722aab1e6eae7adab5f7ebea
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Fri Jul 9 12:09:07 2010 +0300

    Don't trust OpenBSD's gcc to produce working code for __thread.
    
    The gcc on OpenBSD 4.5 to 4.7 at least produces bad code for __thread,
    without as much as a warning.
    
    See PR #6410 "Using __thread TLS variables compiles ok but segfault at runtime."
    
    http://cvs.openbsd.org/cgi-bin/query-pr-wrapper?full=yes&numbers=6410

diff --git a/configure.ac b/configure.ac
index b9488d9..3c6f01d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -531,6 +531,9 @@ AC_LINK_IFELSE([
 #ifdef __MINGW32__
 #error MinGW has broken __thread support
 #endif
+#ifdef __OpenBSD__
+#error OpenBSD has broken __thread support
+#endif
 static __thread int x ;
 int main () { x = 123; return x; }
 ], support_for__thread=yes)
commit dbf35f1f276a673bc4a1eb932dd5cf9266f948da
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Fri Jul 9 12:07:35 2010 +0300

    Try harder to find suitable flags for pthreads.
    
    The flags -D_REENTRANT -lpthread work on more systems than
    does -pthread unfortunately, so give that a go too.

diff --git a/configure.ac b/configure.ac
index 56a6e4d..b9488d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -527,12 +527,12 @@ dnl Thread local storage
 support_for__thread=no
 
 AC_MSG_CHECKING(for __thread)
-AC_COMPILE_IFELSE([
+AC_LINK_IFELSE([
 #ifdef __MINGW32__
 #error MinGW has broken __thread support
 #endif
-__thread int x ;
-int main () { return 0; }
+static __thread int x ;
+int main () { x = 123; return x; }
 ], support_for__thread=yes)
 
 if test $support_for__thread = yes; then 
@@ -541,21 +541,11 @@ fi
 
 AC_MSG_RESULT($support_for__thread)
 
+dnl
 dnl posix tls
+dnl
 
-if test $support_for__thread = no; then
-
-support_for_pthread_setspecific=no
-   
-AC_MSG_CHECKING(for pthread_setspecific)
-
-save_LDFLAGS=$LDFLAGS
-
-LDFLAGS="-pthread"
-
-AC_LINK_IFELSE([
-#include <pthread.h>
-
+m4_define([pthread_test_program],[dnl
 #include <stdlib.h>
 #include <pthread.h>
 
@@ -572,7 +562,7 @@ int
 main ()
 {
     void *value = NULL;
-    
+
     if (pthread_once (&once_control, make_key) != 0)
     {
 	value = NULL;
@@ -586,23 +576,50 @@ main ()
 	    pthread_setspecific (key, value);
 	}
     }
+    return 0;
 }
-], support_for_pthread_setspecific=yes);
+])
+
+AC_DEFUN([PIXMAN_CHECK_PTHREAD],[dnl
+    if test "z$support_for_pthread_setspecific" != "zyes"; then
+	save_CFLAGS="$CFLAGS"
+	save_LDFLAGS="$LDFLAGS"
+	save_LIBS="$LIBS"
+	CFLAGS=""
+	LDFLAGS=""
+	LIBS=""
+	$1
+	AC_LINK_IFELSE([pthread_test_program],
+		[PTHREAD_CFLAGS="$CFLAGS"
+		 PTHREAD_LIBS="$LIBS"
+		 PTHREAD_LDFLAGS="$LDFLAGS"
+		 support_for_pthread_setspecific=yes])
+	CFLAGS="$save_CFLAGS"
+	LDFLAGS="$save_LDFLAGS"
+	LIBS="$save_LIBS"
+    fi
+])
+
+if test $support_for__thread = no; then
+    support_for_pthread_setspecific=no
 
-LDFLAGS=$save_LDFLAGS
+    AC_MSG_CHECKING(for pthread_setspecific)
 
-if test $support_for_pthread_setspecific = yes; then
-   PTHREAD_LDFLAGS="-pthread"
-   AC_DEFINE([HAVE_PTHREAD_SETSPECIFIC], [], [Whether pthread_setspecific() is supported])
-fi
+    PIXMAN_CHECK_PTHREAD([CFLAGS="-D_REENTRANT"; LIBS="-lpthread"])
+    PIXMAN_CHECK_PTHREAD([CFLAGS="-pthread"; LDFLAGS="-pthread"])
 
-AC_MSG_RESULT($support_for_pthread_setspecific);
+    if test $support_for_pthread_setspecific = yes; then
+	CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+	AC_DEFINE([HAVE_PTHREAD_SETSPECIFIC], [], [Whether pthread_setspecific() is supported])
+    fi
 
+    AC_MSG_RESULT($support_for_pthread_setspecific);
 fi
 
 AC_SUBST(TOOLCHAIN_SUPPORTS__THREAD)
 AC_SUBST(HAVE_PTHREAD_SETSPECIFIC)
 AC_SUBST(PTHREAD_LDFLAGS)
+AC_SUBST(PTHREAD_LIBS)
 
 AC_OUTPUT([pixman-1.pc
            pixman-1-uninstalled.pc
diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index 66ad7f0..7538219 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -1,6 +1,6 @@
 lib_LTLIBRARIES = libpixman-1.la
 libpixman_1_la_LDFLAGS = -version-info $(LT_VERSION_INFO) -no-undefined @PTHREAD_LDFLAGS@ 
-libpixman_1_la_LIBADD = @DEP_LIBS@ -lm
+libpixman_1_la_LIBADD = @PTHREAD_LIBS@ @DEP_LIBS@ -lm
 libpixman_1_la_SOURCES =			\
 	pixman.h				\
 	pixman-accessor.h			\


More information about the xorg-commit mailing list