summaryrefslogtreecommitdiff
path: root/m4/pthreads.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/pthreads.m4')
-rw-r--r--m4/pthreads.m448
1 files changed, 28 insertions, 20 deletions
diff --git a/m4/pthreads.m4 b/m4/pthreads.m4
index d29f0d660..653a496da 100644
--- a/m4/pthreads.m4
+++ b/m4/pthreads.m4
@@ -20,9 +20,10 @@ AC_DEFUN([CC_PTHREAD_FLAGS], [
case $host in
*-hpux11*) PTHREAD_CFLAGS="" ;;
*-darwin*) PTHREAD_CFLAGS="" ;;
- *-solaris*)
- # Handle Studio compiler
+ *-solaris*|*-linux-gnu)
+ dnl Handle Sun Studio compiler (also on Linux)
CC_CHECK_CFLAGS([-mt], [PTHREAD_CFLAGS="-mt"]);;
+
*) PTHREAD_CFLAGS="-pthread" ;;
esac
fi
@@ -31,10 +32,15 @@ AC_DEFUN([CC_PTHREAD_FLAGS], [
*-hpux11*) PTHREAD_LIBS="-lpthread" ;;
*-darwin*) PTHREAD_LIBS="" ;;
*-solaris*)
- # Use the same libraries for gcc and sun studio cc
+ dnl Use the same libraries for gcc and Sun Studio cc
PTHREAD_LIBS="-lpthread -lposix4 -lrt";;
*) PTHREAD_LIBS="-pthread" ;;
esac
+
+ dnl Again, handle Sun Studio compiler
+ if test "x${PTHREAD_CFLAGS}" = "x-mt"; then
+ PTHREAD_LIBS="-mt"
+ fi
fi
AC_CACHE_CHECK([if $CC supports Pthread],
@@ -47,7 +53,7 @@ AC_DEFUN([CC_PTHREAD_FLAGS], [
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <pthread.h>
- void *fakethread(void *arg) { return NULL; }
+ void *fakethread(void *arg) { (void)arg; return NULL; }
pthread_t fakevariable;
]],
[[pthread_create(&fakevariable, NULL, &fakethread, NULL);]]
@@ -69,26 +75,28 @@ AC_DEFUN([CC_PTHREAD_FLAGS], [
])
AC_DEFUN([CC_PTHREAD_RECURSIVE_MUTEX], [
- AC_REQUIRE([CC_PTHREAD_FLAGS])
- AC_MSG_CHECKING([for recursive mutex support in pthread])
-
- ac_save_LIBS="$LIBS"
- LIBS="$LIBS $PTHREAD_LIBS"
- AC_COMPILE_IFELSE(AC_LANG_SOURCE([#include <pthread.h>
-
+ AC_REQUIRE([CC_PTHREAD_FLAGS])
+ AC_CACHE_CHECK(
+ [for recursive mutex support in pthread],
+ [cc_cv_pthread_recursive_mutex],
+ [ac_save_LIBS="$LIBS"
+ LIBS="$LIBS $PTHREAD_LIBS"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([
+#include <pthread.h>
+ ], [
int main() {
pthread_mutexattr_t attr;
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
return 0;
}
- ]), [have_recursive_mutex=yes], [have_recursive_mutex=no])
- LIBS="$ac_save_LIBS"
-
- AC_MSG_RESULT([$have_recursive_mutex])
+ ])
+ ],
+ [cc_cv_pthread_recursive_mutex=yes],
+ [cc_cv_pthread_recursive_mutex=no])
+ LIBS="$ac_save_LIBS"
+ ])
- if test x"$have_recursive_mutex" = x"yes"; then
- ifelse([$1], , [:], [$1])
- else
- ifelse([$2], , [:], [$2])
- fi
+ AS_IF([test x"$cc_cv_pthread_recursive_mutex" = x"yes"],
+ [$1], [$2])
])