Move all files into ports/ subdirectory in preparation for merge with glibc
[glibc.git] / ports / sysdeps / unix / sysv / linux / hppa / nptl / pthread.h
blob6a0d953545513a02f56d9211c1667309827e2875
1 /* Copyright (C) 2002-2011, 2012 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library 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 GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #ifndef _PTHREAD_H
19 #define _PTHREAD_H 1
21 #include <features.h>
22 #include <endian.h>
23 #include <sched.h>
24 #define __need_timespec
25 #include <time.h>
27 #include <bits/pthreadtypes.h>
28 #include <bits/setjmp.h>
29 #include <bits/wordsize.h>
32 /* Detach state. */
33 enum
35 PTHREAD_CREATE_JOINABLE,
36 #define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
37 PTHREAD_CREATE_DETACHED
38 #define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
42 /* Mutex types. */
43 enum
45 PTHREAD_MUTEX_TIMED_NP,
46 PTHREAD_MUTEX_RECURSIVE_NP,
47 PTHREAD_MUTEX_ERRORCHECK_NP,
48 PTHREAD_MUTEX_ADAPTIVE_NP
49 #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
51 PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
52 PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
53 PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
54 PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
55 #endif
56 #ifdef __USE_GNU
57 /* For compatibility. */
58 , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
59 #endif
63 #ifdef __USE_XOPEN2K
64 /* Robust mutex or not flags. */
65 enum
67 PTHREAD_MUTEX_STALLED,
68 PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
69 PTHREAD_MUTEX_ROBUST,
70 PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
72 #endif
75 #if defined __USE_POSIX199506 || defined __USE_UNIX98
76 /* Mutex protocols. */
77 enum
79 PTHREAD_PRIO_NONE,
80 PTHREAD_PRIO_INHERIT,
81 PTHREAD_PRIO_PROTECT
83 #endif
86 /* Mutex initializers. */
87 #if __WORDSIZE == 64
88 # define PTHREAD_MUTEX_INITIALIZER \
89 { { 0, 0, 0, 0, 0, 0, { 0, 0 } } }
90 # ifdef __USE_GNU
91 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
92 { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { 0, 0 } } }
93 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
94 { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { 0, 0 } } }
95 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
96 { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { 0, 0 } } }
97 # endif
98 #else
99 # define PTHREAD_MUTEX_INITIALIZER \
100 { { 0, 0, 0, 0, 0, { 0 } } }
101 # ifdef __USE_GNU
102 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
103 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { 0 } } }
104 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
105 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { 0 } } }
106 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
107 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { 0 } } }
108 # endif
109 #endif
112 /* Read-write lock types. */
113 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
114 enum
116 PTHREAD_RWLOCK_PREFER_READER_NP,
117 PTHREAD_RWLOCK_PREFER_WRITER_NP,
118 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
119 PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
122 /* Read-write lock initializers. */
123 # define PTHREAD_RWLOCK_INITIALIZER \
124 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
125 # ifdef __USE_GNU
126 # if __WORDSIZE == 64
127 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
128 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
129 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
130 # else
131 # if __BYTE_ORDER == __LITTLE_ENDIAN
132 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
133 { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \
134 0, 0, 0, 0 } }
135 # else
136 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
137 { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\
138 0 } }
139 # endif
140 # endif
141 # endif
142 #endif /* Unix98 or XOpen2K */
145 /* Scheduler inheritance. */
146 enum
148 PTHREAD_INHERIT_SCHED,
149 #define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
150 PTHREAD_EXPLICIT_SCHED
151 #define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
155 /* Scope handling. */
156 enum
158 PTHREAD_SCOPE_SYSTEM,
159 #define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
160 PTHREAD_SCOPE_PROCESS
161 #define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
165 /* Process shared or private flag. */
166 enum
168 PTHREAD_PROCESS_PRIVATE,
169 #define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
170 PTHREAD_PROCESS_SHARED
171 #define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
176 /* Conditional variable handling. */
177 #define PTHREAD_COND_INITIALIZER { { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }
180 /* Cleanup buffers */
181 struct _pthread_cleanup_buffer
183 void (*__routine) (void *); /* Function to call. */
184 void *__arg; /* Its argument. */
185 int __canceltype; /* Saved cancellation type. */
186 struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions. */
189 /* Cancellation */
190 enum
192 PTHREAD_CANCEL_ENABLE,
193 #define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
194 PTHREAD_CANCEL_DISABLE
195 #define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
197 enum
199 PTHREAD_CANCEL_DEFERRED,
200 #define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
201 PTHREAD_CANCEL_ASYNCHRONOUS
202 #define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
204 #define PTHREAD_CANCELED ((void *) -1)
207 /* Single execution handling. */
208 #define PTHREAD_ONCE_INIT 0
211 #ifdef __USE_XOPEN2K
212 /* Value returned by 'pthread_barrier_wait' for one of the threads after
213 the required number of threads have called this function.
214 -1 is distinct from 0 and all errno constants */
215 # define PTHREAD_BARRIER_SERIAL_THREAD -1
216 #endif
219 __BEGIN_DECLS
221 /* Create a new thread, starting with execution of START-ROUTINE
222 getting passed ARG. Creation attributed come from ATTR. The new
223 handle is stored in *NEWTHREAD. */
224 extern int pthread_create (pthread_t *__restrict __newthread,
225 const pthread_attr_t *__restrict __attr,
226 void *(*__start_routine) (void *),
227 void *__restrict __arg) __THROWNL __nonnull ((1, 3));
229 /* Terminate calling thread.
231 The registered cleanup handlers are called via exception handling
232 so we cannot mark this function with __THROW.*/
233 extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
235 /* Make calling thread wait for termination of the thread TH. The
236 exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
237 is not NULL.
239 This function is a cancellation point and therefore not marked with
240 __THROW. */
241 extern int pthread_join (pthread_t __th, void **__thread_return);
243 #ifdef __USE_GNU
244 /* Check whether thread TH has terminated. If yes return the status of
245 the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */
246 extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
248 /* Make calling thread wait for termination of the thread TH, but only
249 until TIMEOUT. The exit status of the thread is stored in
250 *THREAD_RETURN, if THREAD_RETURN is not NULL.
252 This function is a cancellation point and therefore not marked with
253 __THROW. */
254 extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
255 const struct timespec *__abstime);
256 #endif
258 /* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
259 The resources of TH will therefore be freed immediately when it
260 terminates, instead of waiting for another thread to perform PTHREAD_JOIN
261 on it. */
262 extern int pthread_detach (pthread_t __th) __THROW;
265 /* Obtain the identifier of the current thread. */
266 extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__));
268 /* Compare two thread identifiers. */
269 extern int pthread_equal (pthread_t __thread1, pthread_t __thread2)
270 __THROW __attribute__ ((__const__));
273 /* Thread attribute handling. */
275 /* Initialize thread attribute *ATTR with default attributes
276 (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
277 no user-provided stack). */
278 extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1));
280 /* Destroy thread attribute *ATTR. */
281 extern int pthread_attr_destroy (pthread_attr_t *__attr)
282 __THROW __nonnull ((1));
284 /* Get detach state attribute. */
285 extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr,
286 int *__detachstate)
287 __THROW __nonnull ((1, 2));
289 /* Set detach state attribute. */
290 extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
291 int __detachstate)
292 __THROW __nonnull ((1));
295 /* Get the size of the guard area created for stack overflow protection. */
296 extern int pthread_attr_getguardsize (const pthread_attr_t *__attr,
297 size_t *__guardsize)
298 __THROW __nonnull ((1, 2));
300 /* Set the size of the guard area created for stack overflow protection. */
301 extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
302 size_t __guardsize)
303 __THROW __nonnull ((1));
306 /* Return in *PARAM the scheduling parameters of *ATTR. */
307 extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr,
308 struct sched_param *__restrict __param)
309 __THROW __nonnull ((1, 2));
311 /* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */
312 extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
313 const struct sched_param *__restrict
314 __param) __THROW __nonnull ((1, 2));
316 /* Return in *POLICY the scheduling policy of *ATTR. */
317 extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict
318 __attr, int *__restrict __policy)
319 __THROW __nonnull ((1, 2));
321 /* Set scheduling policy in *ATTR according to POLICY. */
322 extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
323 __THROW __nonnull ((1));
325 /* Return in *INHERIT the scheduling inheritance mode of *ATTR. */
326 extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict
327 __attr, int *__restrict __inherit)
328 __THROW __nonnull ((1, 2));
330 /* Set scheduling inheritance mode in *ATTR according to INHERIT. */
331 extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
332 int __inherit)
333 __THROW __nonnull ((1));
336 /* Return in *SCOPE the scheduling contention scope of *ATTR. */
337 extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
338 int *__restrict __scope)
339 __THROW __nonnull ((1, 2));
341 /* Set scheduling contention scope in *ATTR according to SCOPE. */
342 extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
343 __THROW __nonnull ((1));
345 /* Return the previously set address for the stack. */
346 extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict
347 __attr, void **__restrict __stackaddr)
348 __THROW __nonnull ((1, 2)) __attribute_deprecated__;
350 /* Set the starting address of the stack of the thread to be created.
351 Depending on whether the stack grows up or down the value must either
352 be higher or lower than all the address in the memory block. The
353 minimal size of the block must be PTHREAD_STACK_MIN. */
354 extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
355 void *__stackaddr)
356 __THROW __nonnull ((1)) __attribute_deprecated__;
358 /* Return the currently used minimal stack size. */
359 extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
360 __attr, size_t *__restrict __stacksize)
361 __THROW __nonnull ((1, 2));
363 /* Add information about the minimum stack size needed for the thread
364 to be started. This size must never be less than PTHREAD_STACK_MIN
365 and must also not exceed the system limits. */
366 extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
367 size_t __stacksize)
368 __THROW __nonnull ((1));
370 #ifdef __USE_XOPEN2K
371 /* Return the previously set address for the stack. */
372 extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
373 void **__restrict __stackaddr,
374 size_t *__restrict __stacksize)
375 __THROW __nonnull ((1, 2, 3));
377 /* The following two interfaces are intended to replace the last two. They
378 require setting the address as well as the size since only setting the
379 address will make the implementation on some architectures impossible. */
380 extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
381 size_t __stacksize) __THROW __nonnull ((1));
382 #endif
384 #ifdef __USE_GNU
385 /* Thread created with attribute ATTR will be limited to run only on
386 the processors represented in CPUSET. */
387 extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
388 size_t __cpusetsize,
389 const cpu_set_t *__cpuset)
390 __THROW __nonnull ((1, 3));
392 /* Get bit set in CPUSET representing the processors threads created with
393 ATTR can run on. */
394 extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr,
395 size_t __cpusetsize,
396 cpu_set_t *__cpuset)
397 __THROW __nonnull ((1, 3));
400 /* Initialize thread attribute *ATTR with attributes corresponding to the
401 already running thread TH. It shall be called on uninitialized ATTR
402 and destroyed with pthread_attr_destroy when no longer needed. */
403 extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr)
404 __THROW __nonnull ((2));
405 #endif
408 /* Functions for scheduling control. */
410 /* Set the scheduling parameters for TARGET_THREAD according to POLICY
411 and *PARAM. */
412 extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
413 const struct sched_param *__param)
414 __THROW __nonnull ((3));
416 /* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
417 extern int pthread_getschedparam (pthread_t __target_thread,
418 int *__restrict __policy,
419 struct sched_param *__restrict __param)
420 __THROW __nonnull ((2, 3));
422 /* Set the scheduling priority for TARGET_THREAD. */
423 extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
424 __THROW;
427 #ifdef __USE_GNU
428 /* Get thread name visible in the kernel and its interfaces. */
429 extern int pthread_getname_np (pthread_t __target_thread, char *__buf,
430 size_t __buflen)
431 __THROW __nonnull ((2));
433 /* Set thread name visible in the kernel and its interfaces. */
434 extern int pthread_setname_np (pthread_t __target_thread, const char *__name)
435 __THROW __nonnull ((2));
436 #endif
439 #ifdef __USE_UNIX98
440 /* Determine level of concurrency. */
441 extern int pthread_getconcurrency (void) __THROW;
443 /* Set new concurrency level to LEVEL. */
444 extern int pthread_setconcurrency (int __level) __THROW;
445 #endif
447 #ifdef __USE_GNU
448 /* Yield the processor to another thread or process.
449 This function is similar to the POSIX `sched_yield' function but
450 might be differently implemented in the case of a m-on-n thread
451 implementation. */
452 extern int pthread_yield (void) __THROW;
455 /* Limit specified thread TH to run only on the processors represented
456 in CPUSET. */
457 extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize,
458 const cpu_set_t *__cpuset)
459 __THROW __nonnull ((3));
461 /* Get bit set in CPUSET representing the processors TH can run on. */
462 extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize,
463 cpu_set_t *__cpuset)
464 __THROW __nonnull ((3));
465 #endif
468 /* Functions for handling initialization. */
470 /* Guarantee that the initialization function INIT_ROUTINE will be called
471 only once, even if pthread_once is executed several times with the
472 same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or
473 extern variable initialized to PTHREAD_ONCE_INIT.
475 The initialization functions might throw exception which is why
476 this function is not marked with __THROW. */
477 extern int pthread_once (pthread_once_t *__once_control,
478 void (*__init_routine) (void)) __nonnull ((1, 2));
481 /* Functions for handling cancellation.
483 Note that these functions are explicitly not marked to not throw an
484 exception in C++ code. If cancellation is implemented by unwinding
485 this is necessary to have the compiler generate the unwind information. */
487 /* Set cancelability state of current thread to STATE, returning old
488 state in *OLDSTATE if OLDSTATE is not NULL. */
489 extern int pthread_setcancelstate (int __state, int *__oldstate);
491 /* Set cancellation state of current thread to TYPE, returning the old
492 type in *OLDTYPE if OLDTYPE is not NULL. */
493 extern int pthread_setcanceltype (int __type, int *__oldtype);
495 /* Cancel THREAD immediately or at the next possibility. */
496 extern int pthread_cancel (pthread_t __th);
498 /* Test for pending cancellation for the current thread and terminate
499 the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
500 cancelled. */
501 extern void pthread_testcancel (void);
504 /* Cancellation handling with integration into exception handling. */
506 typedef struct
508 struct
510 __jmp_buf __cancel_jmp_buf;
511 int __mask_was_saved;
512 } __cancel_jmp_buf[1];
513 void *__pad[4];
514 } __pthread_unwind_buf_t __attribute__ ((__aligned__));
516 /* No special attributes by default. */
517 #ifndef __cleanup_fct_attribute
518 # define __cleanup_fct_attribute
519 #endif
522 /* Structure to hold the cleanup handler information. */
523 struct __pthread_cleanup_frame
525 void (*__cancel_routine) (void *);
526 void *__cancel_arg;
527 int __do_it;
528 int __cancel_type;
531 #if defined __GNUC__ && defined __EXCEPTIONS
532 # ifdef __cplusplus
533 /* Class to handle cancellation handler invocation. */
534 class __pthread_cleanup_class
536 void (*__cancel_routine) (void *);
537 void *__cancel_arg;
538 int __do_it;
539 int __cancel_type;
541 public:
542 __pthread_cleanup_class (void (*__fct) (void *), void *__arg)
543 : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { }
544 ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); }
545 void __setdoit (int __newval) { __do_it = __newval; }
546 void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,
547 &__cancel_type); }
548 void __restore () const { pthread_setcanceltype (__cancel_type, 0); }
551 /* Install a cleanup handler: ROUTINE will be called with arguments ARG
552 when the thread is canceled or calls pthread_exit. ROUTINE will also
553 be called with arguments ARG when the matching pthread_cleanup_pop
554 is executed with non-zero EXECUTE argument.
556 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
557 be used in matching pairs at the same nesting level of braces. */
558 # define pthread_cleanup_push(routine, arg) \
559 do { \
560 __pthread_cleanup_class __clframe (routine, arg)
562 /* Remove a cleanup handler installed by the matching pthread_cleanup_push.
563 If EXECUTE is non-zero, the handler function is called. */
564 # define pthread_cleanup_pop(execute) \
565 __clframe.__setdoit (execute); \
566 } while (0)
568 # ifdef __USE_GNU
569 /* Install a cleanup handler as pthread_cleanup_push does, but also
570 saves the current cancellation type and sets it to deferred
571 cancellation. */
572 # define pthread_cleanup_push_defer_np(routine, arg) \
573 do { \
574 __pthread_cleanup_class __clframe (routine, arg); \
575 __clframe.__defer ()
577 /* Remove a cleanup handler as pthread_cleanup_pop does, but also
578 restores the cancellation type that was in effect when the matching
579 pthread_cleanup_push_defer was called. */
580 # define pthread_cleanup_pop_restore_np(execute) \
581 __clframe.__restore (); \
582 __clframe.__setdoit (execute); \
583 } while (0)
584 # endif
585 # else
586 /* Function called to call the cleanup handler. As an extern inline
587 function the compiler is free to decide inlining the change when
588 needed or fall back on the copy which must exist somewhere
589 else. */
590 __extern_inline void
591 __pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
593 if (__frame->__do_it)
594 __frame->__cancel_routine (__frame->__cancel_arg);
597 /* Install a cleanup handler: ROUTINE will be called with arguments ARG
598 when the thread is canceled or calls pthread_exit. ROUTINE will also
599 be called with arguments ARG when the matching pthread_cleanup_pop
600 is executed with non-zero EXECUTE argument.
602 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
603 be used in matching pairs at the same nesting level of braces. */
604 # define pthread_cleanup_push(routine, arg) \
605 do { \
606 struct __pthread_cleanup_frame __clframe \
607 __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
608 = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
609 .__do_it = 1 };
611 /* Remove a cleanup handler installed by the matching pthread_cleanup_push.
612 If EXECUTE is non-zero, the handler function is called. */
613 # define pthread_cleanup_pop(execute) \
614 __clframe.__do_it = (execute); \
615 } while (0)
617 # ifdef __USE_GNU
618 /* Install a cleanup handler as pthread_cleanup_push does, but also
619 saves the current cancellation type and sets it to deferred
620 cancellation. */
621 # define pthread_cleanup_push_defer_np(routine, arg) \
622 do { \
623 struct __pthread_cleanup_frame __clframe \
624 __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
625 = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
626 .__do_it = 1 }; \
627 (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, \
628 &__clframe.__cancel_type)
630 /* Remove a cleanup handler as pthread_cleanup_pop does, but also
631 restores the cancellation type that was in effect when the matching
632 pthread_cleanup_push_defer was called. */
633 # define pthread_cleanup_pop_restore_np(execute) \
634 (void) pthread_setcanceltype (__clframe.__cancel_type, NULL); \
635 __clframe.__do_it = (execute); \
636 } while (0)
637 # endif
638 # endif
639 #else
640 /* Install a cleanup handler: ROUTINE will be called with arguments ARG
641 when the thread is canceled or calls pthread_exit. ROUTINE will also
642 be called with arguments ARG when the matching pthread_cleanup_pop
643 is executed with non-zero EXECUTE argument.
645 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
646 be used in matching pairs at the same nesting level of braces. */
647 # define pthread_cleanup_push(routine, arg) \
648 do { \
649 __pthread_unwind_buf_t __cancel_buf; \
650 void (*__cancel_routine) (void *) = (routine); \
651 void *__cancel_arg = (arg); \
652 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
653 __cancel_buf.__cancel_jmp_buf, 0); \
654 if (__builtin_expect (__not_first_call, 0)) \
656 __cancel_routine (__cancel_arg); \
657 __pthread_unwind_next (&__cancel_buf); \
658 /* NOTREACHED */ \
661 __pthread_register_cancel (&__cancel_buf); \
662 do {
663 extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
664 __cleanup_fct_attribute;
666 /* Remove a cleanup handler installed by the matching pthread_cleanup_push.
667 If EXECUTE is non-zero, the handler function is called. */
668 # define pthread_cleanup_pop(execute) \
669 do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
670 } while (0); \
671 __pthread_unregister_cancel (&__cancel_buf); \
672 if (execute) \
673 __cancel_routine (__cancel_arg); \
674 } while (0)
675 extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
676 __cleanup_fct_attribute;
678 # ifdef __USE_GNU
679 /* Install a cleanup handler as pthread_cleanup_push does, but also
680 saves the current cancellation type and sets it to deferred
681 cancellation. */
682 # define pthread_cleanup_push_defer_np(routine, arg) \
683 do { \
684 __pthread_unwind_buf_t __cancel_buf; \
685 void (*__cancel_routine) (void *) = (routine); \
686 void *__cancel_arg = (arg); \
687 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
688 __cancel_buf.__cancel_jmp_buf, 0); \
689 if (__builtin_expect (__not_first_call, 0)) \
691 __cancel_routine (__cancel_arg); \
692 __pthread_unwind_next (&__cancel_buf); \
693 /* NOTREACHED */ \
696 __pthread_register_cancel_defer (&__cancel_buf); \
697 do {
698 extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf)
699 __cleanup_fct_attribute;
701 /* Remove a cleanup handler as pthread_cleanup_pop does, but also
702 restores the cancellation type that was in effect when the matching
703 pthread_cleanup_push_defer was called. */
704 # define pthread_cleanup_pop_restore_np(execute) \
705 do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
706 } while (0); \
707 __pthread_unregister_cancel_restore (&__cancel_buf); \
708 if (execute) \
709 __cancel_routine (__cancel_arg); \
710 } while (0)
711 extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf)
712 __cleanup_fct_attribute;
713 # endif
715 /* Internal interface to initiate cleanup. */
716 extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
717 __cleanup_fct_attribute __attribute__ ((__noreturn__))
718 # ifndef SHARED
719 __attribute__ ((__weak__))
720 # endif
722 #endif
724 /* Function used in the macros. */
725 struct __jmp_buf_tag;
726 extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROW;
729 /* Mutex handling. */
731 /* Initialize a mutex. */
732 extern int pthread_mutex_init (pthread_mutex_t *__mutex,
733 const pthread_mutexattr_t *__mutexattr)
734 __THROW __nonnull ((1));
736 /* Destroy a mutex. */
737 extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
738 __THROW __nonnull ((1));
740 /* Try locking a mutex. */
741 extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
742 __THROWNL __nonnull ((1));
744 /* Lock a mutex. */
745 extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
746 __THROWNL __nonnull ((1));
748 #ifdef __USE_XOPEN2K
749 /* Wait until lock becomes available, or specified time passes. */
750 extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
751 const struct timespec *__restrict
752 __abstime) __THROWNL __nonnull ((1, 2));
753 #endif
755 /* Unlock a mutex. */
756 extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
757 __THROWNL __nonnull ((1));
760 /* Get the priority ceiling of MUTEX. */
761 extern int pthread_mutex_getprioceiling (const pthread_mutex_t *
762 __restrict __mutex,
763 int *__restrict __prioceiling)
764 __THROW __nonnull ((1, 2));
766 /* Set the priority ceiling of MUTEX to PRIOCEILING, return old
767 priority ceiling value in *OLD_CEILING. */
768 extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
769 int __prioceiling,
770 int *__restrict __old_ceiling)
771 __THROW __nonnull ((1, 3));
774 #ifdef __USE_XOPEN2K8
775 /* Declare the state protected by MUTEX as consistent. */
776 extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
777 __THROW __nonnull ((1));
778 # ifdef __USE_GNU
779 extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex)
780 __THROW __nonnull ((1));
781 # endif
782 #endif
785 /* Functions for handling mutex attributes. */
787 /* Initialize mutex attribute object ATTR with default attributes
788 (kind is PTHREAD_MUTEX_TIMED_NP). */
789 extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
790 __THROW __nonnull ((1));
792 /* Destroy mutex attribute object ATTR. */
793 extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
794 __THROW __nonnull ((1));
796 /* Get the process-shared flag of the mutex attribute ATTR. */
797 extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t *
798 __restrict __attr,
799 int *__restrict __pshared)
800 __THROW __nonnull ((1, 2));
802 /* Set the process-shared flag of the mutex attribute ATTR. */
803 extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
804 int __pshared)
805 __THROW __nonnull ((1));
807 #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
808 /* Return in *KIND the mutex kind attribute in *ATTR. */
809 extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
810 __attr, int *__restrict __kind)
811 __THROW __nonnull ((1, 2));
813 /* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
814 PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
815 PTHREAD_MUTEX_DEFAULT). */
816 extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
817 __THROW __nonnull ((1));
818 #endif
820 /* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */
821 extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *
822 __restrict __attr,
823 int *__restrict __protocol)
824 __THROW __nonnull ((1, 2));
826 /* Set the mutex protocol attribute in *ATTR to PROTOCOL (either
827 PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */
828 extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
829 int __protocol)
830 __THROW __nonnull ((1));
832 /* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */
833 extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *
834 __restrict __attr,
835 int *__restrict __prioceiling)
836 __THROW __nonnull ((1, 2));
838 /* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */
839 extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
840 int __prioceiling)
841 __THROW __nonnull ((1));
843 #ifdef __USE_XOPEN2K
844 /* Get the robustness flag of the mutex attribute ATTR. */
845 extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr,
846 int *__robustness)
847 __THROW __nonnull ((1, 2));
848 # ifdef __USE_GNU
849 extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr,
850 int *__robustness)
851 __THROW __nonnull ((1, 2));
852 # endif
854 /* Set the robustness flag of the mutex attribute ATTR. */
855 extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
856 int __robustness)
857 __THROW __nonnull ((1));
858 # ifdef __USE_GNU
859 extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
860 int __robustness)
861 __THROW __nonnull ((1));
862 # endif
863 #endif
866 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
867 /* Functions for handling read-write locks. */
869 /* Initialize read-write lock RWLOCK using attributes ATTR, or use
870 the default values if later is NULL. */
871 extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
872 const pthread_rwlockattr_t *__restrict
873 __attr) __THROW __nonnull ((1));
875 /* Destroy read-write lock RWLOCK. */
876 extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
877 __THROW __nonnull ((1));
879 /* Acquire read lock for RWLOCK. */
880 extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
881 __THROWNL __nonnull ((1));
883 /* Try to acquire read lock for RWLOCK. */
884 extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
885 __THROWNL __nonnull ((1));
887 # ifdef __USE_XOPEN2K
888 /* Try to acquire read lock for RWLOCK or return after specfied time. */
889 extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
890 const struct timespec *__restrict
891 __abstime) __THROWNL __nonnull ((1, 2));
892 # endif
894 /* Acquire write lock for RWLOCK. */
895 extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
896 __THROWNL __nonnull ((1));
898 /* Try to acquire write lock for RWLOCK. */
899 extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
900 __THROWNL __nonnull ((1));
902 # ifdef __USE_XOPEN2K
903 /* Try to acquire write lock for RWLOCK or return after specfied time. */
904 extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
905 const struct timespec *__restrict
906 __abstime) __THROWNL __nonnull ((1, 2));
907 # endif
909 /* Unlock RWLOCK. */
910 extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
911 __THROWNL __nonnull ((1));
914 /* Functions for handling read-write lock attributes. */
916 /* Initialize attribute object ATTR with default values. */
917 extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
918 __THROW __nonnull ((1));
920 /* Destroy attribute object ATTR. */
921 extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
922 __THROW __nonnull ((1));
924 /* Return current setting of process-shared attribute of ATTR in PSHARED. */
925 extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *
926 __restrict __attr,
927 int *__restrict __pshared)
928 __THROW __nonnull ((1, 2));
930 /* Set process-shared attribute of ATTR to PSHARED. */
931 extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
932 int __pshared)
933 __THROW __nonnull ((1));
935 /* Return current setting of reader/writer preference. */
936 extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *
937 __restrict __attr,
938 int *__restrict __pref)
939 __THROW __nonnull ((1, 2));
941 /* Set reader/write preference. */
942 extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
943 int __pref) __THROW __nonnull ((1));
944 #endif
947 /* Functions for handling conditional variables. */
949 /* Initialize condition variable COND using attributes ATTR, or use
950 the default values if later is NULL. */
951 extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
952 const pthread_condattr_t *__restrict __cond_attr)
953 __THROW __nonnull ((1));
955 /* Destroy condition variable COND. */
956 extern int pthread_cond_destroy (pthread_cond_t *__cond)
957 __THROW __nonnull ((1));
959 /* Wake up one thread waiting for condition variable COND. */
960 extern int pthread_cond_signal (pthread_cond_t *__cond)
961 __THROWNL __nonnull ((1));
963 /* Wake up all threads waiting for condition variables COND. */
964 extern int pthread_cond_broadcast (pthread_cond_t *__cond)
965 __THROWNL __nonnull ((1));
967 /* Wait for condition variable COND to be signaled or broadcast.
968 MUTEX is assumed to be locked before.
970 This function is a cancellation point and therefore not marked with
971 __THROW. */
972 extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
973 pthread_mutex_t *__restrict __mutex)
974 __nonnull ((1, 2));
976 /* Wait for condition variable COND to be signaled or broadcast until
977 ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
978 absolute time specification; zero is the beginning of the epoch
979 (00:00:00 GMT, January 1, 1970).
981 This function is a cancellation point and therefore not marked with
982 __THROW. */
983 extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
984 pthread_mutex_t *__restrict __mutex,
985 const struct timespec *__restrict __abstime)
986 __nonnull ((1, 2, 3));
988 /* Functions for handling condition variable attributes. */
990 /* Initialize condition variable attribute ATTR. */
991 extern int pthread_condattr_init (pthread_condattr_t *__attr)
992 __THROW __nonnull ((1));
994 /* Destroy condition variable attribute ATTR. */
995 extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
996 __THROW __nonnull ((1));
998 /* Get the process-shared flag of the condition variable attribute ATTR. */
999 extern int pthread_condattr_getpshared (const pthread_condattr_t *
1000 __restrict __attr,
1001 int *__restrict __pshared)
1002 __THROW __nonnull ((1, 2));
1004 /* Set the process-shared flag of the condition variable attribute ATTR. */
1005 extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
1006 int __pshared) __THROW __nonnull ((1));
1008 #ifdef __USE_XOPEN2K
1009 /* Get the clock selected for the conditon variable attribute ATTR. */
1010 extern int pthread_condattr_getclock (const pthread_condattr_t *
1011 __restrict __attr,
1012 __clockid_t *__restrict __clock_id)
1013 __THROW __nonnull ((1, 2));
1015 /* Set the clock selected for the conditon variable attribute ATTR. */
1016 extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
1017 __clockid_t __clock_id)
1018 __THROW __nonnull ((1));
1019 #endif
1022 #ifdef __USE_XOPEN2K
1023 /* Functions to handle spinlocks. */
1025 /* Initialize the spinlock LOCK. If PSHARED is nonzero the spinlock can
1026 be shared between different processes. */
1027 extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
1028 __THROW __nonnull ((1));
1030 /* Destroy the spinlock LOCK. */
1031 extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
1032 __THROW __nonnull ((1));
1034 /* Wait until spinlock LOCK is retrieved. */
1035 extern int pthread_spin_lock (pthread_spinlock_t *__lock)
1036 __THROWNL __nonnull ((1));
1038 /* Try to lock spinlock LOCK. */
1039 extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
1040 __THROWNL __nonnull ((1));
1042 /* Release spinlock LOCK. */
1043 extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
1044 __THROWNL __nonnull ((1));
1047 /* Functions to handle barriers. */
1049 /* Initialize BARRIER with the attributes in ATTR. The barrier is
1050 opened when COUNT waiters arrived. */
1051 extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
1052 const pthread_barrierattr_t *__restrict
1053 __attr, unsigned int __count)
1054 __THROW __nonnull ((1));
1056 /* Destroy a previously dynamically initialized barrier BARRIER. */
1057 extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
1058 __THROW __nonnull ((1));
1060 /* Wait on barrier BARRIER. */
1061 extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
1062 __THROWNL __nonnull ((1));
1065 /* Initialize barrier attribute ATTR. */
1066 extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
1067 __THROW __nonnull ((1));
1069 /* Destroy previously dynamically initialized barrier attribute ATTR. */
1070 extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
1071 __THROW __nonnull ((1));
1073 /* Get the process-shared flag of the barrier attribute ATTR. */
1074 extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *
1075 __restrict __attr,
1076 int *__restrict __pshared)
1077 __THROW __nonnull ((1, 2));
1079 /* Set the process-shared flag of the barrier attribute ATTR. */
1080 extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
1081 int __pshared)
1082 __THROW __nonnull ((1));
1083 #endif
1086 /* Functions for handling thread-specific data. */
1088 /* Create a key value identifying a location in the thread-specific
1089 data area. Each thread maintains a distinct thread-specific data
1090 area. DESTR_FUNCTION, if non-NULL, is called with the value
1091 associated to that key when the key is destroyed.
1092 DESTR_FUNCTION is not called if the value associated is NULL when
1093 the key is destroyed. */
1094 extern int pthread_key_create (pthread_key_t *__key,
1095 void (*__destr_function) (void *))
1096 __THROW __nonnull ((1));
1098 /* Destroy KEY. */
1099 extern int pthread_key_delete (pthread_key_t __key) __THROW;
1101 /* Return current value of the thread-specific data slot identified by KEY. */
1102 extern void *pthread_getspecific (pthread_key_t __key) __THROW;
1104 /* Store POINTER in the thread-specific data slot identified by KEY. */
1105 extern int pthread_setspecific (pthread_key_t __key,
1106 const void *__pointer) __THROW ;
1109 #ifdef __USE_XOPEN2K
1110 /* Get ID of CPU-time clock for thread THREAD_ID. */
1111 extern int pthread_getcpuclockid (pthread_t __thread_id,
1112 __clockid_t *__clock_id)
1113 __THROW __nonnull ((2));
1114 #endif
1117 /* Install handlers to be called when a new process is created with FORK.
1118 The PREPARE handler is called in the parent process just before performing
1119 FORK. The PARENT handler is called in the parent process just after FORK.
1120 The CHILD handler is called in the child process. Each of the three
1121 handlers can be NULL, meaning that no handler needs to be called at that
1122 point.
1123 PTHREAD_ATFORK can be called several times, in which case the PREPARE
1124 handlers are called in LIFO order (last added with PTHREAD_ATFORK,
1125 first called before FORK), and the PARENT and CHILD handlers are called
1126 in FIFO (first added, first called). */
1128 extern int pthread_atfork (void (*__prepare) (void),
1129 void (*__parent) (void),
1130 void (*__child) (void)) __THROW;
1133 #ifdef __USE_EXTERN_INLINES
1134 /* Optimizations. */
1135 __extern_inline int
1136 __NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2))
1138 return __thread1 == __thread2;
1140 #endif
1142 __END_DECLS
1144 #endif /* pthread.h */
1146 #ifndef _PTHREAD_H_HPPA_
1147 #define _PTHREAD_H_HPPA_ 1
1149 /* The pthread_cond_t initializer is compatible only with NPTL. We do not
1150 want to be forwards compatible, we eventually want to drop the code
1151 that has to clear the old LT initializer. */
1152 #undef PTHREAD_COND_INITIALIZER
1153 #define PTHREAD_COND_INITIALIZER { { 0, 0, 0, (void *) 0, 0, 0, 0, 0, 0 } }
1155 /* The pthread_mutex_t and pthread_rwlock_t initializers are compatible
1156 only with NPTL. NPTL assumes pthread_rwlock_t is all zero. */
1157 #undef PTHREAD_MUTEX_INITIALIZER
1158 #undef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1159 #undef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
1160 #undef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
1161 /* Mutex initializers. */
1162 #define PTHREAD_MUTEX_INITIALIZER \
1163 { { 0, 0, 0, 0, { 0, 0, 0, 0 }, 0, { 0 }, 0, 0 } }
1164 #ifdef __USE_GNU
1165 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
1166 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, { 0, 0, 0, 0 }, 0, { 0 }, 0, 0 } }
1167 # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
1168 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, { 0, 0, 0, 0 }, 0, { 0 }, 0, 0 } }
1169 # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
1170 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, { 0, 0, 0, 0 }, 0, { 0 }, 0, 0 } }
1171 #endif
1173 #undef PTHREAD_RWLOCK_INITIALIZER
1174 #undef PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
1175 /* Read-write lock initializers. */
1176 #define PTHREAD_RWLOCK_INITIALIZER \
1177 { { { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
1178 #ifdef __USE_GNU
1179 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
1180 { { { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\
1181 0, 0, 0 } }
1182 #endif /* Unix98 or XOpen2K */
1184 #endif