Blame m4/ax_pthread.m4

Packit 875988
# ===========================================================================
Packit 875988
#        https://www.gnu.org/software/autoconf-archive/ax_pthread.html
Packit 875988
# ===========================================================================
Packit 875988
#
Packit 875988
# SYNOPSIS
Packit 875988
#
Packit 875988
#   AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
Packit 875988
#
Packit 875988
# DESCRIPTION
Packit 875988
#
Packit 875988
#   This macro figures out how to build C programs using POSIX threads. It
Packit 875988
#   sets the PTHREAD_LIBS output variable to the threads library and linker
Packit 875988
#   flags, and the PTHREAD_CFLAGS output variable to any special C compiler
Packit 875988
#   flags that are needed. (The user can also force certain compiler
Packit 875988
#   flags/libs to be tested by setting these environment variables.)
Packit 875988
#
Packit 875988
#   Also sets PTHREAD_CC to any special C compiler that is needed for
Packit 875988
#   multi-threaded programs (defaults to the value of CC otherwise). (This
Packit 875988
#   is necessary on AIX to use the special cc_r compiler alias.)
Packit 875988
#
Packit 875988
#   NOTE: You are assumed to not only compile your program with these flags,
Packit 875988
#   but also to link with them as well. For example, you might link with
Packit 875988
#   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
Packit 875988
#
Packit 875988
#   If you are only building threaded programs, you may wish to use these
Packit 875988
#   variables in your default LIBS, CFLAGS, and CC:
Packit 875988
#
Packit 875988
#     LIBS="$PTHREAD_LIBS $LIBS"
Packit 875988
#     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
Packit 875988
#     CC="$PTHREAD_CC"
Packit 875988
#
Packit 875988
#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
Packit 875988
#   has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
Packit 875988
#   that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
Packit 875988
#
Packit 875988
#   Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
Packit 875988
#   PTHREAD_PRIO_INHERIT symbol is defined when compiling with
Packit 875988
#   PTHREAD_CFLAGS.
Packit 875988
#
Packit 875988
#   ACTION-IF-FOUND is a list of shell commands to run if a threads library
Packit 875988
#   is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
Packit 875988
#   is not found. If ACTION-IF-FOUND is not specified, the default action
Packit 875988
#   will define HAVE_PTHREAD.
Packit 875988
#
Packit 875988
#   Please let the authors know if this macro fails on any platform, or if
Packit 875988
#   you have any other suggestions or comments. This macro was based on work
Packit 875988
#   by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
Packit 875988
#   from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
Packit 875988
#   Alejandro Forero Cuervo to the autoconf macro repository. We are also
Packit 875988
#   grateful for the helpful feedback of numerous users.
Packit 875988
#
Packit 875988
#   Updated for Autoconf 2.68 by Daniel Richard G.
Packit 875988
#
Packit 875988
# LICENSE
Packit 875988
#
Packit 875988
#   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
Packit 875988
#   Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
Packit 875988
#
Packit 875988
#   This program is free software: you can redistribute it and/or modify it
Packit 875988
#   under the terms of the GNU General Public License as published by the
Packit 875988
#   Free Software Foundation, either version 3 of the License, or (at your
Packit 875988
#   option) any later version.
Packit 875988
#
Packit 875988
#   This program is distributed in the hope that it will be useful, but
Packit 875988
#   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 875988
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Packit 875988
#   Public License for more details.
Packit 875988
#
Packit 875988
#   You should have received a copy of the GNU General Public License along
Packit 875988
#   with this program. If not, see <https://www.gnu.org/licenses/>.
Packit 875988
#
Packit 875988
#   As a special exception, the respective Autoconf Macro's copyright owner
Packit 875988
#   gives unlimited permission to copy, distribute and modify the configure
Packit 875988
#   scripts that are the output of Autoconf when processing the Macro. You
Packit 875988
#   need not follow the terms of the GNU General Public License when using
Packit 875988
#   or distributing such scripts, even though portions of the text of the
Packit 875988
#   Macro appear in them. The GNU General Public License (GPL) does govern
Packit 875988
#   all other use of the material that constitutes the Autoconf Macro.
Packit 875988
#
Packit 875988
#   This special exception to the GPL applies to versions of the Autoconf
Packit 875988
#   Macro released by the Autoconf Archive. When you make and distribute a
Packit 875988
#   modified version of the Autoconf Macro, you may extend this special
Packit 875988
#   exception to the GPL to apply to your modified version as well.
Packit 875988
Packit 875988
#serial 24
Packit 875988
Packit 875988
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
Packit 875988
AC_DEFUN([AX_PTHREAD], [
Packit 875988
AC_REQUIRE([AC_CANONICAL_HOST])
Packit 875988
AC_REQUIRE([AC_PROG_CC])
Packit 875988
AC_REQUIRE([AC_PROG_SED])
Packit 875988
AC_LANG_PUSH([C])
Packit 875988
ax_pthread_ok=no
Packit 875988
Packit 875988
# We used to check for pthread.h first, but this fails if pthread.h
Packit 875988
# requires special compiler flags (e.g. on Tru64 or Sequent).
Packit 875988
# It gets checked for in the link test anyway.
Packit 875988
Packit 875988
# First of all, check if the user has set any of the PTHREAD_LIBS,
Packit 875988
# etcetera environment variables, and if threads linking works using
Packit 875988
# them:
Packit 875988
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
Packit 875988
        ax_pthread_save_CC="$CC"
Packit 875988
        ax_pthread_save_CFLAGS="$CFLAGS"
Packit 875988
        ax_pthread_save_LIBS="$LIBS"
Packit 875988
        AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
Packit 875988
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
Packit 875988
        LIBS="$PTHREAD_LIBS $LIBS"
Packit 875988
        AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
Packit 875988
        AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
Packit 875988
        AC_MSG_RESULT([$ax_pthread_ok])
Packit 875988
        if test "x$ax_pthread_ok" = "xno"; then
Packit 875988
                PTHREAD_LIBS=""
Packit 875988
                PTHREAD_CFLAGS=""
Packit 875988
        fi
Packit 875988
        CC="$ax_pthread_save_CC"
Packit 875988
        CFLAGS="$ax_pthread_save_CFLAGS"
Packit 875988
        LIBS="$ax_pthread_save_LIBS"
Packit 875988
fi
Packit 875988
Packit 875988
# We must check for the threads library under a number of different
Packit 875988
# names; the ordering is very important because some systems
Packit 875988
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
Packit 875988
# libraries is broken (non-POSIX).
Packit 875988
Packit 875988
# Create a list of thread flags to try.  Items starting with a "-" are
Packit 875988
# C compiler flags, and other items are library names, except for "none"
Packit 875988
# which indicates that we try without any flags at all, and "pthread-config"
Packit 875988
# which is a program returning the flags for the Pth emulation library.
Packit 875988
Packit 875988
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
Packit 875988
Packit 875988
# The ordering *is* (sometimes) important.  Some notes on the
Packit 875988
# individual items follow:
Packit 875988
Packit 875988
# pthreads: AIX (must check this before -lpthread)
Packit 875988
# none: in case threads are in libc; should be tried before -Kthread and
Packit 875988
#       other compiler flags to prevent continual compiler warnings
Packit 875988
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
Packit 875988
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
Packit 875988
#           (Note: HP C rejects this with "bad form for `-t' option")
Packit 875988
# -pthreads: Solaris/gcc (Note: HP C also rejects)
Packit 875988
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
Packit 875988
#      doesn't hurt to check since this sometimes defines pthreads and
Packit 875988
#      -D_REENTRANT too), HP C (must be checked before -lpthread, which
Packit 875988
#      is present but should not be used directly; and before -mthreads,
Packit 875988
#      because the compiler interprets this as "-mt" + "-hreads")
Packit 875988
# -mthreads: Mingw32/gcc, Lynx/gcc
Packit 875988
# pthread: Linux, etcetera
Packit 875988
# --thread-safe: KAI C++
Packit 875988
# pthread-config: use pthread-config program (for GNU Pth library)
Packit 875988
Packit 875988
case $host_os in
Packit 875988
Packit 875988
        freebsd*)
Packit 875988
Packit 875988
        # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
Packit 875988
        # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
Packit 875988
Packit 875988
        ax_pthread_flags="-kthread lthread $ax_pthread_flags"
Packit 875988
        ;;
Packit 875988
Packit 875988
        hpux*)
Packit 875988
Packit 875988
        # From the cc(1) man page: "[-mt] Sets various -D flags to enable
Packit 875988
        # multi-threading and also sets -lpthread."
Packit 875988
Packit 875988
        ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
Packit 875988
        ;;
Packit 875988
Packit 875988
        openedition*)
Packit 875988
Packit 875988
        # IBM z/OS requires a feature-test macro to be defined in order to
Packit 875988
        # enable POSIX threads at all, so give the user a hint if this is
Packit 875988
        # not set. (We don't define these ourselves, as they can affect
Packit 875988
        # other portions of the system API in unpredictable ways.)
Packit 875988
Packit 875988
        AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
Packit 875988
            [
Packit 875988
#            if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
Packit 875988
             AX_PTHREAD_ZOS_MISSING
Packit 875988
#            endif
Packit 875988
            ],
Packit 875988
            [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
Packit 875988
        ;;
Packit 875988
Packit 875988
        solaris*)
Packit 875988
Packit 875988
        # On Solaris (at least, for some versions), libc contains stubbed
Packit 875988
        # (non-functional) versions of the pthreads routines, so link-based
Packit 875988
        # tests will erroneously succeed. (N.B.: The stubs are missing
Packit 875988
        # pthread_cleanup_push, or rather a function called by this macro,
Packit 875988
        # so we could check for that, but who knows whether they'll stub
Packit 875988
        # that too in a future libc.)  So we'll check first for the
Packit 875988
        # standard Solaris way of linking pthreads (-mt -lpthread).
Packit 875988
Packit 875988
        ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags"
Packit 875988
        ;;
Packit 875988
esac
Packit 875988
Packit 875988
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
Packit 875988
Packit 875988
AS_IF([test "x$GCC" = "xyes"],
Packit 875988
      [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
Packit 875988
Packit 875988
# The presence of a feature test macro requesting re-entrant function
Packit 875988
# definitions is, on some systems, a strong hint that pthreads support is
Packit 875988
# correctly enabled
Packit 875988
Packit 875988
case $host_os in
Packit 875988
        darwin* | hpux* | linux* | osf* | solaris*)
Packit 875988
        ax_pthread_check_macro="_REENTRANT"
Packit 875988
        ;;
Packit 875988
Packit 875988
        aix*)
Packit 875988
        ax_pthread_check_macro="_THREAD_SAFE"
Packit 875988
        ;;
Packit 875988
Packit 875988
        *)
Packit 875988
        ax_pthread_check_macro="--"
Packit 875988
        ;;
Packit 875988
esac
Packit 875988
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
Packit 875988
      [ax_pthread_check_cond=0],
Packit 875988
      [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
Packit 875988
Packit 875988
# Are we compiling with Clang?
Packit 875988
Packit 875988
AC_CACHE_CHECK([whether $CC is Clang],
Packit 875988
    [ax_cv_PTHREAD_CLANG],
Packit 875988
    [ax_cv_PTHREAD_CLANG=no
Packit 875988
     # Note that Autoconf sets GCC=yes for Clang as well as GCC
Packit 875988
     if test "x$GCC" = "xyes"; then
Packit 875988
        AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
Packit 875988
            [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
Packit 875988
#            if defined(__clang__) && defined(__llvm__)
Packit 875988
             AX_PTHREAD_CC_IS_CLANG
Packit 875988
#            endif
Packit 875988
            ],
Packit 875988
            [ax_cv_PTHREAD_CLANG=yes])
Packit 875988
     fi
Packit 875988
    ])
Packit 875988
ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
Packit 875988
Packit 875988
ax_pthread_clang_warning=no
Packit 875988
Packit 875988
# Clang needs special handling, because older versions handle the -pthread
Packit 875988
# option in a rather... idiosyncratic way
Packit 875988
Packit 875988
if test "x$ax_pthread_clang" = "xyes"; then
Packit 875988
Packit 875988
        # Clang takes -pthread; it has never supported any other flag
Packit 875988
Packit 875988
        # (Note 1: This will need to be revisited if a system that Clang
Packit 875988
        # supports has POSIX threads in a separate library.  This tends not
Packit 875988
        # to be the way of modern systems, but it's conceivable.)
Packit 875988
Packit 875988
        # (Note 2: On some systems, notably Darwin, -pthread is not needed
Packit 875988
        # to get POSIX threads support; the API is always present and
Packit 875988
        # active.  We could reasonably leave PTHREAD_CFLAGS empty.  But
Packit 875988
        # -pthread does define _REENTRANT, and while the Darwin headers
Packit 875988
        # ignore this macro, third-party headers might not.)
Packit 875988
Packit 875988
        PTHREAD_CFLAGS="-pthread"
Packit 875988
        PTHREAD_LIBS=
Packit 875988
Packit 875988
        ax_pthread_ok=yes
Packit 875988
Packit 875988
        # However, older versions of Clang make a point of warning the user
Packit 875988
        # that, in an invocation where only linking and no compilation is
Packit 875988
        # taking place, the -pthread option has no effect ("argument unused
Packit 875988
        # during compilation").  They expect -pthread to be passed in only
Packit 875988
        # when source code is being compiled.
Packit 875988
        #
Packit 875988
        # Problem is, this is at odds with the way Automake and most other
Packit 875988
        # C build frameworks function, which is that the same flags used in
Packit 875988
        # compilation (CFLAGS) are also used in linking.  Many systems
Packit 875988
        # supported by AX_PTHREAD require exactly this for POSIX threads
Packit 875988
        # support, and in fact it is often not straightforward to specify a
Packit 875988
        # flag that is used only in the compilation phase and not in
Packit 875988
        # linking.  Such a scenario is extremely rare in practice.
Packit 875988
        #
Packit 875988
        # Even though use of the -pthread flag in linking would only print
Packit 875988
        # a warning, this can be a nuisance for well-run software projects
Packit 875988
        # that build with -Werror.  So if the active version of Clang has
Packit 875988
        # this misfeature, we search for an option to squash it.
Packit 875988
Packit 875988
        AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
Packit 875988
            [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
Packit 875988
            [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
Packit 875988
             # Create an alternate version of $ac_link that compiles and
Packit 875988
             # links in two steps (.c -> .o, .o -> exe) instead of one
Packit 875988
             # (.c -> exe), because the warning occurs only in the second
Packit 875988
             # step
Packit 875988
             ax_pthread_save_ac_link="$ac_link"
Packit 875988
             ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
Packit 875988
             ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
Packit 875988
             ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
Packit 875988
             ax_pthread_save_CFLAGS="$CFLAGS"
Packit 875988
             for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
Packit 875988
                AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
Packit 875988
                CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
Packit 875988
                ac_link="$ax_pthread_save_ac_link"
Packit 875988
                AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
Packit 875988
                    [ac_link="$ax_pthread_2step_ac_link"
Packit 875988
                     AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
Packit 875988
                         [break])
Packit 875988
                    ])
Packit 875988
             done
Packit 875988
             ac_link="$ax_pthread_save_ac_link"
Packit 875988
             CFLAGS="$ax_pthread_save_CFLAGS"
Packit 875988
             AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
Packit 875988
             ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
Packit 875988
            ])
Packit 875988
Packit 875988
        case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
Packit 875988
                no | unknown) ;;
Packit 875988
                *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
Packit 875988
        esac
Packit 875988
Packit 875988
fi # $ax_pthread_clang = yes
Packit 875988
Packit 875988
if test "x$ax_pthread_ok" = "xno"; then
Packit 875988
for ax_pthread_try_flag in $ax_pthread_flags; do
Packit 875988
Packit 875988
        case $ax_pthread_try_flag in
Packit 875988
                none)
Packit 875988
                AC_MSG_CHECKING([whether pthreads work without any flags])
Packit 875988
                ;;
Packit 875988
Packit 875988
                -mt,pthread)
Packit 875988
                AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
Packit 875988
                PTHREAD_CFLAGS="-mt"
Packit 875988
                PTHREAD_LIBS="-lpthread"
Packit 875988
                ;;
Packit 875988
Packit 875988
                -*)
Packit 875988
                AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
Packit 875988
                PTHREAD_CFLAGS="$ax_pthread_try_flag"
Packit 875988
                ;;
Packit 875988
Packit 875988
                pthread-config)
Packit 875988
                AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
Packit 875988
                AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
Packit 875988
                PTHREAD_CFLAGS="`pthread-config --cflags`"
Packit 875988
                PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
Packit 875988
                ;;
Packit 875988
Packit 875988
                *)
Packit 875988
                AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
Packit 875988
                PTHREAD_LIBS="-l$ax_pthread_try_flag"
Packit 875988
                ;;
Packit 875988
        esac
Packit 875988
Packit 875988
        ax_pthread_save_CFLAGS="$CFLAGS"
Packit 875988
        ax_pthread_save_LIBS="$LIBS"
Packit 875988
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
Packit 875988
        LIBS="$PTHREAD_LIBS $LIBS"
Packit 875988
Packit 875988
        # Check for various functions.  We must include pthread.h,
Packit 875988
        # since some functions may be macros.  (On the Sequent, we
Packit 875988
        # need a special flag -Kthread to make this header compile.)
Packit 875988
        # We check for pthread_join because it is in -lpthread on IRIX
Packit 875988
        # while pthread_create is in libc.  We check for pthread_attr_init
Packit 875988
        # due to DEC craziness with -lpthreads.  We check for
Packit 875988
        # pthread_cleanup_push because it is one of the few pthread
Packit 875988
        # functions on Solaris that doesn't have a non-functional libc stub.
Packit 875988
        # We try pthread_create on general principles.
Packit 875988
Packit 875988
        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
Packit 875988
#                       if $ax_pthread_check_cond
Packit 875988
#                        error "$ax_pthread_check_macro must be defined"
Packit 875988
#                       endif
Packit 875988
                        static void routine(void *a) { a = 0; }
Packit 875988
                        static void *start_routine(void *a) { return a; }],
Packit 875988
                       [pthread_t th; pthread_attr_t attr;
Packit 875988
                        pthread_create(&th, 0, start_routine, 0);
Packit 875988
                        pthread_join(th, 0);
Packit 875988
                        pthread_attr_init(&attr);
Packit 875988
                        pthread_cleanup_push(routine, 0);
Packit 875988
                        pthread_cleanup_pop(0) /* ; */])],
Packit 875988
            [ax_pthread_ok=yes],
Packit 875988
            [])
Packit 875988
Packit 875988
        CFLAGS="$ax_pthread_save_CFLAGS"
Packit 875988
        LIBS="$ax_pthread_save_LIBS"
Packit 875988
Packit 875988
        AC_MSG_RESULT([$ax_pthread_ok])
Packit 875988
        AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
Packit 875988
Packit 875988
        PTHREAD_LIBS=""
Packit 875988
        PTHREAD_CFLAGS=""
Packit 875988
done
Packit 875988
fi
Packit 875988
Packit 875988
# Various other checks:
Packit 875988
if test "x$ax_pthread_ok" = "xyes"; then
Packit 875988
        ax_pthread_save_CFLAGS="$CFLAGS"
Packit 875988
        ax_pthread_save_LIBS="$LIBS"
Packit 875988
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
Packit 875988
        LIBS="$PTHREAD_LIBS $LIBS"
Packit 875988
Packit 875988
        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
Packit 875988
        AC_CACHE_CHECK([for joinable pthread attribute],
Packit 875988
            [ax_cv_PTHREAD_JOINABLE_ATTR],
Packit 875988
            [ax_cv_PTHREAD_JOINABLE_ATTR=unknown
Packit 875988
             for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
Packit 875988
                 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
Packit 875988
                                                 [int attr = $ax_pthread_attr; return attr /* ; */])],
Packit 875988
                                [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
Packit 875988
                                [])
Packit 875988
             done
Packit 875988
            ])
Packit 875988
        AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
Packit 875988
               test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
Packit 875988
               test "x$ax_pthread_joinable_attr_defined" != "xyes"],
Packit 875988
              [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
Packit 875988
                                  [$ax_cv_PTHREAD_JOINABLE_ATTR],
Packit 875988
                                  [Define to necessary symbol if this constant
Packit 875988
                                   uses a non-standard name on your system.])
Packit 875988
               ax_pthread_joinable_attr_defined=yes
Packit 875988
              ])
Packit 875988
Packit 875988
        AC_CACHE_CHECK([whether more special flags are required for pthreads],
Packit 875988
            [ax_cv_PTHREAD_SPECIAL_FLAGS],
Packit 875988
            [ax_cv_PTHREAD_SPECIAL_FLAGS=no
Packit 875988
             case $host_os in
Packit 875988
             solaris*)
Packit 875988
             ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
Packit 875988
             ;;
Packit 875988
             esac
Packit 875988
            ])
Packit 875988
        AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
Packit 875988
               test "x$ax_pthread_special_flags_added" != "xyes"],
Packit 875988
              [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
Packit 875988
               ax_pthread_special_flags_added=yes])
Packit 875988
Packit 875988
        AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
Packit 875988
            [ax_cv_PTHREAD_PRIO_INHERIT],
Packit 875988
            [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
Packit 875988
                                             [[int i = PTHREAD_PRIO_INHERIT;]])],
Packit 875988
                            [ax_cv_PTHREAD_PRIO_INHERIT=yes],
Packit 875988
                            [ax_cv_PTHREAD_PRIO_INHERIT=no])
Packit 875988
            ])
Packit 875988
        AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
Packit 875988
               test "x$ax_pthread_prio_inherit_defined" != "xyes"],
Packit 875988
              [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
Packit 875988
               ax_pthread_prio_inherit_defined=yes
Packit 875988
              ])
Packit 875988
Packit 875988
        CFLAGS="$ax_pthread_save_CFLAGS"
Packit 875988
        LIBS="$ax_pthread_save_LIBS"
Packit 875988
Packit 875988
        # More AIX lossage: compile with *_r variant
Packit 875988
        if test "x$GCC" != "xyes"; then
Packit 875988
            case $host_os in
Packit 875988
                aix*)
Packit 875988
                AS_CASE(["x/$CC"],
Packit 875988
                    [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
Packit 875988
                    [#handle absolute path differently from PATH based program lookup
Packit 875988
                     AS_CASE(["x$CC"],
Packit 875988
                         [x/*],
Packit 875988
                         [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
Packit 875988
                         [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
Packit 875988
                ;;
Packit 875988
            esac
Packit 875988
        fi
Packit 875988
fi
Packit 875988
Packit 875988
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
Packit 875988
Packit 875988
AC_SUBST([PTHREAD_LIBS])
Packit 875988
AC_SUBST([PTHREAD_CFLAGS])
Packit 875988
AC_SUBST([PTHREAD_CC])
Packit 875988
Packit 875988
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
Packit 875988
if test "x$ax_pthread_ok" = "xyes"; then
Packit 875988
        ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
Packit 875988
        :
Packit 875988
else
Packit 875988
        ax_pthread_ok=no
Packit 875988
        $2
Packit 875988
fi
Packit 875988
AC_LANG_POP
Packit 875988
])dnl AX_PTHREAD