File: pthread.m4

package info (click to toggle)
libolecf 20181231-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 12,476 kB
  • sloc: ansic: 182,255; sh: 6,096; makefile: 1,356; python: 325; sed: 16
file content (183 lines) | stat: -rw-r--r-- 3,852 bytes parent folder | download | duplicates (112)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
dnl Functions for pthread
dnl
dnl Version: 20130509

dnl Function to detect if pthread is available
AC_DEFUN([AX_PTHREAD_CHECK_LIB],
 [dnl Check if parameters were provided
 AS_IF(
  [test "x$ac_cv_with_pthread" != x && test "x$ac_cv_with_pthread" != xno && test "x$ac_cv_with_pthread" != xauto-detect],
  [AS_IF(
   [test -d "$ac_cv_with_pthread"],
   [CFLAGS="$CFLAGS -I${ac_cv_with_pthread}/include"
   LDFLAGS="$LDFLAGS -L${ac_cv_with_pthread}/lib"],
   [AC_MSG_WARN([no such directory: $ac_cv_with_pthread])
   ])
  ])

 AS_IF(
  [test "x$ac_cv_with_pthread" = xno],
  [ac_cv_pthread=no],
  [dnl Check for headers
  AC_CHECK_HEADERS([pthread.h])

  AS_IF(
   [test "x$ac_cv_header_pthread_h" = xno],
   [ac_cv_pthread=no],
   [dnl Check for the individual functions
   ac_cv_pthread=pthread

   dnl Thread functions
   AC_CHECK_LIB(
    pthread,
    pthread_create,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_exit,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_join,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])

   dnl Condition functions
   AC_CHECK_LIB(
    pthread,
    pthread_cond_init,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_cond_destroy,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_cond_broadcast,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_cond_signal,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_cond_wait,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])

   dnl Mutex functions
   AC_CHECK_LIB(
    pthread,
    pthread_mutex_init,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_mutex_destroy,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_mutex_lock,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_mutex_trylock,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_mutex_unlock,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])

   dnl Read/Write lock functions
   AC_CHECK_LIB(
    pthread,
    pthread_rwlock_init,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_rwlock_destroy,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_rwlock_rdlock,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_rwlock_wrlock,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])
   AC_CHECK_LIB(
    pthread,
    pthread_rwlock_unlock,
    [ac_pthread_dummy=yes],
    [ac_cv_pthread=no])

   ac_cv_pthread_LIBADD="-lpthread";
   ])
  ])

 AS_IF(
  [test "x$ac_cv_pthread" = xpthread],
  [AC_DEFINE(
   [HAVE_PTHREAD],
   [1],
   [Define to 1 if you have the 'pthread' library (-lpthread).])
  ])

 AS_IF(
  [test "x$ac_cv_pthread" != xno],
  [AC_SUBST(
   [HAVE_PTHREAD],
   [1]) ],
  [AC_SUBST(
   [HAVE_PTHREAD],
   [0])
  ])
 ])

dnl Function to detect how to enable pthread
AC_DEFUN([AX_PTHREAD_CHECK_ENABLE],
 [AX_COMMON_ARG_WITH(
  [pthread],
  [pthread],
  [search for pthread in includedir and libdir or in the specified DIR, or no if not to use pthread],
  [auto-detect],
  [DIR])

 dnl Check for a shared library version
 AX_PTHREAD_CHECK_LIB

 AS_IF(
  [test "x$ac_cv_pthread_CPPFLAGS" != "x"],
  [AC_SUBST(
   [PTHREAD_CPPFLAGS],
   [$ac_cv_pthread_CPPFLAGS])
  ])
 AS_IF(
  [test "x$ac_cv_pthread_LIBADD" != "x"],
  [AC_SUBST(
   [PTHREAD_LIBADD],
   [$ac_cv_pthread_LIBADD])
  ])

 AS_IF(
  [test "x$ac_cv_pthread" = xpthread],
  [AC_SUBST(
   [ax_pthread_pc_libs_private],
   [-lpthread])
  ])
 ])