1 /* An ISO C 11 compatible <threads.h>.
3 Copyright (C) 2019-2024 Free Software Foundation, Inc.
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19 @PRAGMA_SYSTEM_HEADER@
23 #if defined _GL_ALREADY_INCLUDING_THREADS_H
24 /* Special invocation convention:
25 - On Android we have a sequence of nested includes
26 <threads.h> -> <android/legacy_threads_inlines.h>
27 -> <bits/threads_inlines.h> -> "threads.h"
28 In this situation, the functions are not yet declared, therefore we cannot
29 provide the C++ aliases. */
31 #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_THREADS_H@
34 /* Normal invocation convention. */
36 #ifndef _@GUARD_PREFIX@_THREADS_H
38 #define _GL_ALREADY_INCLUDING_THREADS_H
40 /* The include_next requires a split double-inclusion guard. */
42 # @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_THREADS_H@
45 #undef _GL_ALREADY_INCLUDING_THREADS_H
47 #ifndef _@GUARD_PREFIX@_THREADS_H
48 #define _@GUARD_PREFIX@_THREADS_H
50 /* This file uses _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, _Thread_local,
52 #if !_GL_CONFIG_H_INCLUDED
53 #error "Please include config.h first."
60 # if defined _WIN32 && ! defined __CYGWIN__
61 /* Use Windows threads. */
63 # define WIN32_LEAN_AND_MEAN /* avoid including junk */
67 /* Use POSIX threads. */
75 /* The __attribute__ feature is available in gcc versions 2.5 and later.
76 The attribute __pure__ was added in gcc 2.96. */
77 #ifndef _GL_ATTRIBUTE_PURE
78 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
79 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
81 # define _GL_ATTRIBUTE_PURE /* empty */
85 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
87 /* The definition of _Noreturn is copied here. */
89 /* The definition of _GL_ARG_NONNULL is copied here. */
91 /* The definition of _GL_WARN_ON_USE is copied here. */
94 /* Storage class specifier for thread-local storage. */
96 /* The macro definition from AIX 7.1..7.2 <threads.h> is unusable, because
97 its expansion ends in a semicolon. */
100 #if !@HAVE_THREADS_H@ || !defined thread_local
101 # define thread_local _Thread_local
103 /* Define the macro thread_local if and only if it actually works. */
104 #if !@HAVE_THREAD_LOCAL@
109 /* =========== ISO C 11 7.26.5 Thread functions =========== */
111 #if !@HAVE_THREADS_H@
123 # if defined _WIN32 && ! defined __CYGWIN__
124 /* Use Windows threads. */
126 # include "windows-thread.h"
128 typedef glwthread_thread_t thrd_t
;
131 /* Use POSIX threads. */
133 typedef pthread_t thrd_t
;
139 #if @BROKEN_THRD_START_T@
140 /* Need to override thrd_start_t, to make thrd_create work. */
141 # define thrd_start_t rpl_thrd_start_t
143 #if @BROKEN_THRD_START_T@ || @BROKEN_THRD_JOIN@
144 /* Need to override thrd_t, to make thrd_join work. */
145 struct thrd_with_exitcode
148 int volatile detached
;
149 int volatile exitcode
;
151 typedef struct thrd_with_exitcode
*rpl_thrd_t
;
152 # define thrd_t rpl_thrd_t
154 /* Type of the main function of a thread. */
155 #if !@HAVE_THREADS_H@ || @BROKEN_THRD_START_T@
156 typedef int (* thrd_start_t
) (void *);
160 # if @REPLACE_THRD_CREATE@
161 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
162 # define thrd_create rpl_thrd_create
164 _GL_FUNCDECL_RPL (thrd_create
, int, (thrd_t
*, thrd_start_t
, void *)
165 _GL_ARG_NONNULL ((1, 2)));
166 _GL_CXXALIAS_RPL (thrd_create
, int, (thrd_t
*, thrd_start_t
, void *));
168 # if !@HAVE_THREADS_H@
169 _GL_FUNCDECL_SYS (thrd_create
, int, (thrd_t
*, thrd_start_t
, void *)
170 _GL_ARG_NONNULL ((1, 2)));
172 _GL_CXXALIAS_SYS (thrd_create
, int, (thrd_t
*, thrd_start_t
, void *));
174 _GL_CXXALIASWARN (thrd_create
);
175 #elif defined GNULIB_POSIXCHECK
177 # if HAVE_RAW_DECL_THRD_CREATE
178 _GL_WARN_ON_USE (thrd_create
, "thrd_create is unportable - "
179 "use gnulib module thrd for portability");
184 # if @REPLACE_THRD_CURRENT@
185 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
186 # define thrd_current rpl_thrd_current
188 _GL_FUNCDECL_RPL (thrd_current
, thrd_t
, (void) _GL_ATTRIBUTE_PURE
);
189 _GL_CXXALIAS_RPL (thrd_current
, thrd_t
, (void));
191 # if !@HAVE_THREADS_H@
192 _GL_FUNCDECL_SYS (thrd_current
, thrd_t
, (void) _GL_ATTRIBUTE_PURE
);
194 _GL_CXXALIAS_SYS (thrd_current
, thrd_t
, (void));
196 _GL_CXXALIASWARN (thrd_current
);
197 #elif defined GNULIB_POSIXCHECK
199 # if HAVE_RAW_DECL_THRD_CURRENT
200 _GL_WARN_ON_USE (thrd_current
, "thrd_current is unportable - "
201 "use gnulib module thrd for portability");
206 # if @REPLACE_THRD_EQUAL@
207 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
208 # define thrd_equal rpl_thrd_equal
210 _GL_FUNCDECL_RPL (thrd_equal
, int, (thrd_t
, thrd_t
) _GL_ATTRIBUTE_PURE
);
211 _GL_CXXALIAS_RPL (thrd_equal
, int, (thrd_t
, thrd_t
));
213 # if !@HAVE_THREADS_H@
214 _GL_FUNCDECL_SYS (thrd_equal
, int, (thrd_t
, thrd_t
) _GL_ATTRIBUTE_PURE
);
216 _GL_CXXALIAS_SYS (thrd_equal
, int, (thrd_t
, thrd_t
));
218 _GL_CXXALIASWARN (thrd_equal
);
219 #elif defined GNULIB_POSIXCHECK
221 # if HAVE_RAW_DECL_THRD_EQUAL
222 _GL_WARN_ON_USE (thrd_equal
, "thrd_equal is unportable - "
223 "use gnulib module thrd for portability");
228 # if @REPLACE_THRD_SLEEP@
229 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
230 # define thrd_sleep rpl_thrd_sleep
232 _GL_FUNCDECL_RPL (thrd_sleep
, int,
233 (const struct timespec
*, struct timespec
*)
234 _GL_ARG_NONNULL ((1)));
235 _GL_CXXALIAS_RPL (thrd_sleep
, int,
236 (const struct timespec
*, struct timespec
*));
238 # if !@HAVE_THREADS_H@
239 _GL_FUNCDECL_SYS (thrd_sleep
, int,
240 (const struct timespec
*, struct timespec
*)
241 _GL_ARG_NONNULL ((1)));
243 _GL_CXXALIAS_SYS (thrd_sleep
, int,
244 (const struct timespec
*, struct timespec
*));
246 _GL_CXXALIASWARN (thrd_sleep
);
247 #elif defined GNULIB_POSIXCHECK
249 # if HAVE_RAW_DECL_THRD_SLEEP
250 _GL_WARN_ON_USE (thrd_sleep
, "thrd_sleep is unportable - "
251 "use gnulib module thrd for portability");
256 # if @REPLACE_THRD_YIELD@
257 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
258 # define thrd_yield rpl_thrd_yield
260 _GL_FUNCDECL_RPL (thrd_yield
, void, (void));
261 _GL_CXXALIAS_RPL (thrd_yield
, void, (void));
263 # if !@HAVE_THREADS_H@
264 _GL_FUNCDECL_SYS (thrd_yield
, void, (void));
266 _GL_CXXALIAS_SYS (thrd_yield
, void, (void));
268 _GL_CXXALIASWARN (thrd_yield
);
269 #elif defined GNULIB_POSIXCHECK
271 # if HAVE_RAW_DECL_THRD_YIELD
272 _GL_WARN_ON_USE (thrd_yield
, "thrd_yield is unportable - "
273 "use gnulib module thrd for portability");
278 # if @REPLACE_THRD_DETACH@
279 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
280 # define thrd_detach rpl_thrd_detach
282 _GL_FUNCDECL_RPL (thrd_detach
, int, (thrd_t
));
283 _GL_CXXALIAS_RPL (thrd_detach
, int, (thrd_t
));
285 # if !@HAVE_THREADS_H@
286 _GL_FUNCDECL_SYS (thrd_detach
, int, (thrd_t
));
288 _GL_CXXALIAS_SYS (thrd_detach
, int, (thrd_t
));
290 _GL_CXXALIASWARN (thrd_detach
);
291 #elif defined GNULIB_POSIXCHECK
293 # if HAVE_RAW_DECL_THRD_DETACH
294 _GL_WARN_ON_USE (thrd_detach
, "thrd_detach is unportable - "
295 "use gnulib module thrd for portability");
300 # if @REPLACE_THRD_JOIN@
301 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
302 # define thrd_join rpl_thrd_join
304 _GL_FUNCDECL_RPL (thrd_join
, int, (thrd_t
, int *));
305 _GL_CXXALIAS_RPL (thrd_join
, int, (thrd_t
, int *));
307 # if !@HAVE_THREADS_H@
308 _GL_FUNCDECL_SYS (thrd_join
, int, (thrd_t
, int *));
310 _GL_CXXALIAS_SYS (thrd_join
, int, (thrd_t
, int *));
312 _GL_CXXALIASWARN (thrd_join
);
313 #elif defined GNULIB_POSIXCHECK
315 # if HAVE_RAW_DECL_THRD_JOIN
316 _GL_WARN_ON_USE (thrd_join
, "thrd_join is unportable - "
317 "use gnulib module thrd for portability");
322 # if @REPLACE_THRD_EXIT@
323 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
324 # define thrd_exit rpl_thrd_exit
326 _GL_FUNCDECL_RPL (thrd_exit
, _Noreturn
void, (int));
327 _GL_CXXALIAS_RPL (thrd_exit
, void, (int));
329 # if !@HAVE_THREADS_H@
330 _GL_FUNCDECL_SYS (thrd_exit
, _Noreturn
void, (int));
332 /* Need to cast because of AIX with xlclang++. */
333 _GL_CXXALIAS_SYS_CAST (thrd_exit
, void, (int));
335 _GL_CXXALIASWARN (thrd_exit
);
336 #elif defined GNULIB_POSIXCHECK
338 # if HAVE_RAW_DECL_THRD_EXIT
339 _GL_WARN_ON_USE (thrd_exit
, "thrd_exit is unportable - "
340 "use gnulib module thrd for portability");
345 /* =========== ISO C 11 7.26.4 Mutex functions =========== */
347 #if !@HAVE_THREADS_H@
349 /* Types of mutexes. */
357 # if defined _WIN32 && ! defined __CYGWIN__
358 /* Use Windows threads. */
360 # include "windows-mutex.h"
361 # include "windows-recmutex.h"
362 # include "windows-timedmutex.h"
363 # include "windows-timedrecmutex.h"
370 glwthread_mutex_t u_mutex
;
371 glwthread_recmutex_t u_recmutex
;
372 glwthread_timedmutex_t u_timedmutex
;
373 glwthread_timedrecmutex_t u_timedrecmutex
;
380 /* Use POSIX threads. */
382 typedef pthread_mutex_t mtx_t
;
389 # if @REPLACE_MTX_INIT@
390 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
391 # define mtx_init rpl_mtx_init
393 _GL_FUNCDECL_RPL (mtx_init
, int, (mtx_t
*, int) _GL_ARG_NONNULL ((1)));
394 _GL_CXXALIAS_RPL (mtx_init
, int, (mtx_t
*, int));
396 # if !@HAVE_THREADS_H@
397 _GL_FUNCDECL_SYS (mtx_init
, int, (mtx_t
*, int) _GL_ARG_NONNULL ((1)));
399 _GL_CXXALIAS_SYS (mtx_init
, int, (mtx_t
*, int));
401 _GL_CXXALIASWARN (mtx_init
);
402 #elif defined GNULIB_POSIXCHECK
404 # if HAVE_RAW_DECL_MTX_INIT
405 _GL_WARN_ON_USE (mtx_init
, "mtx_init is unportable - "
406 "use gnulib module mtx for portability");
411 # if @REPLACE_MTX_LOCK@
412 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
413 # define mtx_lock rpl_mtx_lock
415 _GL_FUNCDECL_RPL (mtx_lock
, int, (mtx_t
*) _GL_ARG_NONNULL ((1)));
416 _GL_CXXALIAS_RPL (mtx_lock
, int, (mtx_t
*));
418 # if !@HAVE_THREADS_H@
419 _GL_FUNCDECL_SYS (mtx_lock
, int, (mtx_t
*) _GL_ARG_NONNULL ((1)));
421 _GL_CXXALIAS_SYS (mtx_lock
, int, (mtx_t
*));
423 _GL_CXXALIASWARN (mtx_lock
);
424 #elif defined GNULIB_POSIXCHECK
426 # if HAVE_RAW_DECL_MTX_LOCK
427 _GL_WARN_ON_USE (mtx_lock
, "mtx_lock is unportable - "
428 "use gnulib module mtx for portability");
433 # if @REPLACE_MTX_TRYLOCK@
434 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
435 # define mtx_trylock rpl_mtx_trylock
437 _GL_FUNCDECL_RPL (mtx_trylock
, int, (mtx_t
*) _GL_ARG_NONNULL ((1)));
438 _GL_CXXALIAS_RPL (mtx_trylock
, int, (mtx_t
*));
440 # if !@HAVE_THREADS_H@
441 _GL_FUNCDECL_SYS (mtx_trylock
, int, (mtx_t
*) _GL_ARG_NONNULL ((1)));
443 _GL_CXXALIAS_SYS (mtx_trylock
, int, (mtx_t
*));
445 _GL_CXXALIASWARN (mtx_trylock
);
446 #elif defined GNULIB_POSIXCHECK
448 # if HAVE_RAW_DECL_MTX_TRYLOCK
449 _GL_WARN_ON_USE (mtx_trylock
, "mtx_trylock is unportable - "
450 "use gnulib module mtx for portability");
455 # if @REPLACE_MTX_TIMEDLOCK@
456 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
457 # define mtx_timedlock rpl_mtx_timedlock
459 _GL_FUNCDECL_RPL (mtx_timedlock
, int, (mtx_t
*, const struct timespec
*)
460 _GL_ARG_NONNULL ((1, 2)));
461 _GL_CXXALIAS_RPL (mtx_timedlock
, int, (mtx_t
*, const struct timespec
*));
463 # if !@HAVE_THREADS_H@
464 _GL_FUNCDECL_SYS (mtx_timedlock
, int, (mtx_t
*, const struct timespec
*)
465 _GL_ARG_NONNULL ((1, 2)));
467 _GL_CXXALIAS_SYS (mtx_timedlock
, int, (mtx_t
*, const struct timespec
*));
469 _GL_CXXALIASWARN (mtx_timedlock
);
470 #elif defined GNULIB_POSIXCHECK
471 # undef mtx_timedlock
472 # if HAVE_RAW_DECL_MTX_TIMEDLOCK
473 _GL_WARN_ON_USE (mtx_timedlock
, "mtx_timedlock is unportable - "
474 "use gnulib module mtx for portability");
479 # if @REPLACE_MTX_UNLOCK@
480 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
481 # define mtx_unlock rpl_mtx_unlock
483 _GL_FUNCDECL_RPL (mtx_unlock
, int, (mtx_t
*) _GL_ARG_NONNULL ((1)));
484 _GL_CXXALIAS_RPL (mtx_unlock
, int, (mtx_t
*));
486 # if !@HAVE_THREADS_H@
487 _GL_FUNCDECL_SYS (mtx_unlock
, int, (mtx_t
*) _GL_ARG_NONNULL ((1)));
489 _GL_CXXALIAS_SYS (mtx_unlock
, int, (mtx_t
*));
491 _GL_CXXALIASWARN (mtx_unlock
);
492 #elif defined GNULIB_POSIXCHECK
494 # if HAVE_RAW_DECL_MTX_UNLOCK
495 _GL_WARN_ON_USE (mtx_unlock
, "mtx_unlock is unportable - "
496 "use gnulib module mtx for portability");
501 # if @REPLACE_MTX_DESTROY@
502 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
503 # define mtx_destroy rpl_mtx_destroy
505 _GL_FUNCDECL_RPL (mtx_destroy
, void, (mtx_t
*) _GL_ARG_NONNULL ((1)));
506 _GL_CXXALIAS_RPL (mtx_destroy
, void, (mtx_t
*));
508 # if !@HAVE_THREADS_H@
509 _GL_FUNCDECL_SYS (mtx_destroy
, void, (mtx_t
*) _GL_ARG_NONNULL ((1)));
511 _GL_CXXALIAS_SYS (mtx_destroy
, void, (mtx_t
*));
513 _GL_CXXALIASWARN (mtx_destroy
);
514 #elif defined GNULIB_POSIXCHECK
516 # if HAVE_RAW_DECL_MTX_DESTROY
517 _GL_WARN_ON_USE (mtx_destroy
, "mtx_destroy is unportable - "
518 "use gnulib module mtx for portability");
523 /* =========== ISO C 11 7.26.2 Initialization functions =========== */
525 #if !@HAVE_THREADS_H@
527 /* Type that contains a flag for use by call_once. */
528 # if defined _WIN32 && ! defined __CYGWIN__
529 /* Use Windows threads. */
531 # include "windows-once.h"
533 typedef glwthread_once_t once_flag
;
534 # define ONCE_FLAG_INIT GLWTHREAD_ONCE_INIT
537 /* Use POSIX threads. */
539 typedef pthread_once_t once_flag
;
540 # define ONCE_FLAG_INIT PTHREAD_ONCE_INIT
546 #if @GNULIB_CALL_ONCE@
547 # if @REPLACE_CALL_ONCE@
548 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
549 # define call_once rpl_call_once
551 _GL_FUNCDECL_RPL (call_once
, void, (once_flag
*, void (*) (void))
552 _GL_ARG_NONNULL ((1, 2)));
553 _GL_CXXALIAS_RPL (call_once
, void, (once_flag
*, void (*) (void)));
555 # if !@HAVE_THREADS_H@
556 _GL_FUNCDECL_SYS (call_once
, void, (once_flag
*, void (*) (void))
557 _GL_ARG_NONNULL ((1, 2)));
559 _GL_CXXALIAS_SYS_CAST (call_once
, void, (once_flag
*, void (*) (void)));
561 _GL_CXXALIASWARN (call_once
);
562 #elif defined GNULIB_POSIXCHECK
564 # if HAVE_RAW_DECL_CALL_ONCE
565 _GL_WARN_ON_USE (call_once
, "call_once is unportable - "
566 "use gnulib module call_once for portability");
571 /* =========== ISO C 11 7.26.3 Condition variable functions =========== */
573 #if !@HAVE_THREADS_H@
575 # if defined _WIN32 && ! defined __CYGWIN__
576 /* Use Windows threads. */
578 # include "windows-cond.h"
580 typedef glwthread_cond_t cnd_t
;
583 /* Use POSIX threads. */
585 typedef pthread_cond_t cnd_t
;
592 # if @REPLACE_CND_INIT@
593 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
594 # define cnd_init rpl_cnd_init
596 _GL_FUNCDECL_RPL (cnd_init
, int, (cnd_t
*) _GL_ARG_NONNULL ((1)));
597 _GL_CXXALIAS_RPL (cnd_init
, int, (cnd_t
*));
599 # if !@HAVE_THREADS_H@
600 _GL_FUNCDECL_SYS (cnd_init
, int, (cnd_t
*) _GL_ARG_NONNULL ((1)));
602 _GL_CXXALIAS_SYS (cnd_init
, int, (cnd_t
*));
604 _GL_CXXALIASWARN (cnd_init
);
605 #elif defined GNULIB_POSIXCHECK
607 # if HAVE_RAW_DECL_CND_INIT
608 _GL_WARN_ON_USE (cnd_init
, "cnd_init is unportable - "
609 "use gnulib module cnd for portability");
614 # if @REPLACE_CND_WAIT@
615 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
616 # define cnd_wait rpl_cnd_wait
618 _GL_FUNCDECL_RPL (cnd_wait
, int, (cnd_t
*, mtx_t
*) _GL_ARG_NONNULL ((1, 2)));
619 _GL_CXXALIAS_RPL (cnd_wait
, int, (cnd_t
*, mtx_t
*));
621 # if !@HAVE_THREADS_H@
622 _GL_FUNCDECL_SYS (cnd_wait
, int, (cnd_t
*, mtx_t
*) _GL_ARG_NONNULL ((1, 2)));
624 _GL_CXXALIAS_SYS (cnd_wait
, int, (cnd_t
*, mtx_t
*));
626 _GL_CXXALIASWARN (cnd_wait
);
627 #elif defined GNULIB_POSIXCHECK
629 # if HAVE_RAW_DECL_CND_WAIT
630 _GL_WARN_ON_USE (cnd_wait
, "cnd_wait is unportable - "
631 "use gnulib module cnd for portability");
636 # if @REPLACE_CND_TIMEDWAIT@
637 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
638 # define cnd_timedwait rpl_cnd_timedwait
640 _GL_FUNCDECL_RPL (cnd_timedwait
, int,
641 (cnd_t
*, mtx_t
*, const struct timespec
*)
642 _GL_ARG_NONNULL ((1, 2, 3)));
643 _GL_CXXALIAS_RPL (cnd_timedwait
, int,
644 (cnd_t
*, mtx_t
*, const struct timespec
*));
646 # if !@HAVE_THREADS_H@
647 _GL_FUNCDECL_SYS (cnd_timedwait
, int,
648 (cnd_t
*, mtx_t
*, const struct timespec
*)
649 _GL_ARG_NONNULL ((1, 2, 3)));
651 _GL_CXXALIAS_SYS (cnd_timedwait
, int,
652 (cnd_t
*, mtx_t
*, const struct timespec
*));
654 _GL_CXXALIASWARN (cnd_timedwait
);
655 #elif defined GNULIB_POSIXCHECK
656 # undef cnd_timedwait
657 # if HAVE_RAW_DECL_CND_TIMEDWAIT
658 _GL_WARN_ON_USE (cnd_timedwait
, "cnd_timedwait is unportable - "
659 "use gnulib module cnd for portability");
664 # if @REPLACE_CND_SIGNAL@
665 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
666 # define cnd_signal rpl_cnd_signal
668 _GL_FUNCDECL_RPL (cnd_signal
, int, (cnd_t
*) _GL_ARG_NONNULL ((1)));
669 _GL_CXXALIAS_RPL (cnd_signal
, int, (cnd_t
*));
671 # if !@HAVE_THREADS_H@
672 _GL_FUNCDECL_SYS (cnd_signal
, int, (cnd_t
*) _GL_ARG_NONNULL ((1)));
674 _GL_CXXALIAS_SYS (cnd_signal
, int, (cnd_t
*));
676 _GL_CXXALIASWARN (cnd_signal
);
677 #elif defined GNULIB_POSIXCHECK
679 # if HAVE_RAW_DECL_CND_SIGNAL
680 _GL_WARN_ON_USE (cnd_signal
, "cnd_signal is unportable - "
681 "use gnulib module cnd for portability");
686 # if @REPLACE_CND_BROADCAST@
687 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
688 # define cnd_broadcast rpl_cnd_broadcast
690 _GL_FUNCDECL_RPL (cnd_broadcast
, int, (cnd_t
*) _GL_ARG_NONNULL ((1)));
691 _GL_CXXALIAS_RPL (cnd_broadcast
, int, (cnd_t
*));
693 # if !@HAVE_THREADS_H@
694 _GL_FUNCDECL_SYS (cnd_broadcast
, int, (cnd_t
*) _GL_ARG_NONNULL ((1)));
696 _GL_CXXALIAS_SYS (cnd_broadcast
, int, (cnd_t
*));
698 _GL_CXXALIASWARN (cnd_broadcast
);
699 #elif defined GNULIB_POSIXCHECK
700 # undef cnd_broadcast
701 # if HAVE_RAW_DECL_CND_BROADCAST
702 _GL_WARN_ON_USE (cnd_broadcast
, "cnd_broadcast is unportable - "
703 "use gnulib module cnd for portability");
708 # if @REPLACE_CND_DESTROY@
709 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
710 # define cnd_destroy rpl_cnd_destroy
712 _GL_FUNCDECL_RPL (cnd_destroy
, void, (cnd_t
*) _GL_ARG_NONNULL ((1)));
713 _GL_CXXALIAS_RPL (cnd_destroy
, void, (cnd_t
*));
715 # if !@HAVE_THREADS_H@
716 _GL_FUNCDECL_SYS (cnd_destroy
, void, (cnd_t
*) _GL_ARG_NONNULL ((1)));
718 _GL_CXXALIAS_SYS (cnd_destroy
, void, (cnd_t
*));
720 _GL_CXXALIASWARN (cnd_destroy
);
721 #elif defined GNULIB_POSIXCHECK
723 # if HAVE_RAW_DECL_CND_DESTROY
724 _GL_WARN_ON_USE (cnd_destroy
, "cnd_destroy is unportable - "
725 "use gnulib module cnd for portability");
730 /* =========== ISO C 11 7.26.6 Thread-specific storage functions =========== */
732 #if !@HAVE_THREADS_H@
734 # if defined _WIN32 && ! defined __CYGWIN__
735 /* Use Windows threads. */
737 # include "windows-tls.h"
739 typedef glwthread_tls_key_t tss_t
;
740 # define TSS_DTOR_ITERATIONS GLWTHREAD_DESTRUCTOR_ITERATIONS
743 /* Use POSIX threads. */
747 typedef pthread_key_t tss_t
;
751 /* Type for the destructor of a thread-specific storage pointer. */
752 typedef void (*tss_dtor_t
) (void *);
756 /* AIX 7.1 <threads.h> does not define TSS_DTOR_ITERATIONS. */
757 #ifndef TSS_DTOR_ITERATIONS
758 # ifdef PTHREAD_DESTRUCTOR_ITERATIONS
759 # define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS
761 /* IRIX 6.5 does not define PTHREAD_DESTRUCTOR_ITERATIONS.
762 This value is a wild guess. */
763 # define TSS_DTOR_ITERATIONS 1
768 # if @REPLACE_TSS_CREATE@
769 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
770 # define tss_create rpl_tss_create
772 _GL_FUNCDECL_RPL (tss_create
, int, (tss_t
*, tss_dtor_t
) _GL_ARG_NONNULL ((1)));
773 _GL_CXXALIAS_RPL (tss_create
, int, (tss_t
*, tss_dtor_t
));
775 # if !@HAVE_THREADS_H@
776 _GL_FUNCDECL_SYS (tss_create
, int, (tss_t
*, tss_dtor_t
) _GL_ARG_NONNULL ((1)));
778 _GL_CXXALIAS_SYS (tss_create
, int, (tss_t
*, tss_dtor_t
));
780 _GL_CXXALIASWARN (tss_create
);
781 #elif defined GNULIB_POSIXCHECK
783 # if HAVE_RAW_DECL_TSS_CREATE
784 _GL_WARN_ON_USE (tss_create
, "tss_create is unportable - "
785 "use gnulib module tss for portability");
790 # if @REPLACE_TSS_SET@
791 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
792 # define tss_set rpl_tss_set
794 _GL_FUNCDECL_RPL (tss_set
, int, (tss_t
, void *));
795 _GL_CXXALIAS_RPL (tss_set
, int, (tss_t
, void *));
797 # if !@HAVE_THREADS_H@
798 _GL_FUNCDECL_SYS (tss_set
, int, (tss_t
, void *));
800 _GL_CXXALIAS_SYS (tss_set
, int, (tss_t
, void *));
802 _GL_CXXALIASWARN (tss_set
);
803 #elif defined GNULIB_POSIXCHECK
805 # if HAVE_RAW_DECL_TSS_SET
806 _GL_WARN_ON_USE (tss_set
, "tss_set is unportable - "
807 "use gnulib module tss for portability");
812 # if @REPLACE_TSS_GET@
813 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
814 # define tss_get rpl_tss_get
816 _GL_FUNCDECL_RPL (tss_get
, void *, (tss_t
));
817 _GL_CXXALIAS_RPL (tss_get
, void *, (tss_t
));
819 # if !@HAVE_THREADS_H@
820 _GL_FUNCDECL_SYS (tss_get
, void *, (tss_t
));
822 _GL_CXXALIAS_SYS (tss_get
, void *, (tss_t
));
824 _GL_CXXALIASWARN (tss_get
);
825 #elif defined GNULIB_POSIXCHECK
827 # if HAVE_RAW_DECL_TSS_GET
828 _GL_WARN_ON_USE (tss_get
, "tss_get is unportable - "
829 "use gnulib module tss for portability");
834 # if @REPLACE_TSS_DELETE@
835 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
836 # define tss_delete rpl_tss_delete
838 _GL_FUNCDECL_RPL (tss_delete
, void, (tss_t
));
839 _GL_CXXALIAS_RPL (tss_delete
, void, (tss_t
));
841 # if !@HAVE_THREADS_H@
842 _GL_FUNCDECL_SYS (tss_delete
, void, (tss_t
));
844 _GL_CXXALIAS_SYS (tss_delete
, void, (tss_t
));
846 _GL_CXXALIASWARN (tss_delete
);
847 #elif defined GNULIB_POSIXCHECK
849 # if HAVE_RAW_DECL_TSS_DELETE
850 _GL_WARN_ON_USE (tss_delete
, "tss_delete is unportable - "
851 "use gnulib module tss for portability");
856 #endif /* _@GUARD_PREFIX@_THREADS_H */
857 #endif /* _@GUARD_PREFIX@_THREADS_H */