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.m454
1 files changed, 44 insertions, 10 deletions
diff --git a/gl/m4/threadlib.m4 b/gl/m4/threadlib.m4
index 3dd38aa8..05cc4ffa 100644
--- a/gl/m4/threadlib.m4
+++ b/gl/m4/threadlib.m4
@@ -1,5 +1,5 @@
1# threadlib.m4 serial 3 (gettext-0.18) 1# threadlib.m4 serial 5 (gettext-0.18)
2dnl Copyright (C) 2005-2009 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -52,13 +52,24 @@ AC_HELP_STRING([--disable-threads], [build without multithread safety]),
52 [if test -n "$gl_use_threads_default"; then 52 [if test -n "$gl_use_threads_default"; then
53 gl_use_threads="$gl_use_threads_default" 53 gl_use_threads="$gl_use_threads_default"
54 else 54 else
55changequote(,)dnl
55 case "$host_os" in 56 case "$host_os" in
56 dnl Disable multithreading by default on OSF/1, because it interferes 57 dnl Disable multithreading by default on OSF/1, because it interferes
57 dnl with fork()/exec(): When msgexec is linked with -lpthread, its 58 dnl with fork()/exec(): When msgexec is linked with -lpthread, its
58 dnl child process gets an endless segmentation fault inside execvp(). 59 dnl child process gets an endless segmentation fault inside execvp().
60 dnl Disable multithreading by default on Cygwin 1.5.x, because it has
61 dnl bugs that lead to endless loops or crashes. See
62 dnl <http://cygwin.com/ml/cygwin/2009-08/msg00283.html>.
59 osf*) gl_use_threads=no ;; 63 osf*) gl_use_threads=no ;;
64 cygwin*)
65 case `uname -r` in
66 1.[0-5].*) gl_use_threads=no ;;
67 *) gl_use_threads=yes ;;
68 esac
69 ;;
60 *) gl_use_threads=yes ;; 70 *) gl_use_threads=yes ;;
61 esac 71 esac
72changequote([,])dnl
62 fi 73 fi
63 ]) 74 ])
64 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then 75 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
@@ -96,11 +107,34 @@ AC_DEFUN([gl_THREADLIB_BODY],
96 LTLIBMULTITHREAD= 107 LTLIBMULTITHREAD=
97 if test "$gl_use_threads" != no; then 108 if test "$gl_use_threads" != no; then
98 dnl Check whether the compiler and linker support weak declarations. 109 dnl Check whether the compiler and linker support weak declarations.
99 AC_MSG_CHECKING([whether imported symbols can be declared weak]) 110 AC_CACHE_CHECK([whether imported symbols can be declared weak],
100 gl_have_weak=no 111 [gl_cv_have_weak],
101 AC_TRY_LINK([extern void xyzzy (); 112 [gl_cv_have_weak=no
102#pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes]) 113 dnl First, test whether the compiler accepts it syntactically.
103 AC_MSG_RESULT([$gl_have_weak]) 114 AC_TRY_LINK([extern void xyzzy ();
115#pragma weak xyzzy], [xyzzy();], [gl_cv_have_weak=maybe])
116 if test $gl_cv_have_weak = maybe; then
117 dnl Second, test whether it actually works. On Cygwin 1.7.2, with
118 dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
119 AC_TRY_RUN([
120#include <stdio.h>
121#pragma weak fputs
122int main ()
123{
124 return (fputs == NULL);
125}], [gl_cv_have_weak=yes], [gl_cv_have_weak=no],
126 [dnl When cross-compiling, assume that only ELF platforms support
127 dnl weak symbols.
128 AC_EGREP_CPP([Extensible Linking Format],
129 [#ifdef __ELF__
130 Extensible Linking Format
131 #endif
132 ],
133 [gl_cv_have_weak="guessing yes"],
134 [gl_cv_have_weak="guessing no"])
135 ])
136 fi
137 ])
104 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then 138 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
105 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that 139 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
106 # it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY. 140 # it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
@@ -154,7 +188,7 @@ AC_DEFUN([gl_THREADLIB_BODY],
154 AC_DEFINE([USE_POSIX_THREADS], [1], 188 AC_DEFINE([USE_POSIX_THREADS], [1],
155 [Define if the POSIX multithreading library can be used.]) 189 [Define if the POSIX multithreading library can be used.])
156 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then 190 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
157 if test $gl_have_weak = yes; then 191 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
158 AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], 192 AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
159 [Define if references to the POSIX multithreading library should be made weak.]) 193 [Define if references to the POSIX multithreading library should be made weak.])
160 LIBTHREAD= 194 LIBTHREAD=
@@ -182,7 +216,7 @@ AC_DEFUN([gl_THREADLIB_BODY],
182 LTLIBMULTITHREAD="$LTLIBTHREAD" 216 LTLIBMULTITHREAD="$LTLIBTHREAD"
183 AC_DEFINE([USE_SOLARIS_THREADS], [1], 217 AC_DEFINE([USE_SOLARIS_THREADS], [1],
184 [Define if the old Solaris multithreading library can be used.]) 218 [Define if the old Solaris multithreading library can be used.])
185 if test $gl_have_weak = yes; then 219 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
186 AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1], 220 AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1],
187 [Define if references to the old Solaris multithreading library should be made weak.]) 221 [Define if references to the old Solaris multithreading library should be made weak.])
188 LIBTHREAD= 222 LIBTHREAD=
@@ -208,7 +242,7 @@ AC_DEFUN([gl_THREADLIB_BODY],
208 AC_DEFINE([USE_PTH_THREADS], [1], 242 AC_DEFINE([USE_PTH_THREADS], [1],
209 [Define if the GNU Pth multithreading library can be used.]) 243 [Define if the GNU Pth multithreading library can be used.])
210 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then 244 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
211 if test $gl_have_weak = yes; then 245 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
212 AC_DEFINE([USE_PTH_THREADS_WEAK], [1], 246 AC_DEFINE([USE_PTH_THREADS_WEAK], [1],
213 [Define if references to the GNU Pth multithreading library should be made weak.]) 247 [Define if references to the GNU Pth multithreading library should be made weak.])
214 LIBTHREAD= 248 LIBTHREAD=