usleep tests: Avoid failure due to known Cygwin 3.5.3 bug.
[gnulib.git] / tests / test-pthread-c++.cc
blobc89e32f8a09be770c1e2ad8481c18ff3105092a6
1 /* Test of <pthread.h> substitute in C++ mode.
2 Copyright (C) 2019-2024 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2019. */
19 #define GNULIB_NAMESPACE gnulib
20 #include <config.h>
22 #include <pthread.h>
24 #include "signature.h"
27 /* =========== Thread functions =========== */
29 #if GNULIB_TEST_PTHREAD_THREAD
30 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_create, int,
31 (pthread_t *, const pthread_attr_t *,
32 void * (*) (void*), void *));
33 #endif
35 #if GNULIB_TEST_PTHREAD_THREAD
36 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_attr_init, int, (pthread_attr_t *));
37 #endif
39 #if GNULIB_TEST_PTHREAD_THREAD
40 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_attr_getdetachstate, int,
41 (const pthread_attr_t *, int *));
42 #endif
44 #if GNULIB_TEST_PTHREAD_THREAD
45 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_attr_setdetachstate, int,
46 (pthread_attr_t *, int));
47 #endif
49 #if GNULIB_TEST_PTHREAD_THREAD
50 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_attr_destroy, int,
51 (pthread_attr_t *));
52 #endif
54 #if GNULIB_TEST_PTHREAD_THREAD
55 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_self, pthread_t, (void));
56 #endif
58 #if GNULIB_TEST_PTHREAD_THREAD
59 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_equal, int, (pthread_t, pthread_t));
60 #endif
62 #if GNULIB_TEST_PTHREAD_THREAD
63 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_detach, int, (pthread_t));
64 #endif
66 #if GNULIB_TEST_PTHREAD_THREAD
67 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_join, int, (pthread_t, void **));
68 #endif
70 #if GNULIB_TEST_PTHREAD_THREAD
71 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_exit, void, (void *));
72 #endif
74 /* =========== Once-only control (initialization) functions =========== */
76 #if GNULIB_TEST_PTHREAD_ONCE
77 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_once, int,
78 (pthread_once_t *, void (*) (void)));
79 #endif
81 /* =========== Mutex functions =========== */
83 #if GNULIB_TEST_PTHREAD_MUTEX
84 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutex_init, int,
85 (pthread_mutex_t *, const pthread_mutexattr_t *));
86 #endif
88 #if GNULIB_TEST_PTHREAD_MUTEX
89 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutexattr_init, int,
90 (pthread_mutexattr_t *));
91 #endif
93 #if GNULIB_TEST_PTHREAD_MUTEX
94 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutexattr_gettype, int,
95 (const pthread_mutexattr_t *, int *));
96 #endif
98 #if GNULIB_TEST_PTHREAD_MUTEX
99 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutexattr_settype, int,
100 (pthread_mutexattr_t *, int));
101 #endif
103 #if GNULIB_TEST_PTHREAD_MUTEX
104 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutexattr_getrobust, int,
105 (const pthread_mutexattr_t *, int *));
106 #endif
108 #if GNULIB_TEST_PTHREAD_MUTEX
109 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutexattr_setrobust, int,
110 (pthread_mutexattr_t *, int));
111 #endif
113 #if GNULIB_TEST_PTHREAD_MUTEX
114 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutexattr_destroy, int,
115 (pthread_mutexattr_t *));
116 #endif
118 #if GNULIB_TEST_PTHREAD_MUTEX
119 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutex_lock, int,
120 (pthread_mutex_t *));
121 #endif
123 #if GNULIB_TEST_PTHREAD_MUTEX
124 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutex_trylock, int,
125 (pthread_mutex_t *));
126 #endif
128 #if GNULIB_TEST_PTHREAD_MUTEX_TIMEDLOCK
129 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutex_timedlock, int,
130 (pthread_mutex_t *, const struct timespec *));
131 #endif
133 #if GNULIB_TEST_PTHREAD_MUTEX
134 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutex_unlock, int,
135 (pthread_mutex_t *));
136 #endif
138 #if GNULIB_TEST_PTHREAD_MUTEX
139 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_mutex_destroy, int,
140 (pthread_mutex_t *));
141 #endif
143 /* =========== Read-write lock functions =========== */
145 #if GNULIB_TEST_PTHREAD_RWLOCK
146 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_rwlock_init, int,
147 (pthread_rwlock_t *, const pthread_rwlockattr_t *));
148 #endif
150 #if GNULIB_TEST_PTHREAD_RWLOCK
151 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_rwlockattr_init, int,
152 (pthread_rwlockattr_t *));
153 #endif
155 #if GNULIB_TEST_PTHREAD_RWLOCK
156 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_rwlockattr_destroy, int,
157 (pthread_rwlockattr_t *));
158 #endif
160 #if GNULIB_TEST_PTHREAD_RWLOCK
161 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_rwlock_rdlock, int,
162 (pthread_rwlock_t *));
163 #endif
165 #if GNULIB_TEST_PTHREAD_RWLOCK
166 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_rwlock_wrlock, int,
167 (pthread_rwlock_t *));
168 #endif
170 #if GNULIB_TEST_PTHREAD_RWLOCK
171 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_rwlock_tryrdlock, int,
172 (pthread_rwlock_t *));
173 #endif
175 #if GNULIB_TEST_PTHREAD_RWLOCK
176 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_rwlock_trywrlock, int,
177 (pthread_rwlock_t *));
178 #endif
180 #if GNULIB_TEST_PTHREAD_RWLOCK
181 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_rwlock_timedrdlock, int,
182 (pthread_rwlock_t *, const struct timespec *));
183 #endif
185 #if GNULIB_TEST_PTHREAD_RWLOCK
186 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_rwlock_timedwrlock, int,
187 (pthread_rwlock_t *, const struct timespec *));
188 #endif
190 #if GNULIB_TEST_PTHREAD_RWLOCK
191 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_rwlock_unlock, int,
192 (pthread_rwlock_t *));
193 #endif
195 #if GNULIB_TEST_PTHREAD_RWLOCK
196 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_rwlock_destroy, int,
197 (pthread_rwlock_t *));
198 #endif
200 /* =========== Condition variable functions =========== */
202 #if GNULIB_TEST_PTHREAD_COND
203 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_cond_init, int,
204 (pthread_cond_t *, const pthread_condattr_t *));
205 #endif
207 #if GNULIB_TEST_PTHREAD_COND
208 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_condattr_init, int,
209 (pthread_condattr_t *));
210 #endif
212 #if GNULIB_TEST_PTHREAD_COND
213 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_condattr_destroy, int,
214 (pthread_condattr_t *));
215 #endif
217 #if GNULIB_TEST_PTHREAD_COND
218 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_cond_wait, int,
219 (pthread_cond_t *, pthread_mutex_t *));
220 #endif
222 #if GNULIB_TEST_PTHREAD_COND
223 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_cond_timedwait, int,
224 (pthread_cond_t *, pthread_mutex_t *,
225 const struct timespec *));
226 #endif
228 #if GNULIB_TEST_PTHREAD_COND
229 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_cond_signal, int,
230 (pthread_cond_t *));
231 #endif
233 #if GNULIB_TEST_PTHREAD_COND
234 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_cond_broadcast, int,
235 (pthread_cond_t *));
236 #endif
238 #if GNULIB_TEST_PTHREAD_COND
239 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_cond_destroy, int,
240 (pthread_cond_t *));
241 #endif
243 /* =========== Thread-specific storage functions =========== */
245 #if GNULIB_TEST_PTHREAD_TSS
246 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_key_create, int,
247 (pthread_key_t *, void (*) (void *)));
248 #endif
250 #if GNULIB_TEST_PTHREAD_TSS
251 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_setspecific, int,
252 (pthread_key_t, const void *));
253 #endif
255 #if GNULIB_TEST_PTHREAD_TSS
256 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_getspecific, void *,
257 (pthread_key_t));
258 #endif
260 #if GNULIB_TEST_PTHREAD_TSS
261 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_key_delete, int, (pthread_key_t));
262 #endif
264 /* =========== Spinlock functions =========== */
266 #if GNULIB_TEST_PTHREAD_SPIN
267 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_spin_init, int,
268 (pthread_spinlock_t *, int));
269 #endif
271 #if GNULIB_TEST_PTHREAD_SPIN
272 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_spin_lock, int,
273 (pthread_spinlock_t *));
274 #endif
276 #if GNULIB_TEST_PTHREAD_SPIN
277 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_spin_trylock, int,
278 (pthread_spinlock_t *));
279 #endif
281 #if GNULIB_TEST_PTHREAD_SPIN
282 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_spin_unlock, int,
283 (pthread_spinlock_t *));
284 #endif
286 #if GNULIB_TEST_PTHREAD_SPIN
287 SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_spin_destroy, int,
288 (pthread_spinlock_t *));
289 #endif
293 main ()