update gnulib to 47bf2cf3184027c1eb9c1dfeea5c5b8b2d69710d

* lib/dosname.h, lib/glthread/lock.c, lib/glthread/lock.h,
lib/glthread/threadlib.c, lib/windows-mutex.c, lib/windows-mutex.h,
lib/windows-once.c, lib/windows-once.h, lib/windows-recmutex.c,
lib/windows-recmutex.h, lib/windows-rwlock.c, lib/windows-rwlock.h,
m4/host-cpu-c-abi.m4, m4/lib-ld.m4, m4/lib-link.m4, m4/lib-prefix.m4,
m4/lock.m4, m4/longlong.m4, m4/pthread_rwlock_rdlock.m4,
tools/config.rpath: Delete.
* lib/alloca.in.h, lib/argmatch.c, lib/argmatch.h, lib/arg-nonnull.h,
lib/argp-ba.c, lib/argp-eexst.c, lib/argp-fmtstream.c,
lib/argp-fmtstream.h, lib/argp-fs-xinl.c, lib/argp.h, lib/argp-help.c,
lib/argp-namefrob.h, lib/argp-parse.c, lib/argp-pin.c, lib/argp-pv.c,
lib/argp-pvh.c, lib/argp-xinl.c, lib/asnprintf.c, lib/basename-lgpl.c,
lib/c-ctype.h, lib/c++defs.h, lib/cdefs.h, lib/closeout.c,
lib/closeout.h, lib/close-stream.c, lib/c-strcasecmp.c,
lib/c-strcaseeq.h, lib/c-strcase.h, lib/c-strncasecmp.c,
lib/dirname.h, lib/dirname-lgpl.c, lib/errno.in.h, lib/error.c,
lib/error.h, lib/exitfail.c, lib/exitfail.h, lib/fcntl.in.h,
lib/filename.h, lib/float.c, lib/float+.h, lib/float.in.h,
lib/fpending.c, lib/fpending.h, lib/getopt1.c, lib/getopt.c,
lib/getopt-cdefs.in.h, lib/getopt-core.h, lib/getopt-ext.h,
lib/getopt.in.h, lib/getopt_int.h, lib/getopt-pfx-core.h,
lib/getopt-pfx-ext.h, lib/getprogname.c, lib/getprogname.h,
lib/gettext.h, lib/gettimeofday.c, lib/hard-locale.c,
lib/hard-locale.h, lib/intprops.h, lib/isatty.c, lib/itold.c,
lib/libc-config.h, lib/limits.in.h, lib/localcharset.c,
lib/localcharset.h, lib/localtime-buffer.c, lib/localtime-buffer.h,
lib/lstat.c, lib/Makefile.am, lib/malloca.c, lib/malloca.h,
lib/malloc.c, lib/mbrtowc.c, lib/mbsinit.c, lib/memchr.c,
lib/memchr.valgrind, lib/mempcpy.c, lib/minmax.h, lib/mkdir.c,
lib/mkstemp.c, lib/mkstemps.c, lib/msvc-inval.c, lib/msvc-inval.h,
lib/msvc-nothrow.c, lib/msvc-nothrow.h, lib/_Noreturn.h,
lib/pathmax.h, lib/printf-args.c, lib/printf-args.h,
lib/printf-parse.c, lib/printf-parse.h, lib/progname.c,
lib/progname.h, lib/quotearg.c, lib/quotearg.h, lib/quote.h,
lib/rawmemchr.c, lib/rawmemchr.valgrind, lib/secure_getenv.c,
lib/size_max.h, lib/sleep.c, lib/stat.c, lib/stat-time.h,
lib/stat-w32.c, lib/stat-w32.h, lib/stdalign.in.h, lib/stdbool.in.h,
lib/stddef.in.h, lib/stdint.in.h, lib/stdio-impl.h, lib/stdio.in.h,
lib/stdlib.in.h, lib/stpcpy.c, lib/strcasecmp.c, lib/strchrnul.c,
lib/strchrnul.valgrind, lib/streq.h, lib/strerror.c,
lib/strerror-override.c, lib/strerror-override.h, lib/string.in.h,
lib/strings.in.h, lib/stripslash.c, lib/strncasecmp.c, lib/strndup.c,
lib/strnlen.c, lib/strverscmp.c, lib/sysexits.in.h, lib/sys_stat.in.h,
lib/sys_time.in.h, lib/sys_types.in.h, lib/sys_wait.in.h,
lib/tempname.c, lib/tempname.h, lib/time.in.h, lib/unistd.in.h,
lib/vasnprintf.c, lib/vasnprintf.h, lib/verify.h, lib/vsnprintf.c,
lib/warn-on-use.h, lib/wchar.in.h, lib/wctype.in.h,
lib/windows-initguard.h, lib/xalloc-die.c, lib/xalloc.h,
lib/xalloc-oversized.h, lib/xmalloc.c, lib/xsize.h, m4/00gnulib.m4,
m4/absolute-header.m4, m4/alloca.m4, m4/argp.m4, m4/codeset.m4,
m4/dirname.m4, m4/double-slash-root.m4, m4/eealloc.m4, m4/errno_h.m4,
m4/error.m4, m4/exponentd.m4, m4/extensions.m4, m4/extern-inline.m4,
m4/fcntl_h.m4, m4/fcntl-o.m4, m4/float_h.m4, m4/fpending.m4,
m4/getopt.m4, m4/getprogname.m4, m4/gettimeofday.m4,
m4/gnulib-cache.m4, m4/gnulib-common.m4, m4/gnulib-comp.m4,
m4/gnulib-tool.m4, m4/include_next.m4, m4/__inline.m4, m4/intmax_t.m4,
m4/inttypes_h.m4, m4/isatty.m4, m4/largefile.m4, m4/limits-h.m4,
m4/localcharset.m4, m4/locale-fr.m4, m4/locale-ja.m4, m4/locale-zh.m4,
m4/localtime-buffer.m4, m4/lstat.m4, m4/malloca.m4, m4/malloc.m4,
m4/math_h.m4, m4/mbrtowc.m4, m4/mbsinit.m4, m4/mbstate_t.m4,
m4/memchr.m4, m4/mempcpy.m4, m4/minmax.m4, m4/mkdir.m4, m4/mkstemp.m4,
m4/mkstemps.m4, m4/mmap-anon.m4, m4/msvc-inval.m4, m4/msvc-nothrow.m4,
m4/multiarch.m4, m4/nocrash.m4, m4/off_t.m4, m4/pathmax.m4,
m4/printf.m4, m4/quotearg.m4, m4/quote.m4, m4/rawmemchr.m4,
m4/secure_getenv.m4, m4/size_max.m4, m4/sleep.m4, m4/ssize_t.m4,
m4/stat.m4, m4/stat-time.m4, m4/stdalign.m4, m4/stdbool.m4,
m4/stddef_h.m4, m4/std-gnu11.m4, m4/stdint_h.m4, m4/stdint.m4,
m4/stdio_h.m4, m4/stdlib_h.m4, m4/stpcpy.m4, m4/strcase.m4,
m4/strchrnul.m4, m4/strerror.m4, m4/string_h.m4, m4/strings_h.m4,
m4/strndup.m4, m4/strnlen.m4, m4/strverscmp.m4, m4/sysexits.m4,
m4/sys_socket_h.m4, m4/sys_stat_h.m4, m4/sys_time_h.m4,
m4/sys_types_h.m4, m4/sys_wait_h.m4, m4/tempname.m4, m4/threadlib.m4,
m4/time_h.m4, m4/unistd_h.m4, m4/vasnprintf.m4, m4/vsnprintf.m4,
m4/warn-on-use.m4, m4/wchar_h.m4, m4/wchar_t.m4, m4/wctype_h.m4,
m4/wint_t.m4, m4/xalloc.m4, m4/xsize.m4: Update.
* lib/inttypes.in.h, lib/lc-charset-dispatch.c,
lib/lc-charset-dispatch.h, lib/locale.in.h, lib/mbrtowc-impl.h,
lib/mbrtowc-impl-utf8.h, lib/mbtowc-lock.c, lib/mbtowc-lock.h,
lib/setlocale-lock.c, lib/setlocale_null.c, lib/setlocale_null.h,
m4/inttypes.m4, m4/locale_h.m4, m4/setlocale_null.m4,
m4/visibility.m4, m4/zzgnulib.m4: New files.
This commit is contained in:
Alexandre Duret-Lutz 2020-04-16 10:47:14 +02:00
parent fe642bc9ad
commit 1e86463205
287 changed files with 6133 additions and 6812 deletions

View file

@ -1,5 +1,5 @@
# threadlib.m4 serial 20
dnl Copyright (C) 2005-2019 Free Software Foundation, Inc.
# threadlib.m4 serial 27
dnl Copyright (C) 2005-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@ -8,6 +8,344 @@ dnl From Bruno Haible.
AC_PREREQ([2.60])
dnl The general structure of the multithreading modules in gnulib is that we
dnl have three set of modules:
dnl
dnl * POSIX API:
dnl pthread, which combines
dnl pthread-h
dnl pthread-thread
dnl pthread-once
dnl pthread-mutex
dnl pthread-rwlock
dnl pthread-cond
dnl pthread-tss
dnl pthread-spin
dnl sched_yield
dnl
dnl * ISO C API:
dnl threads, which combines
dnl threads-h
dnl thrd
dnl mtx
dnl cnd
dnl tss
dnl
dnl * Gnulib API, with an implementation that can be chosen at configure
dnl time through the option --enable-threads=...
dnl thread
dnl lock
dnl cond
dnl tls
dnl yield
dnl
dnl They are independent, except for the fact that
dnl - the implementation of the ISO C API may use the POSIX (or some other
dnl platform dependent) API,
dnl - the implementation of the Gnulib API may use the POSIX or ISO C or
dnl some other platform dependent API, depending on the --enable-threads
dnl option.
dnl
dnl This file contains macros for all of these APIs!
dnl ============================================================================
dnl Macros for all thread APIs
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
])
dnl Checks whether the compiler and linker support weak declarations of symbols.
AC_DEFUN([gl_WEAK_SYMBOLS],
[
AC_REQUIRE([AC_CANONICAL_HOST])
AC_CACHE_CHECK([whether imported symbols can be declared weak],
[gl_cv_have_weak],
[gl_cv_have_weak=no
dnl First, test whether the compiler accepts it syntactically.
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[extern void xyzzy ();
#pragma weak xyzzy]],
[[xyzzy();]])],
[gl_cv_have_weak=maybe])
if test $gl_cv_have_weak = maybe; then
dnl Second, test whether it actually works. On Cygwin 1.7.2, with
dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
#include <stdio.h>
#pragma weak fputs
int main ()
{
return (fputs == NULL);
}]])],
[gl_cv_have_weak=yes],
[gl_cv_have_weak=no],
[dnl When cross-compiling, assume that only ELF platforms support
dnl weak symbols.
AC_EGREP_CPP([Extensible Linking Format],
[#ifdef __ELF__
Extensible Linking Format
#endif
],
[gl_cv_have_weak="guessing yes"],
[gl_cv_have_weak="guessing no"])
])
fi
dnl But when linking statically, weak symbols don't work.
case " $LDFLAGS " in
*" -static "*) gl_cv_have_weak=no ;;
esac
dnl Test for a bug in FreeBSD 11: A link error occurs when using a weak
dnl symbol and linking against a shared library that has a dependency on
dnl the shared library that defines the symbol.
case "$gl_cv_have_weak" in
*yes)
case "$host_os" in
freebsd* | dragonfly*)
: > conftest1.c
$CC $CPPFLAGS $CFLAGS $LDFLAGS -fPIC -shared -o libempty.so conftest1.c -lpthread >&AS_MESSAGE_LOG_FD 2>&1
cat <<EOF > conftest2.c
#include <pthread.h>
#pragma weak pthread_mutexattr_gettype
int main ()
{
return (pthread_mutexattr_gettype != NULL);
}
EOF
$CC $CPPFLAGS $CFLAGS $LDFLAGS -o conftest conftest2.c libempty.so >&AS_MESSAGE_LOG_FD 2>&1 \
|| gl_cv_have_weak=no
rm -f conftest1.c libempty.so conftest2.c conftest
;;
esac
;;
esac
])
case "$gl_cv_have_weak" in
*yes)
AC_DEFINE([HAVE_WEAK_SYMBOLS], [1],
[Define to 1 if the compiler and linker support weak declarations of symbols.])
;;
esac
])
dnl ============================================================================
dnl Macros for the POSIX API
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 Sets the variable LIB_SCHED_YIELD to the linker options needed to use the
dnl sched_yield() function.
dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
dnl multithread-safe programs.
dnl Defines the C macro HAVE_PTHREAD_API if (at least parts of) the POSIX
dnl threads API is available.
dnl The guts of gl_PTHREADLIB. Needs to be expanded only once.
AC_DEFUN([gl_PTHREADLIB_BODY],
[
AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
if test -z "$gl_pthreadlib_body_done"; then
gl_pthread_api=no
LIBPTHREAD=
LIBPMULTITHREAD=
# On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
# it groks <pthread.h>. It's added above, in gl_ANYTHREADLIB_EARLY.
AC_CHECK_HEADER([pthread.h],
[gl_have_pthread_h=yes], [gl_have_pthread_h=no])
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])
if test $gl_pthread_api = yes; then
AC_DEFINE([HAVE_PTHREAD_API], [1],
[Define if you have the <pthread.h> header and the POSIX threads API.])
fi
dnl On some systems, sched_yield is in librt, rather than in libpthread.
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <sched.h>]],
[[sched_yield ();]])],
[LIB_SCHED_YIELD=
],
[dnl Solaris 7...10 has sched_yield in librt, not in libpthread or libc.
AC_CHECK_LIB([rt], [sched_yield], [LIB_SCHED_YIELD=-lrt],
[dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt.
AC_CHECK_LIB([posix4], [sched_yield], [LIB_SCHED_YIELD=-lposix4])])
])
AC_SUBST([LIB_SCHED_YIELD])
gl_pthreadlib_body_done=done
fi
])
AC_DEFUN([gl_PTHREADLIB],
[
AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
gl_PTHREADLIB_BODY
])
dnl ============================================================================
dnl Macros for the ISO C API
dnl gl_STDTHREADLIB
dnl ---------------
dnl Tests for the libraries needs for using the ISO C threads API.
dnl Sets the variable LIBSTDTHREAD to the linker options for use in a Makefile.
dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
dnl multithread-safe programs.
dnl Defines the C macro HAVE_THREADS_H if (at least parts of) the ISO C threads
dnl API is available.
dnl The guts of gl_STDTHREADLIB. Needs to be expanded only once.
AC_DEFUN([gl_STDTHREADLIB_BODY],
[
AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
AC_REQUIRE([AC_CANONICAL_HOST])
if test -z "$gl_stdthreadlib_body_done"; then
AC_CHECK_HEADERS_ONCE([threads.h])
case "$host_os" in
mingw*)
LIBSTDTHREAD=
;;
*)
gl_PTHREADLIB_BODY
if test $ac_cv_header_threads_h = yes; then
dnl glibc >= 2.29 has thrd_create in libpthread.
dnl FreeBSD >= 10 has thrd_create in libstdthreads; this library depends
dnl on libpthread (for the symbol 'pthread_mutexattr_gettype').
dnl AIX >= 7.1 and Solaris >= 11.4 have thrd_create in libc.
AC_CHECK_FUNCS([thrd_create])
if test $ac_cv_func_thrd_create = yes; then
LIBSTDTHREAD=
else
AC_CHECK_LIB([stdthreads], [thrd_create], [
LIBSTDTHREAD='-lstdthreads -lpthread'
], [
dnl Guess that thrd_create is in libpthread.
LIBSTDTHREAD="$LIBPMULTITHREAD"
])
fi
else
dnl Libraries needed by thrd.c, mtx.c, cnd.c, tss.c.
LIBSTDTHREAD="$LIBPMULTITHREAD $LIB_SCHED_YIELD"
fi
;;
esac
AC_SUBST([LIBSTDTHREAD])
AC_MSG_CHECKING([whether ISO C threads API is available])
AC_MSG_RESULT([$ac_cv_header_threads_h])
gl_stdthreadlib_body_done=done
fi
])
AC_DEFUN([gl_STDTHREADLIB],
[
AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
gl_STDTHREADLIB_BODY
])
dnl ============================================================================
dnl Macros for the Gnulib API
dnl gl_THREADLIB
dnl ------------
dnl Tests for a multithreading library to be used.
@ -16,7 +354,13 @@ dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the
dnl default is 'no', otherwise it is system dependent. In both cases, the user
dnl can change the choice through the options --enable-threads=choice or
dnl --disable-threads.
dnl Defines at most one of the macros USE_POSIX_THREADS, USE_WINDOWS_THREADS.
dnl Defines at most one of the macros USE_ISOC_THREADS, USE_POSIX_THREADS,
dnl USE_ISOC_AND_POSIX_THREADS, USE_WINDOWS_THREADS.
dnl The choice --enable-threads=isoc+posix is available only on platforms that
dnl have both the ISO C and the POSIX threads APIs. It has the effect of using
dnl the ISO C API for most things and the POSIX API only for creating and
dnl controlling threads (because there is no equivalent to pthread_atfork in
dnl the ISO C API).
dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
dnl libtool).
@ -54,7 +398,7 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY],
[m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=])
AC_ARG_ENABLE([threads],
AC_HELP_STRING([--enable-threads={posix|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
AC_HELP_STRING([--enable-threads={isoc|posix|isoc+posix|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
AC_HELP_STRING([--disable-threads], [build without multithread safety])]),
[gl_use_threads=$enableval],
[if test -n "$gl_use_threads_default"; then
@ -88,26 +432,12 @@ changequote(,)dnl
changequote([,])dnl
fi
])
if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
# For using <pthread.h>:
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
if test "$gl_use_threads" = yes \
|| test "$gl_use_threads" = isoc \
|| test "$gl_use_threads" = posix \
|| test "$gl_use_threads" = isoc+posix; then
# For using <threads.h> or <pthread.h>:
gl_ANYTHREADLIB_EARLY
fi
])
@ -123,45 +453,7 @@ AC_DEFUN([gl_THREADLIB_BODY],
LTLIBMULTITHREAD=
if test "$gl_use_threads" != no; then
dnl Check whether the compiler and linker support weak declarations.
AC_CACHE_CHECK([whether imported symbols can be declared weak],
[gl_cv_have_weak],
[gl_cv_have_weak=no
dnl First, test whether the compiler accepts it syntactically.
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[extern void xyzzy ();
#pragma weak xyzzy]],
[[xyzzy();]])],
[gl_cv_have_weak=maybe])
if test $gl_cv_have_weak = maybe; then
dnl Second, test whether it actually works. On Cygwin 1.7.2, with
dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
#include <stdio.h>
#pragma weak fputs
int main ()
{
return (fputs == NULL);
}]])],
[gl_cv_have_weak=yes],
[gl_cv_have_weak=no],
[dnl When cross-compiling, assume that only ELF platforms support
dnl weak symbols.
AC_EGREP_CPP([Extensible Linking Format],
[#ifdef __ELF__
Extensible Linking Format
#endif
],
[gl_cv_have_weak="guessing yes"],
[gl_cv_have_weak="guessing no"])
])
fi
dnl But when linking statically, weak symbols don't work.
case " $LDFLAGS " in
*" -static "*) gl_cv_have_weak=no ;;
esac
])
gl_WEAK_SYMBOLS
if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
dnl If we use weak symbols to implement pthread_in_use / pth_in_use /
dnl thread_in_use, we also need to test whether the ISO C 11 thrd_create
@ -169,75 +461,23 @@ int main ()
AC_CHECK_HEADERS_ONCE([threads.h])
:
fi
if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
# On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
# it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
AC_CHECK_HEADER([pthread.h],
[gl_have_pthread_h=yes], [gl_have_pthread_h=no])
if test "$gl_have_pthread_h" = yes; then
# Other possible tests:
# -lpthreads (FSU threads, PCthreads)
# -lgthreads
gl_have_pthread=
# 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_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 || test "$gl_use_threads" = isoc+posix; then
AC_CHECK_HEADERS_ONCE([threads.h])
gl_have_isoc_threads="$ac_cv_header_threads_h"
fi
if test "$gl_use_threads" = yes \
|| test "$gl_use_threads" = posix \
|| test "$gl_use_threads" = isoc+posix; then
gl_PTHREADLIB_BODY
LIBTHREAD=$LIBPTHREAD LTLIBTHREAD=$LIBPTHREAD
LIBMULTITHREAD=$LIBPMULTITHREAD LTLIBMULTITHREAD=$LIBPMULTITHREAD
if test $gl_pthread_api = yes; 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.])
@ -245,14 +485,23 @@ int main ()
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=
LIBTHREAD= LTLIBTHREAD=
fi
fi
fi
fi
fi
if test -z "$gl_have_pthread"; then
if test $gl_threads_api = none; then
if test "$gl_use_threads" = isoc && test "$gl_have_isoc_threads" = yes; then
gl_STDTHREADLIB_BODY
LIBTHREAD=$LIBSTDTHREAD LTLIBTHREAD=$LIBSTDTHREAD
LIBMULTITHREAD=$LIBSTDTHREAD LTLIBMULTITHREAD=$LIBSTDTHREAD
gl_threads_api=isoc
AC_DEFINE([USE_ISOC_THREADS], [1],
[Define if the ISO C multithreading library can be used.])
fi
fi
if test $gl_threads_api = none; then
case "$gl_use_threads" in
yes | windows | win32) # The 'win32' is for backward compatibility.
if { case "$host_os" in
@ -306,6 +555,9 @@ AC_DEFUN([gl_AVOID_WINPTHREAD], [
])
dnl ============================================================================
dnl Survey of platforms:
dnl
dnl Platform Available Compiler Supports test-lock