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