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