ax_pthread.m4 | ax_pthread.m4 | |||
---|---|---|---|---|
skipping to change at line 85 | skipping to change at line 85 | |||
# need not follow the terms of the GNU General Public License when using | # need not follow the terms of the GNU General Public License when using | |||
# or distributing such scripts, even though portions of the text of the | # or distributing such scripts, even though portions of the text of the | |||
# Macro appear in them. The GNU General Public License (GPL) does govern | # Macro appear in them. The GNU General Public License (GPL) does govern | |||
# all other use of the material that constitutes the Autoconf Macro. | # all other use of the material that constitutes the Autoconf Macro. | |||
# | # | |||
# This special exception to the GPL applies to versions of the Autoconf | # This special exception to the GPL applies to versions of the Autoconf | |||
# Macro released by the Autoconf Archive. When you make and distribute a | # Macro released by the Autoconf Archive. When you make and distribute a | |||
# modified version of the Autoconf Macro, you may extend this special | # modified version of the Autoconf Macro, you may extend this special | |||
# exception to the GPL to apply to your modified version as well. | # exception to the GPL to apply to your modified version as well. | |||
#serial 18 | #serial 21 | |||
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_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 True64 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, | |||
# etcetera environment variables, and if threads linking works using | # etcetera environment variables, and if threads linking works using | |||
# them: | # them: | |||
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then | if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then | |||
save_CFLAGS="$CFLAGS" | save_CFLAGS="$CFLAGS" | |||
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 in LIBS=$PTHREAD_LIBS with CFLAGS =$PTHREAD_CFLAGS]) | |||
AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes) | AC_TRY_LINK_FUNC([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="" | |||
PTHREAD_CFLAGS="" | PTHREAD_CFLAGS="" | |||
fi | fi | |||
LIBS="$save_LIBS" | LIBS="$save_LIBS" | |||
CFLAGS="$save_CFLAGS" | CFLAGS="$save_CFLAGS" | |||
fi | fi | |||
# We must check for the threads library under a number of different | # We must check for the threads library under a number of different | |||
# names; the ordering is very important because some systems | # names; the ordering is very important because some systems | |||
skipping to change at line 167 | skipping to change at line 167 | |||
# we'll just look for -pthreads and -lpthread first: | # we'll just look for -pthreads and -lpthread first: | |||
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" | ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" | |||
;; | ;; | |||
darwin*) | darwin*) | |||
ax_pthread_flags="-pthread $ax_pthread_flags" | ax_pthread_flags="-pthread $ax_pthread_flags" | |||
;; | ;; | |||
esac | esac | |||
# Clang doesn't consider unrecognized options an error unless we specify | ||||
# -Werror. We throw in some extra Clang-specific options to ensure that | ||||
# this doesn't happen for GCC, which also accepts -Werror. | ||||
AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags]) | ||||
save_CFLAGS="$CFLAGS" | ||||
ax_pthread_extra_flags="-Werror" | ||||
CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-a | ||||
rray-argument" | ||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])], | ||||
[AC_MSG_RESULT([yes])], | ||||
[ax_pthread_extra_flags= | ||||
AC_MSG_RESULT([no])]) | ||||
CFLAGS="$save_CFLAGS" | ||||
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 | |||
case $flag in | case $flag in | |||
none) | none) | |||
AC_MSG_CHECKING([whether pthreads work without any flags]) | AC_MSG_CHECKING([whether pthreads work without any flags]) | |||
;; | ;; | |||
-*) | -*) | |||
AC_MSG_CHECKING([whether pthreads work with $flag]) | AC_MSG_CHECKING([whether pthreads work with $flag]) | |||
PTHREAD_CFLAGS="$flag" | PTHREAD_CFLAGS="$flag" | |||
;; | ;; | |||
pthread-config) | pthread-config) | |||
AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no) | AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) | |||
if test x"$ax_pthread_config" = xno; then continue; fi | if test x"$ax_pthread_config" = xno; then continue; fi | |||
PTHREAD_CFLAGS="`pthread-config --cflags`" | PTHREAD_CFLAGS="`pthread-config --cflags`" | |||
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config -- libs`" | PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config -- libs`" | |||
;; | ;; | |||
*) | *) | |||
AC_MSG_CHECKING([for the pthreads library -l$flag]) | AC_MSG_CHECKING([for the pthreads library -l$flag]) | |||
PTHREAD_LIBS="-l$flag" | PTHREAD_LIBS="-l$flag" | |||
;; | ;; | |||
esac | esac | |||
save_LIBS="$LIBS" | save_LIBS="$LIBS" | |||
save_CFLAGS="$CFLAGS" | save_CFLAGS="$CFLAGS" | |||
LIBS="$PTHREAD_LIBS $LIBS" | LIBS="$PTHREAD_LIBS $LIBS" | |||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" | CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags" | |||
# Check for various functions. We must include pthread.h, | # Check for various functions. We must include pthread.h, | |||
# since some functions may be macros. (On the Sequent, we | # since some functions may be macros. (On the Sequent, we | |||
# need a special flag -Kthread to make this header compile.) | # need a special flag -Kthread to make this header compile.) | |||
# We check for pthread_join because it is in -lpthread on IRIX | # We check for pthread_join because it is in -lpthread on IRIX | |||
# while pthread_create is in libc. We check for pthread_attr_init | # while pthread_create is in libc. We check for pthread_attr_init | |||
# due to DEC craziness with -lpthreads. We check for | # due to DEC craziness with -lpthreads. We check for | |||
# pthread_cleanup_push because it is one of the few pthread | # pthread_cleanup_push because it is one of the few pthread | |||
# functions on Solaris that doesn't have a non-functional libc stub . | # functions on Solaris that doesn't have a non-functional libc stub . | |||
# We try pthread_create on general principles. | # We try pthread_create on general principles. | |||
skipping to change at line 222 | skipping to change at line 236 | |||
pthread_join(th, 0); | pthread_join(th, 0); | |||
pthread_attr_init(&attr); | pthread_attr_init(&attr); | |||
pthread_cleanup_push(routine, 0); | pthread_cleanup_push(routine, 0); | |||
pthread_cleanup_pop(0) /* ; */])], | pthread_cleanup_pop(0) /* ; */])], | |||
[ax_pthread_ok=yes], | [ax_pthread_ok=yes], | |||
[]) | []) | |||
LIBS="$save_LIBS" | LIBS="$save_LIBS" | |||
CFLAGS="$save_CFLAGS" | CFLAGS="$save_CFLAGS" | |||
AC_MSG_RESULT($ax_pthread_ok) | AC_MSG_RESULT([$ax_pthread_ok]) | |||
if test "x$ax_pthread_ok" = xyes; then | if test "x$ax_pthread_ok" = xyes; then | |||
break; | break; | |||
fi | fi | |||
PTHREAD_LIBS="" | PTHREAD_LIBS="" | |||
PTHREAD_CFLAGS="" | PTHREAD_CFLAGS="" | |||
done | done | |||
fi | fi | |||
# Various other checks: | # Various other checks: | |||
skipping to change at line 248 | skipping to change at line 262 | |||
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED. | # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. | |||
AC_MSG_CHECKING([for joinable pthread attribute]) | AC_MSG_CHECKING([for joinable pthread attribute]) | |||
attr_name=unknown | attr_name=unknown | |||
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do | for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do | |||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], | AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], | |||
[int attr = $attr; return attr /* ; */])], | [int attr = $attr; return attr /* ; */])], | |||
[attr_name=$attr; break], | [attr_name=$attr; break], | |||
[]) | []) | |||
done | done | |||
AC_MSG_RESULT($attr_name) | AC_MSG_RESULT([$attr_name]) | |||
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then | if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then | |||
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, | AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name], | |||
[Define to necessary symbol if this constant | [Define to necessary symbol if this constant | |||
uses a non-standard name on your system.]) | uses a non-standard name on your system.]) | |||
fi | fi | |||
AC_MSG_CHECKING([if more special flags are required for pthreads]) | AC_MSG_CHECKING([if more special flags are required for pthreads]) | |||
flag=no | flag=no | |||
case ${host_os} in | case ${host_os} in | |||
aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; | aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; | |||
osf* | hpux*) flag="-D_REENTRANT";; | osf* | hpux*) flag="-D_REENTRANT";; | |||
solaris*) | solaris*) | |||
if test "$GCC" = "yes"; then | if test "$GCC" = "yes"; then | |||
flag="-D_REENTRANT" | flag="-D_REENTRANT" | |||
else | else | |||
# TODO: What about Clang on Solaris? | ||||
flag="-mt -D_REENTRANT" | flag="-mt -D_REENTRANT" | |||
fi | fi | |||
;; | ;; | |||
esac | esac | |||
AC_MSG_RESULT(${flag}) | AC_MSG_RESULT([$flag]) | |||
if test "x$flag" != xno; then | if test "x$flag" != xno; then | |||
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" | PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" | |||
fi | fi | |||
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_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], | |||
AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTH | [[int i = PTHREAD_PRIO_INHE | |||
READ_PRIO_INHERIT;]])], | RIT;]])], | |||
[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_IN HERIT.])) | [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO _INHERIT.])]) | |||
LIBS="$save_LIBS" | LIBS="$save_LIBS" | |||
CFLAGS="$save_CFLAGS" | CFLAGS="$save_CFLAGS" | |||
# More AIX lossage: must compile with xlc_r or cc_r | # More AIX lossage: compile with *_r variant | |||
if test x"$GCC" != xyes; then | if test "x$GCC" != xyes; then | |||
AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) | case $host_os in | |||
else | aix*) | |||
PTHREAD_CC=$CC | AS_CASE(["x/$CC"], | |||
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xl | ||||
c|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], | ||||
[#handle absolute path differently from PATH based progra | ||||
m lookup | ||||
AS_CASE(["x$CC"], | ||||
[x/*], | ||||
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC} | ||||
_r"])], | ||||
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) | ||||
;; | ||||
esac | ||||
fi | fi | |||
else | ||||
PTHREAD_CC="$CC" | ||||
fi | fi | |||
AC_SUBST(PTHREAD_LIBS) | test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" | |||
AC_SUBST(PTHREAD_CFLAGS) | ||||
AC_SUBST(PTHREAD_CC) | AC_SUBST([PTHREAD_LIBS]) | |||
AC_SUBST([PTHREAD_CFLAGS]) | ||||
AC_SUBST([PTHREAD_CC]) | ||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: | # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: | |||
if test x"$ax_pthread_ok" = xyes; then | if test x"$ax_pthread_ok" = xyes; then | |||
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX thr eads libraries and header files.]),[$1]) | ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSI X threads libraries and header files.])],[$1]) | |||
: | : | |||
else | else | |||
ax_pthread_ok=no | ax_pthread_ok=no | |||
$2 | $2 | |||
fi | fi | |||
AC_LANG_POP | AC_LANG_POP | |||
])dnl AX_PTHREAD | ])dnl AX_PTHREAD | |||
End of changes. 16 change blocks. | ||||
25 lines changed or deleted | 52 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |