annotate m4/pthread.m4 @ 40057:b06060465f09

maint: Run 'make update-copyright'
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 01 Jan 2019 00:25:11 +0100
parents 10eb9086bea0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17857
d5c1be666ecc Fix check for pthreads.h pollution on Mingw64
Daniel P. Berrange <berrange@redhat.com>
parents: 17848
diff changeset
1 # pthread.m4 serial 10
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
11431
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
6
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
7 AC_DEFUN([gl_PTHREAD_CHECK],
13717
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
8 [
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
9 AC_REQUIRE([gl_PTHREAD_DEFAULTS])
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
10 gl_CHECK_NEXT_HEADERS([pthread.h])
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
11 if test $ac_cv_header_pthread_h = yes; then
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
12 HAVE_PTHREAD_H=1
17604
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
13 # mingw 3.0 uses winpthreads which installs broken macros via <pthread.h>
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
14 AC_CACHE_CHECK([whether <pthread.h> pollutes the namespace],
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
15 [gl_cv_header_pthread_h_pollution],
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
16 [AC_COMPILE_IFELSE(
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
17 [AC_LANG_PROGRAM(
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
18 [[#include <pthread.h>
17857
d5c1be666ecc Fix check for pthreads.h pollution on Mingw64
Daniel P. Berrange <berrange@redhat.com>
parents: 17848
diff changeset
19 #if defined strtok_r || defined localtime_r
17604
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
20 #error
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
21 break me
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
22 #endif
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
23 ]])],
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
24 [gl_cv_header_pthread_h_pollution=no],
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
25 [gl_cv_header_pthread_h_pollution=yes])])
13717
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
26 else
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
27 HAVE_PTHREAD_H=0
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
28 fi
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
29
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
30 AC_CHECK_TYPES([pthread_t, pthread_spinlock_t], [], [],
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
31 [AC_INCLUDES_DEFAULT[
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
32 #if HAVE_PTHREAD_H
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
33 #include <pthread.h>
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
34 #endif]])
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
35 if test $ac_cv_type_pthread_t != yes; then
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
36 HAVE_PTHREAD_T=0
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
37 fi
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
38 if test $ac_cv_type_pthread_spinlock_t != yes; then
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
39 HAVE_PTHREAD_SPINLOCK_T=0
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
40 fi
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
41
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
42 if test $ac_cv_header_pthread_h != yes ||
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
43 test $ac_cv_type_pthread_t != yes ||
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
44 test $ac_cv_type_pthread_spinlock_t != yes; then
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
45 PTHREAD_H='pthread.h'
17169
8b10fbdb551e pthread: better 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 16969
diff changeset
46 AC_LIBOBJ([pthread])
17604
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
47 elif test $gl_cv_header_pthread_h_pollution = yes; then
736140c38a15 pthread: work around winpthread header pollution on mingw
Eric Blake <eblake@redhat.com>
parents: 17576
diff changeset
48 PTHREAD_H=pthread.h
14528
662ae53d8d37 Remove leftover generated .h files after config.status changed.
Bruno Haible <bruno@clisp.org>
parents: 14211
diff changeset
49 else
662ae53d8d37 Remove leftover generated .h files after config.status changed.
Bruno Haible <bruno@clisp.org>
parents: 14211
diff changeset
50 PTHREAD_H=
13717
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
51 fi
14528
662ae53d8d37 Remove leftover generated .h files after config.status changed.
Bruno Haible <bruno@clisp.org>
parents: 14211
diff changeset
52 AC_SUBST([PTHREAD_H])
662ae53d8d37 Remove leftover generated .h files after config.status changed.
Bruno Haible <bruno@clisp.org>
parents: 14211
diff changeset
53 AM_CONDITIONAL([GL_GENERATE_PTHREAD_H], [test -n "$PTHREAD_H"])
11431
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
54
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
55 LIB_PTHREAD=
13717
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
56 if test $ac_cv_header_pthread_h = yes; then
16969
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
57 dnl We cannot use AC_SEARCH_LIBS here, because on OSF/1 5.1 pthread_join
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
58 dnl is defined as a macro which expands to __phread_join, and libpthread
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
59 dnl contains a definition for __phread_join but none for pthread_join.
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
60 dnl Also, FreeBSD 9 puts pthread_create in libpthread and pthread_join
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
61 dnl in libc, whereas on IRIX 6.5 the reverse is true; so check for both.
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
62 AC_CACHE_CHECK([for library containing pthread_create and pthread_join],
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
63 [gl_cv_lib_pthread],
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
64 [gl_saved_libs=$LIBS
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
65 gl_cv_lib_pthread=
17751
9e8d98ca3311 pthread, pthread_sigmask, threadlib: port to Ubuntu 14.04
Paul Eggert <eggert@cs.ucla.edu>
parents: 17706
diff changeset
66 for gl_lib_prefix in '' '-pthread' '-lpthread'; do
16969
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
67 LIBS="$gl_lib_prefix $gl_saved_libs"
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
68 AC_LINK_IFELSE(
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
69 [AC_LANG_PROGRAM(
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
70 [[#include <pthread.h>
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
71 void *noop (void *p) { return p; }]],
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
72 [[pthread_t pt;
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
73 void *arg = 0;
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
74 pthread_create (&pt, 0, noop, arg);
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
75 pthread_join (pthread_self (), &arg);]])],
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
76 [if test -z "$gl_lib_prefix"; then
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
77 gl_cv_lib_pthread="none required"
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
78 else
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
79 gl_cv_lib_pthread=$gl_lib_prefix
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
80 fi])
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
81 test -n "$gl_cv_lib_pthread" && break
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
82 done
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
83 LIBS="$gl_saved_libs"
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
84 ])
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
85 if test "$gl_cv_lib_pthread" != "none required"; then
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
86 LIB_PTHREAD="$gl_cv_lib_pthread"
b284d21804b8 pthread: check for both pthread_create and pthread_join
Paul Eggert <eggert@cs.ucla.edu>
parents: 16965
diff changeset
87 fi
11431
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
88 fi
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
89 AC_SUBST([LIB_PTHREAD])
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
90
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
91 AC_REQUIRE([AC_C_RESTRICT])
4a2a6b0eadea New modules nproc, pthread.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
92 ])
13717
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
93
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
94 AC_DEFUN([gl_PTHREAD_DEFAULTS],
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
95 [
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
96 dnl Assume proper GNU behavior unless another module says otherwise.
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
97 HAVE_PTHREAD_H=1; AC_SUBST([HAVE_PTHREAD_H])
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
98 HAVE_PTHREAD_T=1; AC_SUBST([HAVE_PTHREAD_T])
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
99 HAVE_PTHREAD_SPINLOCK_T=1; AC_SUBST([HAVE_PTHREAD_SPINLOCK_T])
b747a553a8bb pthread: add to system <pthread.h> instead of replacing it all, for MacOS
Paul Eggert <eggert@cs.ucla.edu>
parents: 13467
diff changeset
100 ])