diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-19 21:27:12 (GMT) |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-19 21:27:12 (GMT) |
commit | 26fbe7f1e68bb0c96da32491efcf3696fe6c299b (patch) | |
tree | c4d95289187a64e9c7517bf73d8208026c3d2fb3 /gl/m4/threadlib.m4 | |
parent | 5f79e3e9f62ca5487d9881973149136ba1d19d3e (diff) | |
download | monitoring-plugins-26fbe7f1e68bb0c96da32491efcf3696fe6c299b.tar.gz |
Sync with the latest Gnulib code (6f2d632)
Diffstat (limited to 'gl/m4/threadlib.m4')
-rw-r--r-- | gl/m4/threadlib.m4 | 136 |
1 files changed, 80 insertions, 56 deletions
diff --git a/gl/m4/threadlib.m4 b/gl/m4/threadlib.m4 index 05cc4ff..26bdeb5 100644 --- a/gl/m4/threadlib.m4 +++ b/gl/m4/threadlib.m4 | |||
@@ -1,5 +1,5 @@ | |||
1 | # threadlib.m4 serial 5 (gettext-0.18) | 1 | # threadlib.m4 serial 10 (gettext-0.18.2) |
2 | dnl Copyright (C) 2005-2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
@@ -9,8 +9,13 @@ dnl From Bruno Haible. | |||
9 | dnl gl_THREADLIB | 9 | dnl gl_THREADLIB |
10 | dnl ------------ | 10 | dnl ------------ |
11 | dnl Tests for a multithreading library to be used. | 11 | dnl Tests for a multithreading library to be used. |
12 | dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO | ||
13 | dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the | ||
14 | dnl default is 'no', otherwise it is system dependent. In both cases, the user | ||
15 | dnl can change the choice through the options --enable-threads=choice or | ||
16 | dnl --disable-threads. | ||
12 | dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, | 17 | dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, |
13 | dnl USE_PTH_THREADS, USE_WIN32_THREADS | 18 | dnl USE_PTH_THREADS, USE_WINDOWS_THREADS |
14 | dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use | 19 | dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use |
15 | dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with | 20 | dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with |
16 | dnl libtool). | 21 | dnl libtool). |
@@ -44,10 +49,12 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY], | |||
44 | [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], | 49 | [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], |
45 | [AC_REQUIRE([AC_GNU_SOURCE])]) | 50 | [AC_REQUIRE([AC_GNU_SOURCE])]) |
46 | dnl Check for multithreading. | 51 | dnl Check for multithreading. |
47 | m4_divert_text([DEFAULTS], [gl_use_threads_default=]) | 52 | m4_ifdef([gl_THREADLIB_DEFAULT_NO], |
53 | [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], | ||
54 | [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) | ||
48 | AC_ARG_ENABLE([threads], | 55 | AC_ARG_ENABLE([threads], |
49 | AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API]) | 56 | AC_HELP_STRING([--enable-threads={posix|solaris|pth|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ |
50 | AC_HELP_STRING([--disable-threads], [build without multithread safety]), | 57 | AC_HELP_STRING([--disable-threads], [build without multithread safety])]), |
51 | [gl_use_threads=$enableval], | 58 | [gl_use_threads=$enableval], |
52 | [if test -n "$gl_use_threads_default"; then | 59 | [if test -n "$gl_use_threads_default"; then |
53 | gl_use_threads="$gl_use_threads_default" | 60 | gl_use_threads="$gl_use_threads_default" |
@@ -80,7 +87,7 @@ changequote([,])dnl | |||
80 | # groks <pthread.h>. cc also understands the flag -pthread, but | 87 | # groks <pthread.h>. cc also understands the flag -pthread, but |
81 | # we don't use it because 1. gcc-2.95 doesn't understand -pthread, | 88 | # we don't use it because 1. gcc-2.95 doesn't understand -pthread, |
82 | # 2. putting a flag into CPPFLAGS that has an effect on the linker | 89 | # 2. putting a flag into CPPFLAGS that has an effect on the linker |
83 | # causes the AC_TRY_LINK test below to succeed unexpectedly, | 90 | # causes the AC_LINK_IFELSE test below to succeed unexpectedly, |
84 | # leading to wrong values of LIBTHREAD and LTLIBTHREAD. | 91 | # leading to wrong values of LIBTHREAD and LTLIBTHREAD. |
85 | CPPFLAGS="$CPPFLAGS -D_REENTRANT" | 92 | CPPFLAGS="$CPPFLAGS -D_REENTRANT" |
86 | ;; | 93 | ;; |
@@ -111,18 +118,25 @@ AC_DEFUN([gl_THREADLIB_BODY], | |||
111 | [gl_cv_have_weak], | 118 | [gl_cv_have_weak], |
112 | [gl_cv_have_weak=no | 119 | [gl_cv_have_weak=no |
113 | dnl First, test whether the compiler accepts it syntactically. | 120 | dnl First, test whether the compiler accepts it syntactically. |
114 | AC_TRY_LINK([extern void xyzzy (); | 121 | AC_LINK_IFELSE( |
115 | #pragma weak xyzzy], [xyzzy();], [gl_cv_have_weak=maybe]) | 122 | [AC_LANG_PROGRAM( |
123 | [[extern void xyzzy (); | ||
124 | #pragma weak xyzzy]], | ||
125 | [[xyzzy();]])], | ||
126 | [gl_cv_have_weak=maybe]) | ||
116 | if test $gl_cv_have_weak = maybe; then | 127 | if test $gl_cv_have_weak = maybe; then |
117 | dnl Second, test whether it actually works. On Cygwin 1.7.2, with | 128 | 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. | 129 | dnl gcc 4.3, symbols declared weak always evaluate to the address 0. |
119 | AC_TRY_RUN([ | 130 | AC_RUN_IFELSE( |
131 | [AC_LANG_SOURCE([[ | ||
120 | #include <stdio.h> | 132 | #include <stdio.h> |
121 | #pragma weak fputs | 133 | #pragma weak fputs |
122 | int main () | 134 | int main () |
123 | { | 135 | { |
124 | return (fputs == NULL); | 136 | return (fputs == NULL); |
125 | }], [gl_cv_have_weak=yes], [gl_cv_have_weak=no], | 137 | }]])], |
138 | [gl_cv_have_weak=yes], | ||
139 | [gl_cv_have_weak=no], | ||
126 | [dnl When cross-compiling, assume that only ELF platforms support | 140 | [dnl When cross-compiling, assume that only ELF platforms support |
127 | dnl weak symbols. | 141 | dnl weak symbols. |
128 | AC_EGREP_CPP([Extensible Linking Format], | 142 | AC_EGREP_CPP([Extensible Linking Format], |
@@ -148,9 +162,11 @@ int main () | |||
148 | # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist | 162 | # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist |
149 | # in libc. IRIX 6.5 has the first one in both libc and libpthread, but | 163 | # in libc. IRIX 6.5 has the first one in both libc and libpthread, but |
150 | # the second one only in libpthread, and lock.c needs it. | 164 | # the second one only in libpthread, and lock.c needs it. |
151 | AC_TRY_LINK([#include <pthread.h>], | 165 | AC_LINK_IFELSE( |
152 | [pthread_mutex_lock((pthread_mutex_t*)0); | 166 | [AC_LANG_PROGRAM( |
153 | pthread_mutexattr_init((pthread_mutexattr_t*)0);], | 167 | [[#include <pthread.h>]], |
168 | [[pthread_mutex_lock((pthread_mutex_t*)0); | ||
169 | pthread_mutexattr_init((pthread_mutexattr_t*)0);]])], | ||
154 | [gl_have_pthread=yes]) | 170 | [gl_have_pthread=yes]) |
155 | # Test for libpthread by looking for pthread_kill. (Not pthread_self, | 171 | # Test for libpthread by looking for pthread_kill. (Not pthread_self, |
156 | # since it is defined as a macro on OSF/1.) | 172 | # since it is defined as a macro on OSF/1.) |
@@ -203,9 +219,13 @@ int main () | |||
203 | gl_have_solaristhread= | 219 | gl_have_solaristhread= |
204 | gl_save_LIBS="$LIBS" | 220 | gl_save_LIBS="$LIBS" |
205 | LIBS="$LIBS -lthread" | 221 | LIBS="$LIBS -lthread" |
206 | AC_TRY_LINK([#include <thread.h> | 222 | AC_LINK_IFELSE( |
207 | #include <synch.h>], | 223 | [AC_LANG_PROGRAM( |
208 | [thr_self();], | 224 | [[ |
225 | #include <thread.h> | ||
226 | #include <synch.h> | ||
227 | ]], | ||
228 | [[thr_self();]])], | ||
209 | [gl_have_solaristhread=yes]) | 229 | [gl_have_solaristhread=yes]) |
210 | LIBS="$gl_save_LIBS" | 230 | LIBS="$gl_save_LIBS" |
211 | if test -n "$gl_have_solaristhread"; then | 231 | if test -n "$gl_have_solaristhread"; then |
@@ -230,8 +250,10 @@ int main () | |||
230 | AC_LIB_LINKFLAGS([pth]) | 250 | AC_LIB_LINKFLAGS([pth]) |
231 | gl_have_pth= | 251 | gl_have_pth= |
232 | gl_save_LIBS="$LIBS" | 252 | gl_save_LIBS="$LIBS" |
233 | LIBS="$LIBS -lpth" | 253 | LIBS="$LIBS $LIBPTH" |
234 | AC_TRY_LINK([#include <pth.h>], [pth_self();], [gl_have_pth=yes]) | 254 | AC_LINK_IFELSE( |
255 | [AC_LANG_PROGRAM([[#include <pth.h>]], [[pth_self();]])], | ||
256 | [gl_have_pth=yes]) | ||
235 | LIBS="$gl_save_LIBS" | 257 | LIBS="$gl_save_LIBS" |
236 | if test -n "$gl_have_pth"; then | 258 | if test -n "$gl_have_pth"; then |
237 | gl_threads_api=pth | 259 | gl_threads_api=pth |
@@ -254,17 +276,19 @@ int main () | |||
254 | fi | 276 | fi |
255 | fi | 277 | fi |
256 | if test -z "$gl_have_pthread"; then | 278 | if test -z "$gl_have_pthread"; then |
257 | if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then | 279 | case "$gl_use_threads" in |
258 | if { case "$host_os" in | 280 | yes | windows | win32) # The 'win32' is for backward compatibility. |
259 | mingw*) true;; | 281 | if { case "$host_os" in |
260 | *) false;; | 282 | mingw*) true;; |
261 | esac | 283 | *) false;; |
262 | }; then | 284 | esac |
263 | gl_threads_api=win32 | 285 | }; then |
264 | AC_DEFINE([USE_WIN32_THREADS], [1], | 286 | gl_threads_api=windows |
265 | [Define if the Win32 multithreading API can be used.]) | 287 | AC_DEFINE([USE_WINDOWS_THREADS], [1], |
266 | fi | 288 | [Define if the native Windows multithreading API can be used.]) |
267 | fi | 289 | fi |
290 | ;; | ||
291 | esac | ||
268 | fi | 292 | fi |
269 | fi | 293 | fi |
270 | AC_MSG_CHECKING([for multithread API to use]) | 294 | AC_MSG_CHECKING([for multithread API to use]) |
@@ -295,50 +319,50 @@ AC_DEFUN([gl_DISABLE_THREADS], [ | |||
295 | 319 | ||
296 | dnl Survey of platforms: | 320 | dnl Survey of platforms: |
297 | dnl | 321 | dnl |
298 | dnl Platform Available Compiler Supports test-lock | 322 | dnl Platform Available Compiler Supports test-lock |
299 | dnl flavours option weak result | 323 | dnl flavours option weak result |
300 | dnl --------------- --------- --------- -------- --------- | 324 | dnl --------------- --------- --------- -------- --------- |
301 | dnl Linux 2.4/glibc posix -lpthread Y OK | 325 | dnl Linux 2.4/glibc posix -lpthread Y OK |
302 | dnl | 326 | dnl |
303 | dnl GNU Hurd/glibc posix | 327 | dnl GNU Hurd/glibc posix |
304 | dnl | 328 | dnl |
305 | dnl FreeBSD 5.3 posix -lc_r Y | 329 | dnl FreeBSD 5.3 posix -lc_r Y |
306 | dnl posix -lkse ? Y | 330 | dnl posix -lkse ? Y |
307 | dnl posix -lpthread ? Y | 331 | dnl posix -lpthread ? Y |
308 | dnl posix -lthr Y | 332 | dnl posix -lthr Y |
309 | dnl | 333 | dnl |
310 | dnl FreeBSD 5.2 posix -lc_r Y | 334 | dnl FreeBSD 5.2 posix -lc_r Y |
311 | dnl posix -lkse Y | 335 | dnl posix -lkse Y |
312 | dnl posix -lthr Y | 336 | dnl posix -lthr Y |
313 | dnl | 337 | dnl |
314 | dnl FreeBSD 4.0,4.10 posix -lc_r Y OK | 338 | dnl FreeBSD 4.0,4.10 posix -lc_r Y OK |
315 | dnl | 339 | dnl |
316 | dnl NetBSD 1.6 -- | 340 | dnl NetBSD 1.6 -- |
317 | dnl | 341 | dnl |
318 | dnl OpenBSD 3.4 posix -lpthread Y OK | 342 | dnl OpenBSD 3.4 posix -lpthread Y OK |
319 | dnl | 343 | dnl |
320 | dnl MacOS X 10.[123] posix -lpthread Y OK | 344 | dnl Mac OS X 10.[123] posix -lpthread Y OK |
321 | dnl | 345 | dnl |
322 | dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK | 346 | dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK |
323 | dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK | 347 | dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK |
324 | dnl | 348 | dnl |
325 | dnl HP-UX 11 posix -lpthread N (cc) OK | 349 | dnl HP-UX 11 posix -lpthread N (cc) OK |
326 | dnl Y (gcc) | 350 | dnl Y (gcc) |
327 | dnl | 351 | dnl |
328 | dnl IRIX 6.5 posix -lpthread Y 0.5 | 352 | dnl IRIX 6.5 posix -lpthread Y 0.5 |
329 | dnl | 353 | dnl |
330 | dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK | 354 | dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK |
331 | dnl | 355 | dnl |
332 | dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK | 356 | dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK |
333 | dnl -lpthread (gcc) Y | 357 | dnl -lpthread (gcc) Y |
334 | dnl | 358 | dnl |
335 | dnl Cygwin posix -lpthread Y OK | 359 | dnl Cygwin posix -lpthread Y OK |
336 | dnl | 360 | dnl |
337 | dnl Any of the above pth -lpth 0.0 | 361 | dnl Any of the above pth -lpth 0.0 |
338 | dnl | 362 | dnl |
339 | dnl Mingw win32 N OK | 363 | dnl Mingw windows N OK |
340 | dnl | 364 | dnl |
341 | dnl BeOS 5 -- | 365 | dnl BeOS 5 -- |
342 | dnl | 366 | dnl |
343 | dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is | 367 | dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is |
344 | dnl turned off: | 368 | dnl turned off: |