mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-08-08 17:22:05 +03:00
pthread-h: Fix link errors with --enable-threads=isoc on AIX.
* m4/threadlib.m4 (gl_ANYTHREADLIB_EARLY): New macro, extracted from gl_THREADLIB_EARLY_BODY. (gl_THREADLIB_EARLY_BODY): Invoke it. (gl_PTHREADLIB_BODY): New macro, extracted from gl_THREADLIB_BODY. (gl_THREADLIB_BODY): Invoke it. (gl_PTHREADLIB): New macro. * m4/pthread_h.m4 (gl_PTHREAD_H): Require gl_PTHREADLIB. Require gl_THREADLIB and test $gl_threads_api only if module 'threadlib' is present. Define LIB_PTHREAD using LIBPMULTITHREAD, not LIBMULTITHREAD. * modules/pthread-h (Files): Add threadlib.m4. (Depends-on): Remove threadlib. (configure.ac-early): Invoke gl_ANYTHREADLIB_EARLY. Don't set _REENTRANT and _THREAD_SAFE here. (Link): Use LIBPTHREAD, not LIBTHREAD. * modules/pthread-thread (Link): Use LIBPMULTITHREAD, not LIBMULTITHREAD. * modules/pthread-once (Link): Likewise. * modules/pthread-mutex (Link): Likewise. * modules/pthread-rwlock (Link): Likewise. * modules/pthread-cond (Link): Likewise. * modules/pthread-tss (Link): Likewise. * modules/pthread-spin (Link): Likewise. * modules/pthread (Link): Likewise. * modules/pthread-h-c++-tests (test_pthread_c___LDADD): Likewise. * modules/pthread-thread-tests (test_pthread_thread_LDADD): Likewise. * modules/pthread-once-tests (test_pthread_once1_LDADD, test_pthread_once2_LDADD): Likewise. * modules/pthread-mutex-tests (test_pthread_mutex_LDADD): Likewise. * modules/pthread-rwlock-tests (test_pthread_rwlock_LDADD): Likewise. * modules/pthread-cond-tests (test_pthread_cond_LDADD): Likewise. * modules/pthread-tss-tests (test_pthread_tss_LDADD): Likewise.
This commit is contained in:
35
ChangeLog
35
ChangeLog
@@ -1,3 +1,38 @@
|
|||||||
|
2019-12-01 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
|
pthread-h: Fix link errors with --enable-threads=isoc on AIX.
|
||||||
|
* m4/threadlib.m4 (gl_ANYTHREADLIB_EARLY): New macro, extracted from
|
||||||
|
gl_THREADLIB_EARLY_BODY.
|
||||||
|
(gl_THREADLIB_EARLY_BODY): Invoke it.
|
||||||
|
(gl_PTHREADLIB_BODY): New macro, extracted from gl_THREADLIB_BODY.
|
||||||
|
(gl_THREADLIB_BODY): Invoke it.
|
||||||
|
(gl_PTHREADLIB): New macro.
|
||||||
|
* m4/pthread_h.m4 (gl_PTHREAD_H): Require gl_PTHREADLIB. Require
|
||||||
|
gl_THREADLIB and test $gl_threads_api only if module 'threadlib' is
|
||||||
|
present. Define LIB_PTHREAD using LIBPMULTITHREAD, not LIBMULTITHREAD.
|
||||||
|
* modules/pthread-h (Files): Add threadlib.m4.
|
||||||
|
(Depends-on): Remove threadlib.
|
||||||
|
(configure.ac-early): Invoke gl_ANYTHREADLIB_EARLY. Don't set _REENTRANT
|
||||||
|
and _THREAD_SAFE here.
|
||||||
|
(Link): Use LIBPTHREAD, not LIBTHREAD.
|
||||||
|
* modules/pthread-thread (Link): Use LIBPMULTITHREAD, not
|
||||||
|
LIBMULTITHREAD.
|
||||||
|
* modules/pthread-once (Link): Likewise.
|
||||||
|
* modules/pthread-mutex (Link): Likewise.
|
||||||
|
* modules/pthread-rwlock (Link): Likewise.
|
||||||
|
* modules/pthread-cond (Link): Likewise.
|
||||||
|
* modules/pthread-tss (Link): Likewise.
|
||||||
|
* modules/pthread-spin (Link): Likewise.
|
||||||
|
* modules/pthread (Link): Likewise.
|
||||||
|
* modules/pthread-h-c++-tests (test_pthread_c___LDADD): Likewise.
|
||||||
|
* modules/pthread-thread-tests (test_pthread_thread_LDADD): Likewise.
|
||||||
|
* modules/pthread-once-tests (test_pthread_once1_LDADD,
|
||||||
|
test_pthread_once2_LDADD): Likewise.
|
||||||
|
* modules/pthread-mutex-tests (test_pthread_mutex_LDADD): Likewise.
|
||||||
|
* modules/pthread-rwlock-tests (test_pthread_rwlock_LDADD): Likewise.
|
||||||
|
* modules/pthread-cond-tests (test_pthread_cond_LDADD): Likewise.
|
||||||
|
* modules/pthread-tss-tests (test_pthread_tss_LDADD): Likewise.
|
||||||
|
|
||||||
2019-12-01 Bruno Haible <bruno@clisp.org>
|
2019-12-01 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
cond: State linking requirements.
|
cond: State linking requirements.
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# pthread_h.m4 serial 4
|
# pthread_h.m4 serial 5
|
||||||
dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
|
dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
|
||||||
dnl This file is free software; the Free Software Foundation
|
dnl This file is free software; the Free Software Foundation
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
@@ -10,13 +10,21 @@ AC_DEFUN([gl_PTHREAD_H],
|
|||||||
dnl once only, before all statements that occur in other macros.
|
dnl once only, before all statements that occur in other macros.
|
||||||
AC_REQUIRE([gl_PTHREAD_H_DEFAULTS])
|
AC_REQUIRE([gl_PTHREAD_H_DEFAULTS])
|
||||||
|
|
||||||
AC_REQUIRE([gl_THREADLIB])
|
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||||
|
AC_REQUIRE([gl_PTHREADLIB])
|
||||||
|
|
||||||
gl_CHECK_NEXT_HEADERS([pthread.h])
|
gl_CHECK_NEXT_HEADERS([pthread.h])
|
||||||
dnl On mingw, if --enable-threads=windows or gl_AVOID_WINPTHREAD is used,
|
if test $ac_cv_header_pthread_h = yes; then
|
||||||
dnl ignore the <pthread.h> from the mingw-w64 winpthreads library.
|
|
||||||
if test $ac_cv_header_pthread_h = yes && test $gl_threads_api != windows; then
|
|
||||||
HAVE_PTHREAD_H=1
|
HAVE_PTHREAD_H=1
|
||||||
|
dnl On mingw, if --enable-threads=windows or gl_AVOID_WINPTHREAD is used,
|
||||||
|
dnl ignore the <pthread.h> from the mingw-w64 winpthreads library.
|
||||||
|
m4_ifdef([gl_][THREADLIB], [
|
||||||
|
AC_REQUIRE([gl_][THREADLIB])
|
||||||
|
if { case "$host_os" in mingw*) true;; *) false;; esac; } \
|
||||||
|
&& test $gl_threads_api = windows; then
|
||||||
|
HAVE_PTHREAD_H=0
|
||||||
|
fi
|
||||||
|
])
|
||||||
else
|
else
|
||||||
HAVE_PTHREAD_H=0
|
HAVE_PTHREAD_H=0
|
||||||
fi
|
fi
|
||||||
@@ -125,7 +133,7 @@ AC_DEFUN([gl_PTHREAD_H],
|
|||||||
AC_REQUIRE([AC_C_RESTRICT])
|
AC_REQUIRE([AC_C_RESTRICT])
|
||||||
|
|
||||||
dnl For backward compatibility with gnulib versions <= 2019-07.
|
dnl For backward compatibility with gnulib versions <= 2019-07.
|
||||||
LIB_PTHREAD="$LIBMULTITHREAD"
|
LIB_PTHREAD="$LIBPMULTITHREAD"
|
||||||
AC_SUBST([LIB_PTHREAD])
|
AC_SUBST([LIB_PTHREAD])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
249
m4/threadlib.m4
249
m4/threadlib.m4
@@ -1,4 +1,4 @@
|
|||||||
# threadlib.m4 serial 21
|
# threadlib.m4 serial 22
|
||||||
dnl Copyright (C) 2005-2019 Free Software Foundation, Inc.
|
dnl Copyright (C) 2005-2019 Free Software Foundation, Inc.
|
||||||
dnl This file is free software; the Free Software Foundation
|
dnl This file is free software; the Free Software Foundation
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
@@ -8,6 +8,17 @@ dnl From Bruno Haible.
|
|||||||
|
|
||||||
AC_PREREQ([2.60])
|
AC_PREREQ([2.60])
|
||||||
|
|
||||||
|
dnl gl_PTHREADLIB
|
||||||
|
dnl -------------
|
||||||
|
dnl Tests for the libraries needs for using the POSIX threads API.
|
||||||
|
dnl Sets the variable LIBPTHREAD to the linker options for use in a Makefile.
|
||||||
|
dnl Sets the variable LIBPMULTITHREAD, for programs that really need
|
||||||
|
dnl multithread functionality. The difference between LIBPTHREAD and
|
||||||
|
dnl LIBPMULTITHREAD is that on platforms supporting weak symbols, typically
|
||||||
|
dnl LIBPTHREAD is empty whereas LIBPMULTITHREAD is not.
|
||||||
|
dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
|
||||||
|
dnl multithread-safe programs.
|
||||||
|
|
||||||
dnl gl_THREADLIB
|
dnl gl_THREADLIB
|
||||||
dnl ------------
|
dnl ------------
|
||||||
dnl Tests for a multithreading library to be used.
|
dnl Tests for a multithreading library to be used.
|
||||||
@@ -36,6 +47,32 @@ dnl Since support for GNU pth was removed, $LTLIBTHREAD and $LIBTHREAD have the
|
|||||||
dnl same value, and similarly $LTLIBMULTITHREAD and $LIBMULTITHREAD have the
|
dnl same value, and similarly $LTLIBMULTITHREAD and $LIBMULTITHREAD have the
|
||||||
dnl same value. Only system libraries are needed.
|
dnl same value. Only system libraries are needed.
|
||||||
|
|
||||||
|
AC_DEFUN([gl_ANYTHREADLIB_EARLY],
|
||||||
|
[
|
||||||
|
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||||
|
if test -z "$gl_anythreadlib_early_done"; then
|
||||||
|
case "$host_os" in
|
||||||
|
osf*)
|
||||||
|
# On OSF/1, the compiler needs the flag -D_REENTRANT so that it
|
||||||
|
# groks <pthread.h>. cc also understands the flag -pthread, but
|
||||||
|
# we don't use it because 1. gcc-2.95 doesn't understand -pthread,
|
||||||
|
# 2. putting a flag into CPPFLAGS that has an effect on the linker
|
||||||
|
# causes the AC_LINK_IFELSE test below to succeed unexpectedly,
|
||||||
|
# leading to wrong values of LIBTHREAD and LTLIBTHREAD.
|
||||||
|
CPPFLAGS="$CPPFLAGS -D_REENTRANT"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
# Some systems optimize for single-threaded programs by default, and
|
||||||
|
# need special flags to disable these optimizations. For example, the
|
||||||
|
# definition of 'errno' in <errno.h>.
|
||||||
|
case "$host_os" in
|
||||||
|
aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
|
||||||
|
solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
|
||||||
|
esac
|
||||||
|
gl_anythreadlib_early_done=done
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
AC_DEFUN([gl_THREADLIB_EARLY],
|
AC_DEFUN([gl_THREADLIB_EARLY],
|
||||||
[
|
[
|
||||||
AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
|
AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
|
||||||
@@ -99,24 +136,91 @@ changequote([,])dnl
|
|||||||
|| test "$gl_use_threads" = posix \
|
|| test "$gl_use_threads" = posix \
|
||||||
|| test "$gl_use_threads" = isoc+posix; then
|
|| test "$gl_use_threads" = isoc+posix; then
|
||||||
# For using <threads.h> or <pthread.h>:
|
# For using <threads.h> or <pthread.h>:
|
||||||
case "$host_os" in
|
gl_ANYTHREADLIB_EARLY
|
||||||
osf*)
|
fi
|
||||||
# On OSF/1, the compiler needs the flag -D_REENTRANT so that it
|
])
|
||||||
# groks <pthread.h>. cc also understands the flag -pthread, but
|
|
||||||
# we don't use it because 1. gcc-2.95 doesn't understand -pthread,
|
dnl The guts of gl_PTHREADLIB. Needs to be expanded only once.
|
||||||
# 2. putting a flag into CPPFLAGS that has an effect on the linker
|
|
||||||
# causes the AC_LINK_IFELSE test below to succeed unexpectedly,
|
AC_DEFUN([gl_PTHREADLIB_BODY],
|
||||||
# leading to wrong values of LIBTHREAD and LTLIBTHREAD.
|
[
|
||||||
CPPFLAGS="$CPPFLAGS -D_REENTRANT"
|
AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
|
||||||
;;
|
if test -z "$gl_threadlib_body_done"; then
|
||||||
esac
|
gl_pthread_api=no
|
||||||
# Some systems optimize for single-threaded programs by default, and
|
LIBPTHREAD=
|
||||||
# need special flags to disable these optimizations. For example, the
|
LIBPMULTITHREAD=
|
||||||
# definition of 'errno' in <errno.h>.
|
# On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
|
||||||
case "$host_os" in
|
# it groks <pthread.h>. It's added above, in gl_ANYTHREADLIB_EARLY.
|
||||||
aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
|
AC_CHECK_HEADER([pthread.h],
|
||||||
solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
|
[gl_have_pthread_h=yes], [gl_have_pthread_h=no])
|
||||||
esac
|
if test "$gl_have_pthread_h" = yes; then
|
||||||
|
# Other possible tests:
|
||||||
|
# -lpthreads (FSU threads, PCthreads)
|
||||||
|
# -lgthreads
|
||||||
|
# Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
|
||||||
|
# in libc. IRIX 6.5 has the first one in both libc and libpthread, but
|
||||||
|
# the second one only in libpthread, and lock.c needs it.
|
||||||
|
#
|
||||||
|
# If -pthread works, prefer it to -lpthread, since Ubuntu 14.04
|
||||||
|
# needs -pthread for some reason. See:
|
||||||
|
# https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html
|
||||||
|
save_LIBS=$LIBS
|
||||||
|
for gl_pthread in '' '-pthread'; do
|
||||||
|
LIBS="$LIBS $gl_pthread"
|
||||||
|
AC_LINK_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM(
|
||||||
|
[[#include <pthread.h>
|
||||||
|
pthread_mutex_t m;
|
||||||
|
pthread_mutexattr_t ma;
|
||||||
|
]],
|
||||||
|
[[pthread_mutex_lock (&m);
|
||||||
|
pthread_mutexattr_init (&ma);]])],
|
||||||
|
[gl_pthread_api=yes
|
||||||
|
LIBPTHREAD=$gl_pthread
|
||||||
|
LIBPMULTITHREAD=$gl_pthread])
|
||||||
|
LIBS=$save_LIBS
|
||||||
|
test $gl_pthread_api = yes && break
|
||||||
|
done
|
||||||
|
|
||||||
|
# Test for libpthread by looking for pthread_kill. (Not pthread_self,
|
||||||
|
# since it is defined as a macro on OSF/1.)
|
||||||
|
if test $gl_pthread_api = yes && test -z "$LIBPTHREAD"; then
|
||||||
|
# The program links fine without libpthread. But it may actually
|
||||||
|
# need to link with libpthread in order to create multiple threads.
|
||||||
|
AC_CHECK_LIB([pthread], [pthread_kill],
|
||||||
|
[LIBPMULTITHREAD=-lpthread
|
||||||
|
# On Solaris and HP-UX, most pthread functions exist also in libc.
|
||||||
|
# Therefore pthread_in_use() needs to actually try to create a
|
||||||
|
# thread: pthread_create from libc will fail, whereas
|
||||||
|
# pthread_create will actually create a thread.
|
||||||
|
# On Solaris 10 or newer, this test is no longer needed, because
|
||||||
|
# libc contains the fully functional pthread functions.
|
||||||
|
case "$host_os" in
|
||||||
|
solaris | solaris2.[1-9] | solaris2.[1-9].* | hpux*)
|
||||||
|
AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
|
||||||
|
[Define if the pthread_in_use() detection is hard.])
|
||||||
|
esac
|
||||||
|
])
|
||||||
|
elif test $gl_pthread_api != yes; then
|
||||||
|
# Some library is needed. Try libpthread and libc_r.
|
||||||
|
AC_CHECK_LIB([pthread], [pthread_kill],
|
||||||
|
[gl_pthread_api=yes
|
||||||
|
LIBPTHREAD=-lpthread
|
||||||
|
LIBPMULTITHREAD=-lpthread])
|
||||||
|
if test $gl_pthread_api != yes; then
|
||||||
|
# For FreeBSD 4.
|
||||||
|
AC_CHECK_LIB([c_r], [pthread_kill],
|
||||||
|
[gl_pthread_api=yes
|
||||||
|
LIBPTHREAD=-lc_r
|
||||||
|
LIBPMULTITHREAD=-lc_r])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
AC_MSG_CHECKING([whether POSIX threads API is available])
|
||||||
|
AC_MSG_RESULT([$gl_pthread_api])
|
||||||
|
AC_SUBST([LIBPTHREAD])
|
||||||
|
AC_SUBST([LIBPMULTITHREAD])
|
||||||
|
gl_threadlib_body_done=done
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -198,89 +302,24 @@ int main ()
|
|||||||
if test "$gl_use_threads" = yes \
|
if test "$gl_use_threads" = yes \
|
||||||
|| test "$gl_use_threads" = posix \
|
|| test "$gl_use_threads" = posix \
|
||||||
|| test "$gl_use_threads" = isoc+posix; then
|
|| test "$gl_use_threads" = isoc+posix; then
|
||||||
# On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
|
gl_PTHREADLIB_BODY
|
||||||
# it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
|
LIBTHREAD=$LIBPTHREAD LTLIBTHREAD=$LIBPTHREAD
|
||||||
AC_CHECK_HEADER([pthread.h],
|
LIBMULTITHREAD=$LIBPMULTITHREAD LTLIBMULTITHREAD=$LIBPMULTITHREAD
|
||||||
[gl_have_pthread_h=yes], [gl_have_pthread_h=no])
|
if test $gl_pthread_api = yes; then
|
||||||
if test "$gl_have_pthread_h" = yes; then
|
if test "$gl_use_threads" = isoc+posix && test "$gl_have_isoc_threads" = yes; then
|
||||||
# Other possible tests:
|
gl_threads_api='isoc+posix'
|
||||||
# -lpthreads (FSU threads, PCthreads)
|
AC_DEFINE([USE_ISOC_AND_POSIX_THREADS], [1],
|
||||||
# -lgthreads
|
[Define if the combination of the ISO C and POSIX multithreading APIs can be used.])
|
||||||
gl_have_pthread=
|
LIBTHREAD= LTLIBTHREAD=
|
||||||
# Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
|
else
|
||||||
# in libc. IRIX 6.5 has the first one in both libc and libpthread, but
|
gl_threads_api=posix
|
||||||
# the second one only in libpthread, and lock.c needs it.
|
AC_DEFINE([USE_POSIX_THREADS], [1],
|
||||||
#
|
[Define if the POSIX multithreading library can be used.])
|
||||||
# If -pthread works, prefer it to -lpthread, since Ubuntu 14.04
|
if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
|
||||||
# needs -pthread for some reason. See:
|
if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
|
||||||
# https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html
|
AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
|
||||||
save_LIBS=$LIBS
|
[Define if references to the POSIX multithreading library should be made weak.])
|
||||||
for gl_pthread in '' '-pthread'; do
|
LIBTHREAD= LTLIBTHREAD=
|
||||||
LIBS="$LIBS $gl_pthread"
|
|
||||||
AC_LINK_IFELSE(
|
|
||||||
[AC_LANG_PROGRAM(
|
|
||||||
[[#include <pthread.h>
|
|
||||||
pthread_mutex_t m;
|
|
||||||
pthread_mutexattr_t ma;
|
|
||||||
]],
|
|
||||||
[[pthread_mutex_lock (&m);
|
|
||||||
pthread_mutexattr_init (&ma);]])],
|
|
||||||
[gl_have_pthread=yes
|
|
||||||
LIBTHREAD=$gl_pthread LTLIBTHREAD=$gl_pthread
|
|
||||||
LIBMULTITHREAD=$gl_pthread LTLIBMULTITHREAD=$gl_pthread])
|
|
||||||
LIBS=$save_LIBS
|
|
||||||
test -n "$gl_have_pthread" && break
|
|
||||||
done
|
|
||||||
|
|
||||||
# Test for libpthread by looking for pthread_kill. (Not pthread_self,
|
|
||||||
# since it is defined as a macro on OSF/1.)
|
|
||||||
if test -n "$gl_have_pthread" && test -z "$LIBTHREAD"; then
|
|
||||||
# The program links fine without libpthread. But it may actually
|
|
||||||
# need to link with libpthread in order to create multiple threads.
|
|
||||||
AC_CHECK_LIB([pthread], [pthread_kill],
|
|
||||||
[LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
|
|
||||||
# On Solaris and HP-UX, most pthread functions exist also in libc.
|
|
||||||
# Therefore pthread_in_use() needs to actually try to create a
|
|
||||||
# thread: pthread_create from libc will fail, whereas
|
|
||||||
# pthread_create will actually create a thread.
|
|
||||||
# On Solaris 10 or newer, this test is no longer needed, because
|
|
||||||
# libc contains the fully functional pthread functions.
|
|
||||||
case "$host_os" in
|
|
||||||
solaris | solaris2.[1-9] | solaris2.[1-9].* | hpux*)
|
|
||||||
AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
|
|
||||||
[Define if the pthread_in_use() detection is hard.])
|
|
||||||
esac
|
|
||||||
])
|
|
||||||
elif test -z "$gl_have_pthread"; then
|
|
||||||
# Some library is needed. Try libpthread and libc_r.
|
|
||||||
AC_CHECK_LIB([pthread], [pthread_kill],
|
|
||||||
[gl_have_pthread=yes
|
|
||||||
LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
|
|
||||||
LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread])
|
|
||||||
if test -z "$gl_have_pthread"; then
|
|
||||||
# For FreeBSD 4.
|
|
||||||
AC_CHECK_LIB([c_r], [pthread_kill],
|
|
||||||
[gl_have_pthread=yes
|
|
||||||
LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
|
|
||||||
LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test -n "$gl_have_pthread"; then
|
|
||||||
if test "$gl_use_threads" = isoc+posix && test "$gl_have_isoc_threads" = yes; then
|
|
||||||
gl_threads_api='isoc+posix'
|
|
||||||
AC_DEFINE([USE_ISOC_AND_POSIX_THREADS], [1],
|
|
||||||
[Define if the combination of the ISO C and POSIX multithreading APIs can be used.])
|
|
||||||
LIBTHREAD= LTLIBTHREAD=
|
|
||||||
else
|
|
||||||
gl_threads_api=posix
|
|
||||||
AC_DEFINE([USE_POSIX_THREADS], [1],
|
|
||||||
[Define if the POSIX multithreading library can be used.])
|
|
||||||
if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
|
|
||||||
if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
|
|
||||||
AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
|
|
||||||
[Define if references to the POSIX multithreading library should be made weak.])
|
|
||||||
LIBTHREAD= LTLIBTHREAD=
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -317,6 +356,12 @@ int main ()
|
|||||||
AC_SUBST([LTLIBMULTITHREAD])
|
AC_SUBST([LTLIBMULTITHREAD])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([gl_PTHREADLIB],
|
||||||
|
[
|
||||||
|
AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
|
||||||
|
gl_PTHREADLIB_BODY
|
||||||
|
])
|
||||||
|
|
||||||
AC_DEFUN([gl_THREADLIB],
|
AC_DEFUN([gl_THREADLIB],
|
||||||
[
|
[
|
||||||
AC_REQUIRE([gl_THREADLIB_EARLY])
|
AC_REQUIRE([gl_THREADLIB_EARLY])
|
||||||
|
@@ -21,7 +21,7 @@ Include:
|
|||||||
<pthread.h>
|
<pthread.h>
|
||||||
|
|
||||||
Link:
|
Link:
|
||||||
$(LIBMULTITHREAD)
|
$(LIBPMULTITHREAD)
|
||||||
|
|
||||||
License:
|
License:
|
||||||
LGPLv2+
|
LGPLv2+
|
||||||
|
@@ -23,7 +23,7 @@ Include:
|
|||||||
<pthread.h>
|
<pthread.h>
|
||||||
|
|
||||||
Link:
|
Link:
|
||||||
$(LIBMULTITHREAD)
|
$(LIBPMULTITHREAD)
|
||||||
|
|
||||||
License:
|
License:
|
||||||
LGPLv2+
|
LGPLv2+
|
||||||
|
@@ -13,4 +13,4 @@ configure.ac:
|
|||||||
Makefile.am:
|
Makefile.am:
|
||||||
TESTS += test-pthread-cond
|
TESTS += test-pthread-cond
|
||||||
check_PROGRAMS += test-pthread-cond
|
check_PROGRAMS += test-pthread-cond
|
||||||
test_pthread_cond_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@
|
test_pthread_cond_LDADD = $(LDADD) @LIBPMULTITHREAD@ @YIELD_LIB@
|
||||||
|
@@ -4,21 +4,20 @@ A POSIX-like <pthread.h>.
|
|||||||
Files:
|
Files:
|
||||||
lib/pthread.in.h
|
lib/pthread.in.h
|
||||||
m4/pthread_h.m4
|
m4/pthread_h.m4
|
||||||
|
m4/threadlib.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
extensions
|
extensions
|
||||||
extern-inline
|
extern-inline
|
||||||
sched
|
sched
|
||||||
time
|
time
|
||||||
threadlib
|
|
||||||
snippet/c++defs
|
snippet/c++defs
|
||||||
snippet/_Noreturn
|
snippet/_Noreturn
|
||||||
snippet/arg-nonnull
|
snippet/arg-nonnull
|
||||||
snippet/warn-on-use
|
snippet/warn-on-use
|
||||||
|
|
||||||
configure.ac-early:
|
configure.ac-early:
|
||||||
AC_DEFINE([_REENTRANT], 1, [For thread-safety on OSF/1, Solaris.])
|
gl_ANYTHREADLIB_EARLY
|
||||||
AC_DEFINE([_THREAD_SAFE], 1, [For thread-safety on AIX, FreeBSD.])
|
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
gl_PTHREAD_H
|
gl_PTHREAD_H
|
||||||
@@ -166,7 +165,7 @@ Include:
|
|||||||
<pthread.h>
|
<pthread.h>
|
||||||
|
|
||||||
Link:
|
Link:
|
||||||
$(LIBTHREAD)
|
$(LIBPTHREAD)
|
||||||
|
|
||||||
License:
|
License:
|
||||||
LGPLv2+
|
LGPLv2+
|
||||||
|
@@ -15,5 +15,5 @@ if ANSICXX
|
|||||||
TESTS += test-pthread-c++
|
TESTS += test-pthread-c++
|
||||||
check_PROGRAMS += test-pthread-c++
|
check_PROGRAMS += test-pthread-c++
|
||||||
test_pthread_c___SOURCES = test-pthread-c++.cc
|
test_pthread_c___SOURCES = test-pthread-c++.cc
|
||||||
test_pthread_c___LDADD = $(LDADD) $(LIBMULTITHREAD)
|
test_pthread_c___LDADD = $(LDADD) $(LIBPMULTITHREAD)
|
||||||
endif
|
endif
|
||||||
|
@@ -25,7 +25,7 @@ Include:
|
|||||||
<pthread.h>
|
<pthread.h>
|
||||||
|
|
||||||
Link:
|
Link:
|
||||||
$(LIBTHREAD) or $(LIBMULTITHREAD)
|
$(LIBPTHREAD) or $(LIBPMULTITHREAD)
|
||||||
|
|
||||||
License:
|
License:
|
||||||
LGPLv2+
|
LGPLv2+
|
||||||
|
@@ -11,4 +11,4 @@ configure.ac:
|
|||||||
Makefile.am:
|
Makefile.am:
|
||||||
TESTS += test-pthread-mutex
|
TESTS += test-pthread-mutex
|
||||||
check_PROGRAMS += test-pthread-mutex
|
check_PROGRAMS += test-pthread-mutex
|
||||||
test_pthread_mutex_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@
|
test_pthread_mutex_LDADD = $(LDADD) @LIBPMULTITHREAD@ @YIELD_LIB@
|
||||||
|
@@ -22,7 +22,7 @@ Include:
|
|||||||
<pthread.h>
|
<pthread.h>
|
||||||
|
|
||||||
Link:
|
Link:
|
||||||
$(LIBMULTITHREAD)
|
$(LIBPMULTITHREAD)
|
||||||
|
|
||||||
License:
|
License:
|
||||||
LGPLv2+
|
LGPLv2+
|
||||||
|
@@ -13,5 +13,5 @@ configure.ac:
|
|||||||
Makefile.am:
|
Makefile.am:
|
||||||
TESTS += test-pthread-once1 test-pthread-once2
|
TESTS += test-pthread-once1 test-pthread-once2
|
||||||
check_PROGRAMS += test-pthread-once1 test-pthread-once2
|
check_PROGRAMS += test-pthread-once1 test-pthread-once2
|
||||||
test_pthread_once1_LDADD = $(LDADD) @LIBMULTITHREAD@
|
test_pthread_once1_LDADD = $(LDADD) @LIBPMULTITHREAD@
|
||||||
test_pthread_once2_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@
|
test_pthread_once2_LDADD = $(LDADD) @LIBPMULTITHREAD@ @YIELD_LIB@
|
||||||
|
@@ -24,7 +24,7 @@ Include:
|
|||||||
<pthread.h>
|
<pthread.h>
|
||||||
|
|
||||||
Link:
|
Link:
|
||||||
$(LIBTHREAD) or $(LIBMULTITHREAD)
|
$(LIBPTHREAD) or $(LIBPMULTITHREAD)
|
||||||
|
|
||||||
License:
|
License:
|
||||||
LGPLv2+
|
LGPLv2+
|
||||||
|
@@ -12,4 +12,4 @@ configure.ac:
|
|||||||
Makefile.am:
|
Makefile.am:
|
||||||
TESTS += test-pthread-rwlock
|
TESTS += test-pthread-rwlock
|
||||||
check_PROGRAMS += test-pthread-rwlock
|
check_PROGRAMS += test-pthread-rwlock
|
||||||
test_pthread_rwlock_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@
|
test_pthread_rwlock_LDADD = $(LDADD) @LIBPMULTITHREAD@ @YIELD_LIB@
|
||||||
|
@@ -22,7 +22,7 @@ Include:
|
|||||||
<pthread.h>
|
<pthread.h>
|
||||||
|
|
||||||
Link:
|
Link:
|
||||||
$(LIBMULTITHREAD)
|
$(LIBPMULTITHREAD)
|
||||||
|
|
||||||
License:
|
License:
|
||||||
LGPLv2+
|
LGPLv2+
|
||||||
|
@@ -22,7 +22,7 @@ Include:
|
|||||||
<pthread.h>
|
<pthread.h>
|
||||||
|
|
||||||
Link:
|
Link:
|
||||||
$(LIBMULTITHREAD)
|
$(LIBPMULTITHREAD)
|
||||||
|
|
||||||
License:
|
License:
|
||||||
LGPLv2+
|
LGPLv2+
|
||||||
|
@@ -9,4 +9,4 @@ configure.ac:
|
|||||||
Makefile.am:
|
Makefile.am:
|
||||||
TESTS += test-pthread-thread
|
TESTS += test-pthread-thread
|
||||||
check_PROGRAMS += test-pthread-thread
|
check_PROGRAMS += test-pthread-thread
|
||||||
test_pthread_thread_LDADD = $(LDADD) @LIBMULTITHREAD@
|
test_pthread_thread_LDADD = $(LDADD) @LIBPMULTITHREAD@
|
||||||
|
@@ -22,7 +22,7 @@ Include:
|
|||||||
<pthread.h>
|
<pthread.h>
|
||||||
|
|
||||||
Link:
|
Link:
|
||||||
$(LIBMULTITHREAD)
|
$(LIBPMULTITHREAD)
|
||||||
|
|
||||||
License:
|
License:
|
||||||
LGPLv2+
|
LGPLv2+
|
||||||
|
@@ -12,4 +12,4 @@ configure.ac:
|
|||||||
Makefile.am:
|
Makefile.am:
|
||||||
TESTS += test-pthread-tss
|
TESTS += test-pthread-tss
|
||||||
check_PROGRAMS += test-pthread-tss
|
check_PROGRAMS += test-pthread-tss
|
||||||
test_pthread_tss_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@
|
test_pthread_tss_LDADD = $(LDADD) @LIBPMULTITHREAD@ @YIELD_LIB@
|
||||||
|
Reference in New Issue
Block a user