Update ax_pthread.m4 to an experimental draft version from upstream.

The current version is adding a spurious -pthread option on some Darwin
systems that don't need it, which leads to a bunch of "unrecognized option
'-pthread'" warnings. There is a proposed fix for that in the upstream
autoconf archive's bug tracker, see https://savannah.gnu.org/patch/?8186.
This commit updates our version of ax_pthread.m4 to the "draft2" version
proposed there by Daniel Richard G. I'm using our buildfarm to help Daniel
to test this, before he commits this to the upstream repository.
This commit is contained in:
Heikki Linnakangas 2015-07-30 14:14:50 +03:00
parent c53f73879f
commit a2932283c2
2 changed files with 242 additions and 130 deletions

View file

@ -87,11 +87,12 @@
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [ AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_CC])
AC_LANG_PUSH([C]) AC_LANG_PUSH([C])
ax_pthread_ok=no ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h # We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on True64 or Sequent). # requires special compiler flags (e.g. on Tru64 or Sequent).
# It gets checked for in the link test anyway. # It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS, # First of all, check if the user has set any of the PTHREAD_LIBS,
@ -102,8 +103,8 @@ if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS" save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS" LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes]) AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
AC_MSG_RESULT([$ax_pthread_ok]) AC_MSG_RESULT([$ax_pthread_ok])
if test x"$ax_pthread_ok" = xno; then if test x"$ax_pthread_ok" = xno; then
PTHREAD_LIBS="" PTHREAD_LIBS=""
@ -123,7 +124,7 @@ fi
# which indicates that we try without any flags at all, and "pthread-config" # which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library. # which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mt -mthreads pthread --thread-safe pthread-config"
# The ordering *is* (sometimes) important. Some notes on the # The ordering *is* (sometimes) important. Some notes on the
# individual items follow: # individual items follow:
@ -134,49 +135,76 @@ ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mt
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
# -pthreads: Solaris/gcc # -pthreads: Solaris/gcc
# -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too; # doesn't hurt to check since this sometimes defines pthreads and
# also defines -D_REENTRANT) # -D_REENTRANT too), HP C (must be checked before -lpthread, which
# ... -mt is also the pthreads flag for HP/aCC # is present but should not be used directly)
# -mthreads: Mingw32/gcc, Lynx/gcc
# pthread: Linux, etcetera # pthread: Linux, etcetera
# --thread-safe: KAI C++ # --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library) # pthread-config: use pthread-config program (for GNU Pth library)
case ${host_os} in case $host_os in
hpux*)
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
# multi-threading and also sets -lpthread."
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
;;
openedition*)
# IBM z/OS requires a feature-test macro to be defined in order to
# enable POSIX threads at all, so give the user a hint if this is
# not set. (We don't define these ourselves, as they can affect
# other portions of the system API in unpredictable ways.)
AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
[
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
AX_PTHREAD_ZOS_MISSING
# endif
],
[AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
;;
solaris*) solaris*)
# On Solaris (at least, for some versions), libc contains stubbed # Newer versions of Solaris require the "-mt -lpthread" pair, and we
# check that first. On some older versions, libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based # (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but # a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So, # who knows whether they'll stub that too in a future libc.) So
# we'll just look for -pthreads and -lpthread first: # we'll look for -pthreads and -lpthread shortly thereafter.
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" ax_pthread_flags="-mt,pthread -pthreads -pthread pthread $ax_pthread_flags"
;;
darwin*)
ax_pthread_flags="-pthread $ax_pthread_flags"
;; ;;
esac esac
# Clang doesn't consider unrecognized options an error unless we specify # Older versions of Clang only give a warning instead of an error for an
# -Werror. We throw in some extra Clang-specific options to ensure that # unrecognized option, unless we specify -Werror. (We throw in some extra
# this doesn't happen for GCC, which also accepts -Werror. # Clang warning flags for good measure.)
AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags]) AC_CACHE_CHECK([if compiler needs certain flags to reject unknown flags],
save_CFLAGS="$CFLAGS" [ax_cv_PTHREAD_REJECT_UNKNOWN],
ax_pthread_extra_flags="-Werror" [ax_cv_PTHREAD_REJECT_UNKNOWN=unknown
CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument" save_CFLAGS="$CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])], ax_pthread_extra_flags="-Wunknown-warning-option -Wunused-command-line-argument"
[AC_MSG_RESULT([yes])], CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wfoobaz -foobaz"
[ax_pthread_extra_flags= AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
AC_MSG_RESULT([no])]) [ax_cv_PTHREAD_REJECT_UNKNOWN="-Werror $ax_pthread_extra_flags"],
CFLAGS="$save_CFLAGS" [ax_cv_PTHREAD_REJECT_UNKNOWN=no])
CFLAGS="$save_CFLAGS"
])
ax_pthread_extra_flags=
AS_IF([test "x$ax_cv_PTHREAD_REJECT_UNKNOWN" != "xno"],
[ax_pthread_extra_flags="$ax_cv_PTHREAD_REJECT_UNKNOWN"])
if test x"$ax_pthread_ok" = xno; then if test x"$ax_pthread_ok" = xno; then
for flag in $ax_pthread_flags; do for flag in $ax_pthread_flags; do
@ -186,6 +214,12 @@ for flag in $ax_pthread_flags; do
AC_MSG_CHECKING([whether pthreads work without any flags]) AC_MSG_CHECKING([whether pthreads work without any flags])
;; ;;
-mt,pthread)
AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
PTHREAD_CFLAGS="-mt"
PTHREAD_LIBS="-lpthread"
;;
-*) -*)
AC_MSG_CHECKING([whether pthreads work with $flag]) AC_MSG_CHECKING([whether pthreads work with $flag])
PTHREAD_CFLAGS="$flag" PTHREAD_CFLAGS="$flag"
@ -251,46 +285,54 @@ if test "x$ax_pthread_ok" = xyes; then
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED. # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_MSG_CHECKING([for joinable pthread attribute]) AC_CACHE_CHECK([for joinable pthread attribute],
attr_name=unknown [ax_cv_PTHREAD_JOINABLE_ATTR],
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do [ax_cv_PTHREAD_JOINABLE_ATTR=unknown
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
[int attr = $attr; return attr /* ; */])], AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[attr_name=$attr; break], [int attr = $attr; return attr /* ; */])],
[]) [ax_cv_PTHREAD_JOINABLE_ATTR=$attr; break],
done [])
AC_MSG_RESULT([$attr_name]) done
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then ])
AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name], AS_IF([test "$ax_cv_PTHREAD_JOINABLE_ATTR" != unknown && \
[Define to necessary symbol if this constant test "$ax_cv_PTHREAD_JOINABLE_ATTR" != PTHREAD_CREATE_JOINABLE],
uses a non-standard name on your system.]) [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
fi [$ax_cv_PTHREAD_JOINABLE_ATTR],
[Define to necessary symbol if this constant
uses a non-standard name on your system.])])
AC_MSG_CHECKING([if more special flags are required for pthreads]) AC_CACHE_CHECK([if more special flags are required for pthreads],
flag=no [ax_cv_PTHREAD_SPECIAL_FLAGS],
case ${host_os} in [ax_cv_PTHREAD_SPECIAL_FLAGS=no
aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; ax_pthread_special_flags_added=no
osf* | hpux*) flag="-D_REENTRANT";; AC_EGREP_CPP([AX_PTHREAD_NEED_SPECIAL_FLAG],
solaris*) [
if test "$GCC" = "yes"; then # if !defined(_REENTRANT) && !defined(_THREAD_SAFE)
flag="-D_REENTRANT" AX_PTHREAD_NEED_SPECIAL_FLAG
else # endif
# TODO: What about Clang on Solaris? ],
flag="-mt -D_REENTRANT" [case $host_os in
fi aix* | freebsd*)
;; ax_cv_PTHREAD_SPECIAL_FLAGS="-D_THREAD_SAFE"
esac ;;
AC_MSG_RESULT([$flag]) darwin* | hpux* | osf* | solaris*)
if test "x$flag" != xno; then ax_cv_PTHREAD_SPECIAL_FLAGS="-D_REENTRANT"
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" ;;
fi esac
])
])
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
test "x$ax_pthread_special_flags_added" != "xyes"],
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
ax_pthread_special_flags_added=yes])
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
[ax_cv_PTHREAD_PRIO_INHERIT], [ [ax_cv_PTHREAD_PRIO_INHERIT],
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_PRIO_INHERIT;]])], [[int i = PTHREAD_PRIO_INHERIT;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no]) [ax_cv_PTHREAD_PRIO_INHERIT=no])
]) ])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])]) [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])

196
configure vendored
View file

@ -7799,6 +7799,7 @@ if test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"; then :
# then # then
ac_ext=c ac_ext=c
ac_cpp='$CPP $CPPFLAGS' ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@ -7808,7 +7809,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
ax_pthread_ok=no ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h # We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on True64 or Sequent). # requires special compiler flags (e.g. on Tru64 or Sequent).
# It gets checked for in the link test anyway. # It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS, # First of all, check if the user has set any of the PTHREAD_LIBS,
@ -7819,8 +7820,8 @@ if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS" save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS" LIBS="$PTHREAD_LIBS $LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS" >&5
$as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; } $as_echo_n "checking for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -7864,7 +7865,7 @@ fi
# which indicates that we try without any flags at all, and "pthread-config" # which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library. # which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mt -mthreads pthread --thread-safe pthread-config"
# The ordering *is* (sometimes) important. Some notes on the # The ordering *is* (sometimes) important. Some notes on the
# individual items follow: # individual items follow:
@ -7875,46 +7876,80 @@ ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mt
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
# -pthreads: Solaris/gcc # -pthreads: Solaris/gcc
# -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too; # doesn't hurt to check since this sometimes defines pthreads and
# also defines -D_REENTRANT) # -D_REENTRANT too), HP C (must be checked before -lpthread, which
# ... -mt is also the pthreads flag for HP/aCC # is present but should not be used directly)
# -mthreads: Mingw32/gcc, Lynx/gcc
# pthread: Linux, etcetera # pthread: Linux, etcetera
# --thread-safe: KAI C++ # --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library) # pthread-config: use pthread-config program (for GNU Pth library)
case ${host_os} in case $host_os in
hpux*)
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
# multi-threading and also sets -lpthread."
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
;;
openedition*)
# IBM z/OS requires a feature-test macro to be defined in order to
# enable POSIX threads at all, so give the user a hint if this is
# not set. (We don't define these ourselves, as they can affect
# other portions of the system API in unpredictable ways.)
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
AX_PTHREAD_ZOS_MISSING
# endif
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "AX_PTHREAD_ZOS_MISSING" >/dev/null 2>&1; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support." >&5
$as_echo "$as_me: WARNING: IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support." >&2;}
fi
rm -f conftest*
;;
solaris*) solaris*)
# On Solaris (at least, for some versions), libc contains stubbed # Newer versions of Solaris require the "-mt -lpthread" pair, and we
# check that first. On some older versions, libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based # (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but # a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So, # who knows whether they'll stub that too in a future libc.) So
# we'll just look for -pthreads and -lpthread first: # we'll look for -pthreads and -lpthread shortly thereafter.
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" ax_pthread_flags="-mt,pthread -pthreads -pthread pthread $ax_pthread_flags"
;;
darwin*)
ax_pthread_flags="-pthread $ax_pthread_flags"
;; ;;
esac esac
# Clang doesn't consider unrecognized options an error unless we specify # Older versions of Clang only give a warning instead of an error for an
# -Werror. We throw in some extra Clang-specific options to ensure that # unrecognized option, unless we specify -Werror. (We throw in some extra
# this doesn't happen for GCC, which also accepts -Werror. # Clang warning flags for good measure.)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler needs -Werror to reject unknown flags" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler needs certain flags to reject unknown flags" >&5
$as_echo_n "checking if compiler needs -Werror to reject unknown flags... " >&6; } $as_echo_n "checking if compiler needs certain flags to reject unknown flags... " >&6; }
save_CFLAGS="$CFLAGS" if ${ax_cv_PTHREAD_REJECT_UNKNOWN+:} false; then :
ax_pthread_extra_flags="-Werror" $as_echo_n "(cached) " >&6
CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument" else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext ax_cv_PTHREAD_REJECT_UNKNOWN=unknown
save_CFLAGS="$CFLAGS"
ax_pthread_extra_flags="-Wunknown-warning-option -Wunused-command-line-argument"
CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wfoobaz -foobaz"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
int foo(void); int foo(void);
int int
@ -7926,15 +7961,20 @@ foo()
} }
_ACEOF _ACEOF
if ac_fn_c_try_compile "$LINENO"; then : if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ax_cv_PTHREAD_REJECT_UNKNOWN="-Werror $ax_pthread_extra_flags"
$as_echo "yes" >&6; }
else else
ax_pthread_extra_flags= ax_cv_PTHREAD_REJECT_UNKNOWN=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CFLAGS="$save_CFLAGS" CFLAGS="$save_CFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_REJECT_UNKNOWN" >&5
$as_echo "$ax_cv_PTHREAD_REJECT_UNKNOWN" >&6; }
ax_pthread_extra_flags=
if test "x$ax_cv_PTHREAD_REJECT_UNKNOWN" != "xno"; then :
ax_pthread_extra_flags="$ax_cv_PTHREAD_REJECT_UNKNOWN"
fi
if test x"$ax_pthread_ok" = xno; then if test x"$ax_pthread_ok" = xno; then
for flag in $ax_pthread_flags; do for flag in $ax_pthread_flags; do
@ -7945,6 +7985,13 @@ for flag in $ax_pthread_flags; do
$as_echo_n "checking whether pthreads work without any flags... " >&6; } $as_echo_n "checking whether pthreads work without any flags... " >&6; }
;; ;;
-mt,pthread)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with -mt -lpthread" >&5
$as_echo_n "checking whether pthreads work with -mt -lpthread... " >&6; }
PTHREAD_CFLAGS="-mt"
PTHREAD_LIBS="-lpthread"
;;
-*) -*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5
$as_echo_n "checking whether pthreads work with $flag... " >&6; } $as_echo_n "checking whether pthreads work with $flag... " >&6; }
@ -8064,9 +8111,12 @@ if test "x$ax_pthread_ok" = xyes; then
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED. # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5
$as_echo_n "checking for joinable pthread attribute... " >&6; } $as_echo_n "checking for joinable pthread attribute... " >&6; }
attr_name=unknown if ${ax_cv_PTHREAD_JOINABLE_ATTR+:} false; then :
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do $as_echo_n "(cached) " >&6
cat confdefs.h - <<_ACEOF >conftest.$ac_ext else
ax_cv_PTHREAD_JOINABLE_ATTR=unknown
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
#include <pthread.h> #include <pthread.h>
int int
@ -8078,49 +8128,69 @@ int attr = $attr; return attr /* ; */
} }
_ACEOF _ACEOF
if ac_fn_c_try_link "$LINENO"; then : if ac_fn_c_try_link "$LINENO"; then :
attr_name=$attr; break ax_cv_PTHREAD_JOINABLE_ATTR=$attr; break
fi fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
done done
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5
$as_echo "$attr_name" >&6; } fi
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_JOINABLE_ATTR" >&5
$as_echo "$ax_cv_PTHREAD_JOINABLE_ATTR" >&6; }
if test "$ax_cv_PTHREAD_JOINABLE_ATTR" != unknown && \
test "$ax_cv_PTHREAD_JOINABLE_ATTR" != PTHREAD_CREATE_JOINABLE; then :
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define PTHREAD_CREATE_JOINABLE $attr_name #define PTHREAD_CREATE_JOINABLE $ax_cv_PTHREAD_JOINABLE_ATTR
_ACEOF _ACEOF
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5
$as_echo_n "checking if more special flags are required for pthreads... " >&6; } $as_echo_n "checking if more special flags are required for pthreads... " >&6; }
flag=no if ${ax_cv_PTHREAD_SPECIAL_FLAGS+:} false; then :
case ${host_os} in $as_echo_n "(cached) " >&6
aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; else
osf* | hpux*) flag="-D_REENTRANT";; ax_cv_PTHREAD_SPECIAL_FLAGS=no
solaris*) ax_pthread_special_flags_added=no
if test "$GCC" = "yes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext
flag="-D_REENTRANT" /* end confdefs.h. */
else
# TODO: What about Clang on Solaris? # if !defined(_REENTRANT) && !defined(_THREAD_SAFE)
flag="-mt -D_REENTRANT" AX_PTHREAD_NEED_SPECIAL_FLAG
fi # endif
;;
esac _ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $flag" >&5 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$as_echo "$flag" >&6; } $EGREP "AX_PTHREAD_NEED_SPECIAL_FLAG" >/dev/null 2>&1; then :
if test "x$flag" != xno; then case $host_os in
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" aix* | freebsd*)
fi ax_cv_PTHREAD_SPECIAL_FLAGS="-D_THREAD_SAFE"
;;
darwin* | hpux* | osf* | solaris*)
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_REENTRANT"
;;
esac
fi
rm -f conftest*
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_SPECIAL_FLAGS" >&5
$as_echo "$ax_cv_PTHREAD_SPECIAL_FLAGS" >&6; }
if test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
test "x$ax_pthread_special_flags_added" != "xyes"; then :
PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
ax_pthread_special_flags_added=yes
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PRIO_INHERIT" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PRIO_INHERIT" >&5
$as_echo_n "checking for PTHREAD_PRIO_INHERIT... " >&6; } $as_echo_n "checking for PTHREAD_PRIO_INHERIT... " >&6; }
if ${ax_cv_PTHREAD_PRIO_INHERIT+:} false; then : if ${ax_cv_PTHREAD_PRIO_INHERIT+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
#include <pthread.h> #include <pthread.h>
int int