summaryrefslogtreecommitdiff
path: root/gnulib-m4/threadlib.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gnulib-m4/threadlib.m4')
-rw-r--r--gnulib-m4/threadlib.m4162
1 files changed, 60 insertions, 102 deletions
diff --git a/gnulib-m4/threadlib.m4 b/gnulib-m4/threadlib.m4
index 8615ac9..05cc4ff 100644
--- a/gnulib-m4/threadlib.m4
+++ b/gnulib-m4/threadlib.m4
@@ -1,5 +1,5 @@
-# threadlib.m4 serial 11 (gettext-0.18.2)
-dnl Copyright (C) 2005-2015 Free Software Foundation, Inc.
+# threadlib.m4 serial 5 (gettext-0.18)
+dnl Copyright (C) 2005-2010 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.
@@ -9,20 +9,15 @@ dnl From Bruno Haible.
dnl gl_THREADLIB
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 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_SOLARIS_THREADS,
-dnl USE_PTH_THREADS, USE_WINDOWS_THREADS
+dnl USE_PTH_THREADS, USE_WIN32_THREADS
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).
dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
dnl programs that really need multithread functionality. The difference
dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
-dnl symbols, typically LIBTHREAD is empty whereas LIBMULTITHREAD is not.
+dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread".
dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
dnl multithread-safe programs.
@@ -49,12 +44,10 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY],
[AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
[AC_REQUIRE([AC_GNU_SOURCE])])
dnl Check for multithreading.
- m4_ifdef([gl_THREADLIB_DEFAULT_NO],
- [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
- [m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
+ m4_divert_text([DEFAULTS], [gl_use_threads_default=])
AC_ARG_ENABLE([threads],
-AC_HELP_STRING([--enable-threads={posix|solaris|pth|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
-AC_HELP_STRING([--disable-threads], [build without multithread safety])]),
+AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API])
+AC_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"
@@ -87,7 +80,7 @@ changequote([,])dnl
# 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,
+ # causes the AC_TRY_LINK test below to succeed unexpectedly,
# leading to wrong values of LIBTHREAD and LTLIBTHREAD.
CPPFLAGS="$CPPFLAGS -D_REENTRANT"
;;
@@ -118,25 +111,18 @@ AC_DEFUN([gl_THREADLIB_BODY],
[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])
+ AC_TRY_LINK([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([[
+ AC_TRY_RUN([
#include <stdio.h>
#pragma weak fputs
int main ()
{
return (fputs == NULL);
-}]])],
- [gl_cv_have_weak=yes],
- [gl_cv_have_weak=no],
+}], [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],
@@ -162,31 +148,13 @@ int main ()
# 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:
- # http://lists.gnu.org/archive/html/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
-
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_mutex_lock((pthread_mutex_t*)0);
+ pthread_mutexattr_init((pthread_mutexattr_t*)0);],
+ [gl_have_pthread=yes])
# 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
+ if test -n "$gl_have_pthread"; 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],
@@ -201,7 +169,7 @@ int main ()
[Define if the pthread_in_use() detection is hard.])
esac
])
- elif test -z "$gl_have_pthread"; then
+ else
# Some library is needed. Try libpthread and libc_r.
AC_CHECK_LIB([pthread], [pthread_kill],
[gl_have_pthread=yes
@@ -235,13 +203,9 @@ int main ()
gl_have_solaristhread=
gl_save_LIBS="$LIBS"
LIBS="$LIBS -lthread"
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM(
- [[
-#include <thread.h>
-#include <synch.h>
- ]],
- [[thr_self();]])],
+ AC_TRY_LINK([#include <thread.h>
+#include <synch.h>],
+ [thr_self();],
[gl_have_solaristhread=yes])
LIBS="$gl_save_LIBS"
if test -n "$gl_have_solaristhread"; then
@@ -266,10 +230,8 @@ int main ()
AC_LIB_LINKFLAGS([pth])
gl_have_pth=
gl_save_LIBS="$LIBS"
- LIBS="$LIBS $LIBPTH"
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[#include <pth.h>]], [[pth_self();]])],
- [gl_have_pth=yes])
+ LIBS="$LIBS -lpth"
+ AC_TRY_LINK([#include <pth.h>], [pth_self();], [gl_have_pth=yes])
LIBS="$gl_save_LIBS"
if test -n "$gl_have_pth"; then
gl_threads_api=pth
@@ -292,19 +254,17 @@ int main ()
fi
fi
if test -z "$gl_have_pthread"; then
- case "$gl_use_threads" in
- yes | windows | win32) # The 'win32' is for backward compatibility.
- if { case "$host_os" in
- mingw*) 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
+ if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then
+ if { case "$host_os" in
+ mingw*) true;;
+ *) false;;
+ esac
+ }; then
+ gl_threads_api=win32
+ AC_DEFINE([USE_WIN32_THREADS], [1],
+ [Define if the Win32 multithreading API can be used.])
+ fi
+ fi
fi
fi
AC_MSG_CHECKING([for multithread API to use])
@@ -335,52 +295,50 @@ AC_DEFUN([gl_DISABLE_THREADS], [
dnl Survey of platforms:
dnl
-dnl Platform Available Compiler Supports test-lock
-dnl flavours option weak result
-dnl --------------- --------- --------- -------- ---------
-dnl Linux 2.4/glibc posix -lpthread Y OK
-dnl
-dnl GNU Hurd/glibc posix
+dnl Platform Available Compiler Supports test-lock
+dnl flavours option weak result
+dnl --------------- --------- --------- -------- ---------
+dnl Linux 2.4/glibc posix -lpthread Y OK
dnl
-dnl Ubuntu 14.04 posix -pthread Y OK
+dnl GNU Hurd/glibc posix
dnl
-dnl FreeBSD 5.3 posix -lc_r Y
-dnl posix -lkse ? Y
-dnl posix -lpthread ? Y
-dnl posix -lthr Y
+dnl FreeBSD 5.3 posix -lc_r Y
+dnl posix -lkse ? Y
+dnl posix -lpthread ? Y
+dnl posix -lthr Y
dnl
-dnl FreeBSD 5.2 posix -lc_r Y
-dnl posix -lkse Y
-dnl posix -lthr Y
+dnl FreeBSD 5.2 posix -lc_r Y
+dnl posix -lkse Y
+dnl posix -lthr Y
dnl
-dnl FreeBSD 4.0,4.10 posix -lc_r Y OK
+dnl FreeBSD 4.0,4.10 posix -lc_r Y OK
dnl
-dnl NetBSD 1.6 --
+dnl NetBSD 1.6 --
dnl
-dnl OpenBSD 3.4 posix -lpthread Y OK
+dnl OpenBSD 3.4 posix -lpthread Y OK
dnl
-dnl Mac OS X 10.[123] posix -lpthread Y OK
+dnl MacOS X 10.[123] posix -lpthread Y OK
dnl
-dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK
-dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK
+dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK
+dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK
dnl
-dnl HP-UX 11 posix -lpthread N (cc) OK
+dnl HP-UX 11 posix -lpthread N (cc) OK
dnl Y (gcc)
dnl
-dnl IRIX 6.5 posix -lpthread Y 0.5
+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 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 OSF/1 4.0,5.1 posix -pthread (cc) N OK
dnl -lpthread (gcc) Y
dnl
-dnl Cygwin posix -lpthread Y OK
+dnl Cygwin posix -lpthread Y OK
dnl
-dnl Any of the above pth -lpth 0.0
+dnl Any of the above pth -lpth 0.0
dnl
-dnl Mingw windows N OK
+dnl Mingw win32 N OK
dnl
-dnl BeOS 5 --
+dnl BeOS 5 --
dnl
dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is
dnl turned off: