summaryrefslogtreecommitdiffstats
path: root/gl/m4/threadlib.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/threadlib.m4')
-rw-r--r--gl/m4/threadlib.m445
1 files changed, 12 insertions, 33 deletions
diff --git a/gl/m4/threadlib.m4 b/gl/m4/threadlib.m4
index 333c8fe0..bdea4b97 100644
--- a/gl/m4/threadlib.m4
+++ b/gl/m4/threadlib.m4
@@ -1,6 +1,6 @@
1# threadlib.m4 1# threadlib.m4
2# serial 45.1 2# serial 49
3dnl Copyright (C) 2005-2025 Free Software Foundation, Inc. 3dnl Copyright (C) 2005-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -57,16 +57,6 @@ AC_DEFUN([gl_ANYTHREADLIB_EARLY],
57[ 57[
58 AC_REQUIRE([AC_CANONICAL_HOST]) 58 AC_REQUIRE([AC_CANONICAL_HOST])
59 if test -z "$gl_anythreadlib_early_done"; then 59 if test -z "$gl_anythreadlib_early_done"; then
60 AS_CASE([$host_os],
61 [osf*],
62 [# On OSF/1, the compiler needs the flag -D_REENTRANT so that it
63 # groks <pthread.h>. cc also understands the flag -pthread, but
64 # we do not use it because 1. gcc-2.95 does not understand -pthread,
65 # 2. putting a flag into CPPFLAGS that has an effect on the linker
66 # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
67 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
68 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
69 ])
70 # Some systems optimize for single-threaded programs by default, and 60 # Some systems optimize for single-threaded programs by default, and
71 # need special flags to disable these optimizations. For example, the 61 # need special flags to disable these optimizations. For example, the
72 # definition of errno in <errno.h>. 62 # definition of errno in <errno.h>.
@@ -190,17 +180,13 @@ AC_DEFUN([gl_PTHREADLIB_BODY],
190 gl_pthread_api=no 180 gl_pthread_api=no
191 LIBPTHREAD= 181 LIBPTHREAD=
192 LIBPMULTITHREAD= 182 LIBPMULTITHREAD=
193 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
194 # it groks <pthread.h>. It is added above, in gl_ANYTHREADLIB_EARLY.
195 AC_CHECK_HEADER([pthread.h], 183 AC_CHECK_HEADER([pthread.h],
196 [gl_have_pthread_h=yes], [gl_have_pthread_h=no]) 184 [gl_have_pthread_h=yes], [gl_have_pthread_h=no])
197 AS_IF([test "$gl_have_pthread_h" = yes], [ 185 AS_IF([test "$gl_have_pthread_h" = yes], [
198 # Other possible tests: 186 # Other possible tests:
199 # -lpthreads (FSU threads, PCthreads) 187 # -lpthreads (FSU threads, PCthreads)
200 # -lgthreads 188 # -lgthreads
201 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist 189 # Test whether both pthread_mutex_lock exists in libc.
202 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
203 # the second one only in libpthread, and lock.c needs it.
204 # 190 #
205 # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04 191 # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04
206 # needs -pthread for some reason. See: 192 # needs -pthread for some reason. See:
@@ -212,10 +198,8 @@ AC_DEFUN([gl_PTHREADLIB_BODY],
212 [AC_LANG_PROGRAM( 198 [AC_LANG_PROGRAM(
213 [[#include <pthread.h> 199 [[#include <pthread.h>
214 pthread_mutex_t m; 200 pthread_mutex_t m;
215 pthread_mutexattr_t ma;
216 ]], 201 ]],
217 [[pthread_mutex_lock (&m); 202 [[pthread_mutex_lock (&m);]])],
218 pthread_mutexattr_init (&ma);]])],
219 [gl_pthread_api=yes 203 [gl_pthread_api=yes
220 LIBPTHREAD=$gl_pthread 204 LIBPTHREAD=$gl_pthread
221 LIBPMULTITHREAD=$gl_pthread]) 205 LIBPMULTITHREAD=$gl_pthread])
@@ -244,8 +228,7 @@ AC_DEFUN([gl_PTHREADLIB_BODY],
244 ]) 228 ])
245 echo "$as_me:__oline__: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&AS_MESSAGE_LOG_FD 229 echo "$as_me:__oline__: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&AS_MESSAGE_LOG_FD
246 230
247 # Test for libpthread by looking for pthread_kill. (Not pthread_self, 231 # Test for libpthread by looking for pthread_kill.
248 # since it is defined as a macro on OSF/1.)
249 AS_IF([test $gl_pthread_api = yes && test -z "$LIBPTHREAD"], [ 232 AS_IF([test $gl_pthread_api = yes && test -z "$LIBPTHREAD"], [
250 # The program links fine without libpthread. But it may actually 233 # The program links fine without libpthread. But it may actually
251 # need to link with libpthread in order to create multiple threads. 234 # need to link with libpthread in order to create multiple threads.
@@ -451,18 +434,19 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY],
451 dnl gl_use_winpthreads_default defaults to "no", because in mingw 10, like 434 dnl gl_use_winpthreads_default defaults to "no", because in mingw 10, like
452 dnl in mingw 5, the use of libwinpthread still makes test-pthread-tss crash. 435 dnl in mingw 5, the use of libwinpthread still makes test-pthread-tss crash.
453 m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=no]) 436 m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=no])
437 dnl Don't display the --disable-threads option
438 dnl - if the package builds one or more libraries, because libraries must
439 dnl always be multithread-safe (as far as possible),
440 dnl - if the package defines gl_THREADLIB_DEFAULT_NO, because the option
441 dnl would then be a no-op.
454 AC_ARG_ENABLE([threads], 442 AC_ARG_ENABLE([threads],
455AS_HELP_STRING([[--enable-threads={isoc|posix|isoc+posix|windows}]], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ 443AS_HELP_STRING([[--enable-threads={isoc|posix|isoc+posix|windows}]], [specify multithreading API])m4_ifdef([LT_INIT], [], [m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
456AS_HELP_STRING([[--disable-threads]], [build without multithread safety])]), 444AS_HELP_STRING([[--disable-threads]], [build without multithread safety])])]),
457 [gl_use_threads=$enableval], 445 [gl_use_threads=$enableval],
458 [if test -n "$gl_use_threads_default"; then 446 [if test -n "$gl_use_threads_default"; then
459 gl_use_threads="$gl_use_threads_default" 447 gl_use_threads="$gl_use_threads_default"
460 else 448 else
461 AS_CASE([$host_os], 449 AS_CASE([$host_os],
462 dnl Disable multithreading by default on OSF/1, because it interferes
463 dnl with fork()/exec(): When msgexec is linked with -lpthread, its
464 dnl child process gets an endless segmentation fault inside execvp().
465 [osf*], [gl_use_threads=no],
466 dnl Disable multithreading by default on Cygwin 1.5.x, because it has 450 dnl Disable multithreading by default on Cygwin 1.5.x, because it has
467 dnl bugs that lead to endless loops or crashes. See 451 dnl bugs that lead to endless loops or crashes. See
468 dnl <https://cygwin.com/ml/cygwin/2009-08/msg00283.html>. 452 dnl <https://cygwin.com/ml/cygwin/2009-08/msg00283.html>.
@@ -665,13 +649,8 @@ dnl
665dnl HP-UX 11 posix -lpthread N (cc) OK 649dnl HP-UX 11 posix -lpthread N (cc) OK
666dnl Y (gcc) 650dnl Y (gcc)
667dnl 651dnl
668dnl IRIX 6.5 posix -lpthread Y 0.5
669dnl
670dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK 652dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK
671dnl 653dnl
672dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK
673dnl -lpthread (gcc) Y
674dnl
675dnl Cygwin posix -lpthread Y OK 654dnl Cygwin posix -lpthread Y OK
676dnl 655dnl
677dnl Mingw windows N OK 656dnl Mingw windows N OK