diff options
Diffstat (limited to 'gnulib-m4/threadlib.m4')
-rw-r--r-- | gnulib-m4/threadlib.m4 | 403 |
1 files changed, 190 insertions, 213 deletions
diff --git a/gnulib-m4/threadlib.m4 b/gnulib-m4/threadlib.m4 index f5e81479..a93aa5c1 100644 --- a/gnulib-m4/threadlib.m4 +++ b/gnulib-m4/threadlib.m4 @@ -1,9 +1,10 @@ # threadlib.m4 -# serial 42 -dnl Copyright (C) 2005-2024 Free Software Foundation, Inc. +# serial 49 +dnl Copyright (C) 2005-2025 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. +dnl This file is offered as-is, without any warranty. dnl From Bruno Haible. @@ -56,24 +57,12 @@ 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 + # definition of errno in <errno.h>. + AS_CASE([$host_os], + [aix* | freebsd*], [CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"], + [hpux* | solaris*], [CPPFLAGS="$CPPFLAGS -D_REENTRANT"]) gl_anythreadlib_early_done=done fi ]) @@ -85,24 +74,26 @@ AC_DEFUN([gl_WEAK_SYMBOLS], AC_REQUIRE([AC_CANONICAL_HOST]) AC_CACHE_CHECK([whether imported symbols can be declared weak], [gl_cv_have_weak], - [case "$host_os" in - cygwin* | mingw* | windows*) + [AS_CASE([$host_os], + [cygwin* | mingw* | windows*], + [ dnl On Cygwin 3.2.0 with gcc 10.2, and likewise on mingw 10.0.0 with dnl gcc 11.3, the test below would succeed, but programs that use dnl pthread_in_use() with weak symbol references crash miserably at dnl runtime. gl_cv_have_weak="guessing no" - ;; - *) + ], + [ 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]], +#pragma weak xyzzy + ]], [[xyzzy();]])], [gl_cv_have_weak=maybe]) - if test $gl_cv_have_weak = maybe; then + AS_IF([test $gl_cv_have_weak = maybe], [ 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( @@ -125,20 +116,19 @@ int main () [gl_cv_have_weak="guessing yes"], [gl_cv_have_weak="guessing no"]) ]) - fi - ;; - esac - dnl But when linking statically, weak symbols don't work. - case " $LDFLAGS " in - *" -static "*) gl_cv_have_weak=no ;; - esac + ]) + ]) + dnl But when linking statically, weak symbols do not work. + AS_CASE([" $LDFLAGS "], + [*" -static "*], [gl_cv_have_weak=no]) 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* | midnightbsd*) + AS_CASE([$gl_cv_have_weak], + [*yes], + [AS_CASE([$host_os], + [freebsd* | dragonfly* | midnightbsd*], + [ : > conftest1.c $CC $CPPFLAGS $CFLAGS $LDFLAGS -fPIC -shared -o libempty.so conftest1.c -lpthread >&AS_MESSAGE_LOG_FD 2>&1 cat <<EOF > conftest2.c @@ -152,17 +142,15 @@ 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) + AS_CASE([$gl_cv_have_weak], + [*yes], + [ AC_DEFINE([HAVE_WEAK_SYMBOLS], [1], [Define to 1 if the compiler and linker support weak declarations of symbols.]) - ;; - esac + ]) ]) dnl ============================================================================ @@ -188,36 +176,30 @@ 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 + AS_IF([test -z "$gl_pthreadlib_body_done"], [ 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 + AS_IF([test "$gl_have_pthread_h" = yes], [ # 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. + # Test whether both pthread_mutex_lock exists in libc. # # 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 saved_LIBS="$LIBS" - for gl_pthread in '' '-pthread'; do + 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);]])], + [[pthread_mutex_lock (&m);]])], [gl_pthread_api=yes LIBPTHREAD=$gl_pthread LIBPMULTITHREAD=$gl_pthread]) @@ -230,8 +212,9 @@ AC_DEFUN([gl_PTHREADLIB_BODY], gl_pthread_in_glibc=no # On Linux with glibc >= 2.34, libc contains the fully functional # pthread functions. - case "$host_os" in - linux*) + AS_CASE([$host_os], + [linux*], + [ AC_EGREP_CPP([Lucky user], [#include <features.h> #ifdef __GNU_LIBRARY__ @@ -242,19 +225,17 @@ AC_DEFUN([gl_PTHREADLIB_BODY], ], [gl_pthread_in_glibc=yes], []) - ;; - esac + ]) echo "$as_me:__oline__: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&AS_MESSAGE_LOG_FD - # 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 + # Test for libpthread by looking for pthread_kill. + AS_IF([test $gl_pthread_api = yes && test -z "$LIBPTHREAD"], [ # 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], - [if test $gl_pthread_in_glibc = yes; then + [AS_IF([test $gl_pthread_in_glibc = yes], [ LIBPMULTITHREAD= - else + ], [ 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 @@ -262,14 +243,13 @@ AC_DEFUN([gl_PTHREADLIB_BODY], # 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 -changequote(,)dnl - solaris | solaris2.[1-9] | solaris2.[1-9].* | hpux*) -changequote([,])dnl - AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], - [Define if the pthread_in_use() detection is hard.]) - esac - fi + AS_CASE([$host_os], + [[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.]) + ]) + ]) ], [dnl This is needed on FreeBSD 5.2.1. AC_CHECK_LIB([thr], [pthread_kill], @@ -280,35 +260,36 @@ changequote([,])dnl fi ]) ]) - elif test $gl_pthread_api != yes; then + ], [test $gl_pthread_api != yes], [ # 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 + AS_IF([test $gl_pthread_api != yes], [ # For FreeBSD 4. AC_CHECK_LIB([c_r], [pthread_kill], [gl_pthread_api=yes LIBPTHREAD=-lc_r LIBPMULTITHREAD=-lc_r]) - fi - fi + ]) + ]) echo "$as_me:__oline__: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&AS_MESSAGE_LOG_FD - 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 + AS_IF([test $gl_pthread_api = yes], [ 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>]], + [[#include <sched.h> + ]], [[sched_yield ();]])], [SCHED_YIELD_LIB= ], @@ -323,7 +304,7 @@ changequote([,])dnl AC_SUBST([LIB_SCHED_YIELD]) gl_pthreadlib_body_done=done - fi + ]) ]) AC_DEFUN([gl_PTHREADLIB], @@ -350,44 +331,45 @@ AC_DEFUN([gl_STDTHREADLIB_BODY], [ AC_REQUIRE([gl_ANYTHREADLIB_EARLY]) AC_REQUIRE([AC_CANONICAL_HOST]) - if test -z "$gl_stdthreadlib_body_done"; then + AS_IF([test -z "$gl_stdthreadlib_body_done"], [ AC_CHECK_HEADERS_ONCE([threads.h]) - case "$host_os" in - mingw* | windows*) + AS_CASE([$host_os], + [mingw* | windows*], + [ LIBSTDTHREAD= - ;; - *) + ], + [ gl_PTHREADLIB_BODY - if test $ac_cv_header_threads_h = yes; then + AS_IF([test $ac_cv_header_threads_h = yes], [ 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 on libpthread (for the symbol pthread_mutexattr_gettype). dnl glibc >= 2.34, AIX >= 7.1, and Solaris >= 11.4 have thrd_create in dnl libc. - gl_CHECK_FUNCS_ANDROID([thrd_create], [[#include <threads.h>]]) - if test $ac_cv_func_thrd_create = yes; then + gl_CHECK_FUNCS_ANDROID([thrd_create], [[#include <threads.h> + ]]) + AS_IF([test $ac_cv_func_thrd_create = yes], [ LIBSTDTHREAD= - else + ], [ AC_CHECK_LIB([stdthreads], [thrd_create], [ - LIBSTDTHREAD='-lstdthreads -lpthread' + 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 $SCHED_YIELD_LIB" - 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], @@ -404,7 +386,7 @@ dnl ------------ dnl Tests for a multithreading library to be used. dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO 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 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_ISOC_THREADS, USE_POSIX_THREADS, @@ -449,51 +431,46 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY], m4_ifdef([gl_THREADLIB_DEFAULT_NO], [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) - dnl gl_use_winpthreads_default defaults to 'no', because in mingw 10, like + dnl gl_use_winpthreads_default defaults to "no", because in mingw 10, like dnl in mingw 5, the use of libwinpthread still makes test-pthread-tss crash. m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=no]) + dnl Don't display the --disable-threads option + dnl - if the package builds one or more libraries, because libraries must + dnl always be multithread-safe (as far as possible), + dnl - if the package defines gl_THREADLIB_DEFAULT_NO, because the option + dnl would then be a no-op. AC_ARG_ENABLE([threads], -AS_HELP_STRING([[--enable-threads={isoc|posix|isoc+posix|windows}]], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ -AS_HELP_STRING([[--disable-threads]], [build without multithread safety])]), +AS_HELP_STRING([[--enable-threads={isoc|posix|isoc+posix|windows}]], [specify multithreading API])m4_ifdef([LT_INIT], [], [m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ +AS_HELP_STRING([[--disable-threads]], [build without multithread safety])])]), [gl_use_threads=$enableval], [if test -n "$gl_use_threads_default"; then gl_use_threads="$gl_use_threads_default" else -changequote(,)dnl - case "$host_os" in - dnl Disable multithreading by default on OSF/1, because it interferes - dnl with fork()/exec(): When msgexec is linked with -lpthread, its - dnl child process gets an endless segmentation fault inside execvp(). - osf*) gl_use_threads=no ;; + AS_CASE([$host_os], dnl Disable multithreading by default on Cygwin 1.5.x, because it has dnl bugs that lead to endless loops or crashes. See dnl <https://cygwin.com/ml/cygwin/2009-08/msg00283.html>. - cygwin*) - case `uname -r` in - 1.[0-5].*) gl_use_threads=no ;; - *) gl_use_threads=yes ;; - esac - ;; + [cygwin*], + [AS_CASE([$(uname -r)], + [[1.[0-5].*]], [gl_use_threads=no], + [gl_use_threads=yes]) + ], dnl Obey gl_AVOID_WINPTHREAD on mingw. - mingw* | windows*) - case "$gl_use_winpthreads_default" in - yes) gl_use_threads=posix ;; - no) gl_use_threads=windows ;; - *) gl_use_threads=yes ;; - esac - ;; - *) gl_use_threads=yes ;; - esac -changequote([,])dnl + [mingw* | windows*], + [AS_CASE([$gl_use_winpthreads_default], + [yes], [gl_use_threads=posix], + [no], [gl_use_threads=windows], + [gl_use_threads=yes]) + ], + [gl_use_threads=yes]) fi ]) - 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 + AS_CASE([$gl_use_threads], + [yes | isoc | posix | isoc+posix], + [ + # For using <threads.h> or <pthread.h>: + gl_ANYTHREADLIB_EARLY + ]) ]) dnl The guts of gl_THREADLIB. Needs to be expanded only once. @@ -506,90 +483,95 @@ AC_DEFUN([gl_THREADLIB_BODY], LTLIBTHREAD= LIBMULTITHREAD= LTLIBMULTITHREAD= - if test "$gl_use_threads" != no; then + AS_IF([test "$gl_use_threads" = no], + [AC_DEFINE([AVOID_ANY_THREADS], [1], + [Define if no multithread safety and no multithreading is desired.])], + [ dnl Check whether the compiler and linker support weak declarations. 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 - dnl facility is in use. - AC_CHECK_HEADERS_ONCE([threads.h]) - : - fi - 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.]) - if test -z "$LIBMULTITHREAD" && test -z "$LTLIBMULTITHREAD"; then - AC_DEFINE([USE_POSIX_THREADS_FROM_LIBC], [1], - [Define if references to the POSIX multithreading library are satisfied by libc.]) - else - 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= - else - case "$host_os" in - freebsd* | dragonfly* | midnightbsd*) - if test "x$LIBTHREAD" != "x$LIBMULTITHREAD"; then - dnl If weak symbols can't tell whether pthread_create(), pthread_key_create() - dnl etc. will succeed, we need a runtime test. - AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], - [Define if the pthread_in_use() detection is hard.]) - fi - ;; - esac - fi - fi - fi - fi - fi - if test $gl_threads_api = none; then - if test "$gl_use_threads" = isoc && test "$gl_have_isoc_threads" = yes; then + AS_CASE([$gl_cv_have_weak], + [*yes], + [ + 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 + dnl facility is in use. + AC_CHECK_HEADERS_ONCE([threads.h]) + : + ]) + AS_CASE([$gl_use_threads], + [isoc | isoc+posix], + [ + AC_CHECK_HEADERS_ONCE([threads.h]) + gl_have_isoc_threads="$ac_cv_header_threads_h" + ]) + AS_CASE([$gl_use_threads], + [yes | posix | isoc+posix], + [ + gl_PTHREADLIB_BODY + LIBTHREAD=$LIBPTHREAD LTLIBTHREAD=$LIBPTHREAD + LIBMULTITHREAD=$LIBPMULTITHREAD LTLIBMULTITHREAD=$LIBPMULTITHREAD + AS_IF([test $gl_pthread_api = yes], [ + AS_IF([test "$gl_use_threads" = isoc+posix && + test "$gl_have_isoc_threads" = yes], [ + 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= + ], [ + gl_threads_api=posix + AC_DEFINE([USE_POSIX_THREADS], [1], + [Define if the POSIX multithreading library can be used.]) + AS_IF([test -z "$LIBMULTITHREAD" && test -z "$LTLIBMULTITHREAD"], [ + AC_DEFINE([USE_POSIX_THREADS_FROM_LIBC], [1], + [Define if references to the POSIX multithreading library are satisfied by libc.]) + ], [ + AS_CASE([$gl_cv_have_weak], + [*yes], + [ + AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], + [Define if references to the POSIX multithreading library should be made weak.]) + LIBTHREAD= LTLIBTHREAD= + ], + [AS_CASE([$host_os], + [freebsd* | dragonfly* | midnightbsd*], + [ + AS_IF([test "x$LIBTHREAD" != "x$LIBMULTITHREAD"], [ + dnl If weak symbols cannot tell whether + dnl pthread_create(), dnl pthread_key_create() + dnl etc. will succeed, we need a runtime test. + AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], + [Define if the pthread_in_use() detection is hard.]) + ]) + ]) + ]) + ]) + ]) + ]) + ]) + AS_IF([test $gl_threads_api = none], [ + AS_IF([test "$gl_use_threads" = isoc && test "$gl_have_isoc_threads" = yes], [ 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 - mingw* | windows*) true;; - *) false;; - esac - }; then - gl_threads_api=windows - AC_DEFINE([USE_WINDOWS_THREADS], [1], - [Define if the native Windows multithreading API can be used.]) - fi - ;; - esac - fi - else - dnl "$gl_use_threads" is "no". - AC_DEFINE([AVOID_ANY_THREADS], [1], - [Define if no multithread safety and no multithreading is desired.]) - fi + ]) + ]) + AS_IF([test $gl_threads_api = none], [ + # The "win32" is for backward compatibility. + AS_CASE([$gl_use_threads], + [yes | windows | win32], + [AS_CASE([$host_os], + [mingw* | windows*], + [ + gl_threads_api=windows + AC_DEFINE([USE_WINDOWS_THREADS], [1], + [Define if the native Windows multithreading API can be used.]) + ]) + ]) + ]) + ]) AC_MSG_CHECKING([for multithread API to use]) AC_MSG_RESULT([$gl_threads_api]) AC_SUBST([LIBTHREAD]) @@ -609,7 +591,7 @@ dnl gl_DISABLE_THREADS dnl ------------------ dnl Sets the gl_THREADLIB default so that threads are not used by default. dnl The user can still override it at installation time, by using the -dnl configure option '--enable-threads'. +dnl configure option "--enable-threads". AC_DEFUN([gl_DISABLE_THREADS], [ m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no]) @@ -621,7 +603,7 @@ dnl ------------------- dnl Sets the gl_THREADLIB default so that on mingw, a dependency to the dnl libwinpthread DLL (mingw-w64 winpthreads library) is avoided. dnl The user can still override it at installation time, by using the -dnl configure option '--enable-threads=posix'. +dnl configure option "--enable-threads=posix". dnl As of 2023, this is now the default. AC_DEFUN([gl_AVOID_WINPTHREAD], [ @@ -667,13 +649,8 @@ dnl dnl HP-UX 11 posix -lpthread N (cc) OK dnl Y (gcc) dnl -dnl IRIX 6.5 posix -lpthread Y 0.5 -dnl dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK dnl -dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK -dnl -lpthread (gcc) Y -dnl dnl Cygwin posix -lpthread Y OK dnl dnl Mingw windows N OK |