1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | #ifndef _PTHREAD_H |
19 | #define _PTHREAD_H 1 |
20 | |
21 | #include <features.h> |
22 | #include <endian.h> |
23 | #include <sched.h> |
24 | #include <time.h> |
25 | |
26 | #include <bits/pthreadtypes.h> |
27 | #include <bits/setjmp.h> |
28 | #include <bits/wordsize.h> |
29 | |
30 | |
31 | |
32 | enum |
33 | { |
34 | PTHREAD_CREATE_JOINABLE, |
35 | #define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE |
36 | PTHREAD_CREATE_DETACHED |
37 | #define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED |
38 | }; |
39 | |
40 | |
41 | |
42 | enum |
43 | { |
44 | PTHREAD_MUTEX_TIMED_NP, |
45 | PTHREAD_MUTEX_RECURSIVE_NP, |
46 | PTHREAD_MUTEX_ERRORCHECK_NP, |
47 | PTHREAD_MUTEX_ADAPTIVE_NP |
48 | #if defined __USE_UNIX98 || defined __USE_XOPEN2K8 |
49 | , |
50 | PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, |
51 | PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, |
52 | PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, |
53 | PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL |
54 | #endif |
55 | #ifdef __USE_GNU |
56 | |
57 | , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP |
58 | #endif |
59 | }; |
60 | |
61 | |
62 | #ifdef __USE_XOPEN2K |
63 | |
64 | enum |
65 | { |
66 | PTHREAD_MUTEX_STALLED, |
67 | PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED, |
68 | PTHREAD_MUTEX_ROBUST, |
69 | PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST |
70 | }; |
71 | #endif |
72 | |
73 | |
74 | #if defined __USE_POSIX199506 || defined __USE_UNIX98 |
75 | |
76 | enum |
77 | { |
78 | PTHREAD_PRIO_NONE, |
79 | PTHREAD_PRIO_INHERIT, |
80 | PTHREAD_PRIO_PROTECT |
81 | }; |
82 | #endif |
83 | |
84 | |
85 | #ifdef __PTHREAD_MUTEX_HAVE_PREV |
86 | # define PTHREAD_MUTEX_INITIALIZER \ |
87 | { { 0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } } |
88 | # ifdef __USE_GNU |
89 | # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ |
90 | { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __PTHREAD_SPINS, { 0, 0 } } } |
91 | # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ |
92 | { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __PTHREAD_SPINS, { 0, 0 } } } |
93 | # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \ |
94 | { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __PTHREAD_SPINS, { 0, 0 } } } |
95 | |
96 | # endif |
97 | #else |
98 | # define PTHREAD_MUTEX_INITIALIZER \ |
99 | { { 0, 0, 0, 0, 0, { __PTHREAD_SPINS } } } |
100 | # ifdef __USE_GNU |
101 | # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ |
102 | { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { __PTHREAD_SPINS } } } |
103 | # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ |
104 | { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { __PTHREAD_SPINS } } } |
105 | # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \ |
106 | { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { __PTHREAD_SPINS } } } |
107 | |
108 | # endif |
109 | #endif |
110 | |
111 | |
112 | |
113 | #if defined __USE_UNIX98 || defined __USE_XOPEN2K |
114 | enum |
115 | { |
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 |
120 | }; |
121 | |
122 | |
123 | |
124 | |
125 | #ifndef __PTHREAD_RWLOCK_INT_FLAGS_SHARED |
126 | # if __WORDSIZE == 64 |
127 | # define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1 |
128 | # endif |
129 | #endif |
130 | |
131 | |
132 | # define PTHREAD_RWLOCK_INITIALIZER \ |
133 | { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } } |
134 | # ifdef __USE_GNU |
135 | # ifdef __PTHREAD_RWLOCK_INT_FLAGS_SHARED |
136 | # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ |
137 | { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, \ |
138 | PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } } |
139 | # else |
140 | # if __BYTE_ORDER == __LITTLE_ENDIAN |
141 | # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ |
142 | { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \ |
143 | 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } } |
144 | # else |
145 | # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ |
146 | { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\ |
147 | 0 } } |
148 | # endif |
149 | # endif |
150 | # endif |
151 | #endif |
152 | |
153 | |
154 | |
155 | enum |
156 | { |
157 | PTHREAD_INHERIT_SCHED, |
158 | #define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED |
159 | PTHREAD_EXPLICIT_SCHED |
160 | #define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED |
161 | }; |
162 | |
163 | |
164 | |
165 | enum |
166 | { |
167 | PTHREAD_SCOPE_SYSTEM, |
168 | #define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM |
169 | PTHREAD_SCOPE_PROCESS |
170 | #define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS |
171 | }; |
172 | |
173 | |
174 | |
175 | enum |
176 | { |
177 | PTHREAD_PROCESS_PRIVATE, |
178 | #define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE |
179 | PTHREAD_PROCESS_SHARED |
180 | #define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED |
181 | }; |
182 | |
183 | |
184 | |
185 | |
186 | #define PTHREAD_COND_INITIALIZER { { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } } |
187 | |
188 | |
189 | |
190 | struct _pthread_cleanup_buffer |
191 | { |
192 | void (*__routine) (void *); |
193 | void *__arg; |
194 | int __canceltype; |
195 | struct _pthread_cleanup_buffer *__prev; |
196 | }; |
197 | |
198 | |
199 | enum |
200 | { |
201 | PTHREAD_CANCEL_ENABLE, |
202 | #define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE |
203 | PTHREAD_CANCEL_DISABLE |
204 | #define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE |
205 | }; |
206 | enum |
207 | { |
208 | PTHREAD_CANCEL_DEFERRED, |
209 | #define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED |
210 | PTHREAD_CANCEL_ASYNCHRONOUS |
211 | #define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS |
212 | }; |
213 | #define PTHREAD_CANCELED ((void *) -1) |
214 | |
215 | |
216 | |
217 | #define PTHREAD_ONCE_INIT 0 |
218 | |
219 | |
220 | #ifdef __USE_XOPEN2K |
221 | |
222 | |
223 | |
224 | # define PTHREAD_BARRIER_SERIAL_THREAD -1 |
225 | #endif |
226 | |
227 | |
228 | __BEGIN_DECLS |
229 | |
230 | |
231 | |
232 | |
233 | extern int pthread_create (pthread_t *__restrict __newthread, |
234 | const pthread_attr_t *__restrict __attr, |
235 | void *(*__start_routine) (void *), |
236 | void *__restrict __arg) __THROWNL __nonnull ((1, 3)); |
237 | |
238 | |
239 | |
240 | |
241 | |
242 | extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__)); |
243 | |
244 | |
245 | |
246 | |
247 | |
248 | |
249 | |
250 | extern int pthread_join (pthread_t __th, void **__thread_return); |
251 | |
252 | #ifdef __USE_GNU |
253 | |
254 | |
255 | extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW; |
256 | |
257 | |
258 | |
259 | |
260 | |
261 | |
262 | |
263 | extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return, |
264 | const struct timespec *__abstime); |
265 | #endif |
266 | |
267 | |
268 | |
269 | |
270 | |
271 | extern int pthread_detach (pthread_t __th) __THROW; |
272 | |
273 | |
274 | |
275 | extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__)); |
276 | |
277 | |
278 | extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) |
279 | __THROW __attribute__ ((__const__)); |
280 | |
281 | |
282 | |
283 | |
284 | |
285 | |
286 | |
287 | extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1)); |
288 | |
289 | |
290 | extern int pthread_attr_destroy (pthread_attr_t *__attr) |
291 | __THROW __nonnull ((1)); |
292 | |
293 | |
294 | extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr, |
295 | int *__detachstate) |
296 | __THROW __nonnull ((1, 2)); |
297 | |
298 | |
299 | extern int pthread_attr_setdetachstate (pthread_attr_t *__attr, |
300 | int __detachstate) |
301 | __THROW __nonnull ((1)); |
302 | |
303 | |
304 | |
305 | extern int pthread_attr_getguardsize (const pthread_attr_t *__attr, |
306 | size_t *__guardsize) |
307 | __THROW __nonnull ((1, 2)); |
308 | |
309 | |
310 | extern int pthread_attr_setguardsize (pthread_attr_t *__attr, |
311 | size_t __guardsize) |
312 | __THROW __nonnull ((1)); |
313 | |
314 | |
315 | |
316 | extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr, |
317 | struct sched_param *__restrict __param) |
318 | __THROW __nonnull ((1, 2)); |
319 | |
320 | |
321 | extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr, |
322 | const struct sched_param *__restrict |
323 | __param) __THROW __nonnull ((1, 2)); |
324 | |
325 | |
326 | extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict |
327 | __attr, int *__restrict __policy) |
328 | __THROW __nonnull ((1, 2)); |
329 | |
330 | |
331 | extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy) |
332 | __THROW __nonnull ((1)); |
333 | |
334 | |
335 | extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict |
336 | __attr, int *__restrict __inherit) |
337 | __THROW __nonnull ((1, 2)); |
338 | |
339 | |
340 | extern int pthread_attr_setinheritsched (pthread_attr_t *__attr, |
341 | int __inherit) |
342 | __THROW __nonnull ((1)); |
343 | |
344 | |
345 | |
346 | extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr, |
347 | int *__restrict __scope) |
348 | __THROW __nonnull ((1, 2)); |
349 | |
350 | |
351 | extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope) |
352 | __THROW __nonnull ((1)); |
353 | |
354 | |
355 | extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict |
356 | __attr, void **__restrict __stackaddr) |
357 | __THROW __nonnull ((1, 2)) __attribute_deprecated__; |
358 | |
359 | |
360 | |
361 | |
362 | |
363 | extern int pthread_attr_setstackaddr (pthread_attr_t *__attr, |
364 | void *__stackaddr) |
365 | __THROW __nonnull ((1)) __attribute_deprecated__; |
366 | |
367 | |
368 | extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict |
369 | __attr, size_t *__restrict __stacksize) |
370 | __THROW __nonnull ((1, 2)); |
371 | |
372 | |
373 | |
374 | |
375 | extern int pthread_attr_setstacksize (pthread_attr_t *__attr, |
376 | size_t __stacksize) |
377 | __THROW __nonnull ((1)); |
378 | |
379 | #ifdef __USE_XOPEN2K |
380 | |
381 | extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr, |
382 | void **__restrict __stackaddr, |
383 | size_t *__restrict __stacksize) |
384 | __THROW __nonnull ((1, 2, 3)); |
385 | |
386 | |
387 | |
388 | |
389 | extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr, |
390 | size_t __stacksize) __THROW __nonnull ((1)); |
391 | #endif |
392 | |
393 | #ifdef __USE_GNU |
394 | |
395 | |
396 | extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr, |
397 | size_t __cpusetsize, |
398 | const cpu_set_t *__cpuset) |
399 | __THROW __nonnull ((1, 3)); |
400 | |
401 | |
402 | |
403 | extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr, |
404 | size_t __cpusetsize, |
405 | cpu_set_t *__cpuset) |
406 | __THROW __nonnull ((1, 3)); |
407 | |
408 | |
409 | extern int pthread_getattr_default_np (pthread_attr_t *__attr) |
410 | __THROW __nonnull ((1)); |
411 | |
412 | |
413 | |
414 | extern int pthread_setattr_default_np (const pthread_attr_t *__attr) |
415 | __THROW __nonnull ((1)); |
416 | |
417 | |
418 | |
419 | |
420 | extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) |
421 | __THROW __nonnull ((2)); |
422 | #endif |
423 | |
424 | |
425 | |
426 | |
427 | |
428 | |
429 | extern int pthread_setschedparam (pthread_t __target_thread, int __policy, |
430 | const struct sched_param *__param) |
431 | __THROW __nonnull ((3)); |
432 | |
433 | |
434 | extern int pthread_getschedparam (pthread_t __target_thread, |
435 | int *__restrict __policy, |
436 | struct sched_param *__restrict __param) |
437 | __THROW __nonnull ((2, 3)); |
438 | |
439 | |
440 | extern int pthread_setschedprio (pthread_t __target_thread, int __prio) |
441 | __THROW; |
442 | |
443 | |
444 | #ifdef __USE_GNU |
445 | |
446 | extern int pthread_getname_np (pthread_t __target_thread, char *__buf, |
447 | size_t __buflen) |
448 | __THROW __nonnull ((2)); |
449 | |
450 | |
451 | extern int pthread_setname_np (pthread_t __target_thread, const char *__name) |
452 | __THROW __nonnull ((2)); |
453 | #endif |
454 | |
455 | |
456 | #ifdef __USE_UNIX98 |
457 | |
458 | extern int pthread_getconcurrency (void) __THROW; |
459 | |
460 | |
461 | extern int pthread_setconcurrency (int __level) __THROW; |
462 | #endif |
463 | |
464 | #ifdef __USE_GNU |
465 | |
466 | |
467 | |
468 | |
469 | extern int pthread_yield (void) __THROW; |
470 | |
471 | |
472 | |
473 | |
474 | extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize, |
475 | const cpu_set_t *__cpuset) |
476 | __THROW __nonnull ((3)); |
477 | |
478 | |
479 | extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize, |
480 | cpu_set_t *__cpuset) |
481 | __THROW __nonnull ((3)); |
482 | #endif |
483 | |
484 | |
485 | |
486 | |
487 | |
488 | |
489 | |
490 | |
491 | |
492 | |
493 | |
494 | extern int pthread_once (pthread_once_t *__once_control, |
495 | void (*__init_routine) (void)) __nonnull ((1, 2)); |
496 | |
497 | |
498 | |
499 | |
500 | |
501 | |
502 | |
503 | |
504 | |
505 | |
506 | extern int pthread_setcancelstate (int __state, int *__oldstate); |
507 | |
508 | |
509 | |
510 | extern int pthread_setcanceltype (int __type, int *__oldtype); |
511 | |
512 | |
513 | extern int pthread_cancel (pthread_t __th); |
514 | |
515 | |
516 | |
517 | |
518 | extern void pthread_testcancel (void); |
519 | |
520 | |
521 | |
522 | |
523 | typedef struct |
524 | { |
525 | struct |
526 | { |
527 | __jmp_buf __cancel_jmp_buf; |
528 | int __mask_was_saved; |
529 | } __cancel_jmp_buf[1]; |
530 | void *__pad[4]; |
531 | } __pthread_unwind_buf_t __attribute__ ((__aligned__)); |
532 | |
533 | |
534 | #ifndef __cleanup_fct_attribute |
535 | # define __cleanup_fct_attribute |
536 | #endif |
537 | |
538 | |
539 | |
540 | struct __pthread_cleanup_frame |
541 | { |
542 | void (*__cancel_routine) (void *); |
543 | void *__cancel_arg; |
544 | int __do_it; |
545 | int __cancel_type; |
546 | }; |
547 | |
548 | #if defined __GNUC__ && defined __EXCEPTIONS |
549 | # ifdef __cplusplus |
550 | |
551 | class __pthread_cleanup_class |
552 | { |
553 | void (*__cancel_routine) (void *); |
554 | void *__cancel_arg; |
555 | int __do_it; |
556 | int __cancel_type; |
557 | |
558 | public: |
559 | __pthread_cleanup_class (void (*__fct) (void *), void *__arg) |
560 | : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { } |
561 | ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); } |
562 | void __setdoit (int __newval) { __do_it = __newval; } |
563 | void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, |
564 | &__cancel_type); } |
565 | void __restore () const { pthread_setcanceltype (__cancel_type, 0); } |
566 | }; |
567 | |
568 | |
569 | |
570 | |
571 | |
572 | |
573 | |
574 | |
575 | # define pthread_cleanup_push(routine, arg) \ |
576 | do { \ |
577 | __pthread_cleanup_class __clframe (routine, arg) |
578 | |
579 | |
580 | |
581 | # define pthread_cleanup_pop(execute) \ |
582 | __clframe.__setdoit (execute); \ |
583 | } while (0) |
584 | |
585 | # ifdef __USE_GNU |
586 | |
587 | |
588 | |
589 | # define pthread_cleanup_push_defer_np(routine, arg) \ |
590 | do { \ |
591 | __pthread_cleanup_class __clframe (routine, arg); \ |
592 | __clframe.__defer () |
593 | |
594 | |
595 | |
596 | |
597 | # define pthread_cleanup_pop_restore_np(execute) \ |
598 | __clframe.__restore (); \ |
599 | __clframe.__setdoit (execute); \ |
600 | } while (0) |
601 | # endif |
602 | # else |
603 | |
604 | |
605 | |
606 | |
607 | __extern_inline void |
608 | __pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame) |
609 | { |
610 | if (__frame->__do_it) |
611 | __frame->__cancel_routine (__frame->__cancel_arg); |
612 | } |
613 | |
614 | |
615 | |
616 | |
617 | |
618 | |
619 | |
620 | |
621 | # define pthread_cleanup_push(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 | |
628 | |
629 | |
630 | # define pthread_cleanup_pop(execute) \ |
631 | __clframe.__do_it = (execute); \ |
632 | } while (0) |
633 | |
634 | # ifdef __USE_GNU |
635 | |
636 | |
637 | |
638 | # define pthread_cleanup_push_defer_np(routine, arg) \ |
639 | do { \ |
640 | struct __pthread_cleanup_frame __clframe \ |
641 | __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \ |
642 | = { .__cancel_routine = (routine), .__cancel_arg = (arg), \ |
643 | .__do_it = 1 }; \ |
644 | (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, \ |
645 | &__clframe.__cancel_type) |
646 | |
647 | |
648 | |
649 | |
650 | # define pthread_cleanup_pop_restore_np(execute) \ |
651 | (void) pthread_setcanceltype (__clframe.__cancel_type, NULL); \ |
652 | __clframe.__do_it = (execute); \ |
653 | } while (0) |
654 | # endif |
655 | # endif |
656 | #else |
657 | |
658 | |
659 | |
660 | |
661 | |
662 | |
663 | |
664 | # define pthread_cleanup_push(routine, arg) \ |
665 | do { \ |
666 | __pthread_unwind_buf_t __cancel_buf; \ |
667 | void (*__cancel_routine) (void *) = (routine); \ |
668 | void *__cancel_arg = (arg); \ |
669 | int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \ |
670 | __cancel_buf.__cancel_jmp_buf, 0); \ |
671 | if (__glibc_unlikely (__not_first_call)) \ |
672 | { \ |
673 | __cancel_routine (__cancel_arg); \ |
674 | __pthread_unwind_next (&__cancel_buf); \ |
675 | \ |
676 | } \ |
677 | \ |
678 | __pthread_register_cancel (&__cancel_buf); \ |
679 | do { |
680 | extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf) |
681 | __cleanup_fct_attribute; |
682 | |
683 | |
684 | |
685 | # define pthread_cleanup_pop(execute) \ |
686 | do { } while (0);\ |
687 | } while (0); \ |
688 | __pthread_unregister_cancel (&__cancel_buf); \ |
689 | if (execute) \ |
690 | __cancel_routine (__cancel_arg); \ |
691 | } while (0) |
692 | extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf) |
693 | __cleanup_fct_attribute; |
694 | |
695 | # ifdef __USE_GNU |
696 | |
697 | |
698 | |
699 | # define pthread_cleanup_push_defer_np(routine, arg) \ |
700 | do { \ |
701 | __pthread_unwind_buf_t __cancel_buf; \ |
702 | void (*__cancel_routine) (void *) = (routine); \ |
703 | void *__cancel_arg = (arg); \ |
704 | int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \ |
705 | __cancel_buf.__cancel_jmp_buf, 0); \ |
706 | if (__glibc_unlikely (__not_first_call)) \ |
707 | { \ |
708 | __cancel_routine (__cancel_arg); \ |
709 | __pthread_unwind_next (&__cancel_buf); \ |
710 | \ |
711 | } \ |
712 | \ |
713 | __pthread_register_cancel_defer (&__cancel_buf); \ |
714 | do { |
715 | extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf) |
716 | __cleanup_fct_attribute; |
717 | |
718 | |
719 | |
720 | |
721 | # define pthread_cleanup_pop_restore_np(execute) \ |
722 | do { } while (0);\ |
723 | } while (0); \ |
724 | __pthread_unregister_cancel_restore (&__cancel_buf); \ |
725 | if (execute) \ |
726 | __cancel_routine (__cancel_arg); \ |
727 | } while (0) |
728 | extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf) |
729 | __cleanup_fct_attribute; |
730 | # endif |
731 | |
732 | |
733 | extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf) |
734 | __cleanup_fct_attribute __attribute__ ((__noreturn__)) |
735 | # ifndef SHARED |
736 | __attribute__ ((__weak__)) |
737 | # endif |
738 | ; |
739 | #endif |
740 | |
741 | |
742 | struct __jmp_buf_tag; |
743 | extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL; |
744 | |
745 | |
746 | |
747 | |
748 | |
749 | extern int pthread_mutex_init (pthread_mutex_t *__mutex, |
750 | const pthread_mutexattr_t *__mutexattr) |
751 | __THROW __nonnull ((1)); |
752 | |
753 | |
754 | extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) |
755 | __THROW __nonnull ((1)); |
756 | |
757 | |
758 | extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) |
759 | __THROWNL __nonnull ((1)); |
760 | |
761 | |
762 | extern int pthread_mutex_lock (pthread_mutex_t *__mutex) |
763 | __THROWNL __nonnull ((1)); |
764 | |
765 | #ifdef __USE_XOPEN2K |
766 | |
767 | extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex, |
768 | const struct timespec *__restrict |
769 | __abstime) __THROWNL __nonnull ((1, 2)); |
770 | #endif |
771 | |
772 | |
773 | extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) |
774 | __THROWNL __nonnull ((1)); |
775 | |
776 | |
777 | |
778 | extern int pthread_mutex_getprioceiling (const pthread_mutex_t * |
779 | __restrict __mutex, |
780 | int *__restrict __prioceiling) |
781 | __THROW __nonnull ((1, 2)); |
782 | |
783 | |
784 | |
785 | extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex, |
786 | int __prioceiling, |
787 | int *__restrict __old_ceiling) |
788 | __THROW __nonnull ((1, 3)); |
789 | |
790 | |
791 | #ifdef __USE_XOPEN2K8 |
792 | |
793 | extern int pthread_mutex_consistent (pthread_mutex_t *__mutex) |
794 | __THROW __nonnull ((1)); |
795 | # ifdef __USE_GNU |
796 | extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex) |
797 | __THROW __nonnull ((1)); |
798 | # endif |
799 | #endif |
800 | |
801 | |
802 | |
803 | |
804 | |
805 | |
806 | extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) |
807 | __THROW __nonnull ((1)); |
808 | |
809 | |
810 | extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) |
811 | __THROW __nonnull ((1)); |
812 | |
813 | |
814 | extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t * |
815 | __restrict __attr, |
816 | int *__restrict __pshared) |
817 | __THROW __nonnull ((1, 2)); |
818 | |
819 | |
820 | extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr, |
821 | int __pshared) |
822 | __THROW __nonnull ((1)); |
823 | |
824 | #if defined __USE_UNIX98 || defined __USE_XOPEN2K8 |
825 | |
826 | extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict |
827 | __attr, int *__restrict __kind) |
828 | __THROW __nonnull ((1, 2)); |
829 | |
830 | |
831 | |
832 | |
833 | extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) |
834 | __THROW __nonnull ((1)); |
835 | #endif |
836 | |
837 | |
838 | extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t * |
839 | __restrict __attr, |
840 | int *__restrict __protocol) |
841 | __THROW __nonnull ((1, 2)); |
842 | |
843 | |
844 | |
845 | extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr, |
846 | int __protocol) |
847 | __THROW __nonnull ((1)); |
848 | |
849 | |
850 | extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t * |
851 | __restrict __attr, |
852 | int *__restrict __prioceiling) |
853 | __THROW __nonnull ((1, 2)); |
854 | |
855 | |
856 | extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr, |
857 | int __prioceiling) |
858 | __THROW __nonnull ((1)); |
859 | |
860 | #ifdef __USE_XOPEN2K |
861 | |
862 | extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr, |
863 | int *__robustness) |
864 | __THROW __nonnull ((1, 2)); |
865 | # ifdef __USE_GNU |
866 | extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr, |
867 | int *__robustness) |
868 | __THROW __nonnull ((1, 2)); |
869 | # endif |
870 | |
871 | |
872 | extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr, |
873 | int __robustness) |
874 | __THROW __nonnull ((1)); |
875 | # ifdef __USE_GNU |
876 | extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr, |
877 | int __robustness) |
878 | __THROW __nonnull ((1)); |
879 | # endif |
880 | #endif |
881 | |
882 | |
883 | #if defined __USE_UNIX98 || defined __USE_XOPEN2K |
884 | |
885 | |
886 | |
887 | |
888 | extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock, |
889 | const pthread_rwlockattr_t *__restrict |
890 | __attr) __THROW __nonnull ((1)); |
891 | |
892 | |
893 | extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) |
894 | __THROW __nonnull ((1)); |
895 | |
896 | |
897 | extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) |
898 | __THROWNL __nonnull ((1)); |
899 | |
900 | |
901 | extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) |
902 | __THROWNL __nonnull ((1)); |
903 | |
904 | # ifdef __USE_XOPEN2K |
905 | |
906 | extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock, |
907 | const struct timespec *__restrict |
908 | __abstime) __THROWNL __nonnull ((1, 2)); |
909 | # endif |
910 | |
911 | |
912 | extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) |
913 | __THROWNL __nonnull ((1)); |
914 | |
915 | |
916 | extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) |
917 | __THROWNL __nonnull ((1)); |
918 | |
919 | # ifdef __USE_XOPEN2K |
920 | |
921 | extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock, |
922 | const struct timespec *__restrict |
923 | __abstime) __THROWNL __nonnull ((1, 2)); |
924 | # endif |
925 | |
926 | |
927 | extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) |
928 | __THROWNL __nonnull ((1)); |
929 | |
930 | |
931 | |
932 | |
933 | |
934 | extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) |
935 | __THROW __nonnull ((1)); |
936 | |
937 | |
938 | extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) |
939 | __THROW __nonnull ((1)); |
940 | |
941 | |
942 | extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * |
943 | __restrict __attr, |
944 | int *__restrict __pshared) |
945 | __THROW __nonnull ((1, 2)); |
946 | |
947 | |
948 | extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr, |
949 | int __pshared) |
950 | __THROW __nonnull ((1)); |
951 | |
952 | |
953 | extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t * |
954 | __restrict __attr, |
955 | int *__restrict __pref) |
956 | __THROW __nonnull ((1, 2)); |
957 | |
958 | |
959 | extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr, |
960 | int __pref) __THROW __nonnull ((1)); |
961 | #endif |
962 | |
963 | |
964 | |
965 | |
966 | |
967 | |
968 | extern int pthread_cond_init (pthread_cond_t *__restrict __cond, |
969 | const pthread_condattr_t *__restrict __cond_attr) |
970 | __THROW __nonnull ((1)); |
971 | |
972 | |
973 | extern int pthread_cond_destroy (pthread_cond_t *__cond) |
974 | __THROW __nonnull ((1)); |
975 | |
976 | |
977 | extern int pthread_cond_signal (pthread_cond_t *__cond) |
978 | __THROWNL __nonnull ((1)); |
979 | |
980 | |
981 | extern int pthread_cond_broadcast (pthread_cond_t *__cond) |
982 | __THROWNL __nonnull ((1)); |
983 | |
984 | |
985 | |
986 | |
987 | |
988 | |
989 | extern int pthread_cond_wait (pthread_cond_t *__restrict __cond, |
990 | pthread_mutex_t *__restrict __mutex) |
991 | __nonnull ((1, 2)); |
992 | |
993 | |
994 | |
995 | |
996 | |
997 | |
998 | |
999 | |
1000 | extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond, |
1001 | pthread_mutex_t *__restrict __mutex, |
1002 | const struct timespec *__restrict __abstime) |
1003 | __nonnull ((1, 2, 3)); |
1004 | |
1005 | |
1006 | |
1007 | |
1008 | extern int pthread_condattr_init (pthread_condattr_t *__attr) |
1009 | __THROW __nonnull ((1)); |
1010 | |
1011 | |
1012 | extern int pthread_condattr_destroy (pthread_condattr_t *__attr) |
1013 | __THROW __nonnull ((1)); |
1014 | |
1015 | |
1016 | extern int pthread_condattr_getpshared (const pthread_condattr_t * |
1017 | __restrict __attr, |
1018 | int *__restrict __pshared) |
1019 | __THROW __nonnull ((1, 2)); |
1020 | |
1021 | |
1022 | extern int pthread_condattr_setpshared (pthread_condattr_t *__attr, |
1023 | int __pshared) __THROW __nonnull ((1)); |
1024 | |
1025 | #ifdef __USE_XOPEN2K |
1026 | |
1027 | extern int pthread_condattr_getclock (const pthread_condattr_t * |
1028 | __restrict __attr, |
1029 | __clockid_t *__restrict __clock_id) |
1030 | __THROW __nonnull ((1, 2)); |
1031 | |
1032 | |
1033 | extern int pthread_condattr_setclock (pthread_condattr_t *__attr, |
1034 | __clockid_t __clock_id) |
1035 | __THROW __nonnull ((1)); |
1036 | #endif |
1037 | |
1038 | |
1039 | #ifdef __USE_XOPEN2K |
1040 | |
1041 | |
1042 | |
1043 | |
1044 | extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared) |
1045 | __THROW __nonnull ((1)); |
1046 | |
1047 | |
1048 | extern int pthread_spin_destroy (pthread_spinlock_t *__lock) |
1049 | __THROW __nonnull ((1)); |
1050 | |
1051 | |
1052 | extern int pthread_spin_lock (pthread_spinlock_t *__lock) |
1053 | __THROWNL __nonnull ((1)); |
1054 | |
1055 | |
1056 | extern int pthread_spin_trylock (pthread_spinlock_t *__lock) |
1057 | __THROWNL __nonnull ((1)); |
1058 | |
1059 | |
1060 | extern int pthread_spin_unlock (pthread_spinlock_t *__lock) |
1061 | __THROWNL __nonnull ((1)); |
1062 | |
1063 | |
1064 | |
1065 | |
1066 | |
1067 | |
1068 | extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier, |
1069 | const pthread_barrierattr_t *__restrict |
1070 | __attr, unsigned int __count) |
1071 | __THROW __nonnull ((1)); |
1072 | |
1073 | |
1074 | extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) |
1075 | __THROW __nonnull ((1)); |
1076 | |
1077 | |
1078 | extern int pthread_barrier_wait (pthread_barrier_t *__barrier) |
1079 | __THROWNL __nonnull ((1)); |
1080 | |
1081 | |
1082 | |
1083 | extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) |
1084 | __THROW __nonnull ((1)); |
1085 | |
1086 | |
1087 | extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) |
1088 | __THROW __nonnull ((1)); |
1089 | |
1090 | |
1091 | extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t * |
1092 | __restrict __attr, |
1093 | int *__restrict __pshared) |
1094 | __THROW __nonnull ((1, 2)); |
1095 | |
1096 | |
1097 | extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr, |
1098 | int __pshared) |
1099 | __THROW __nonnull ((1)); |
1100 | #endif |
1101 | |
1102 | |
1103 | |
1104 | |
1105 | |
1106 | |
1107 | |
1108 | |
1109 | |
1110 | |
1111 | extern int pthread_key_create (pthread_key_t *__key, |
1112 | void (*__destr_function) (void *)) |
1113 | __THROW __nonnull ((1)); |
1114 | |
1115 | |
1116 | extern int pthread_key_delete (pthread_key_t __key) __THROW; |
1117 | |
1118 | |
1119 | extern void *pthread_getspecific (pthread_key_t __key) __THROW; |
1120 | |
1121 | |
1122 | extern int pthread_setspecific (pthread_key_t __key, |
1123 | const void *__pointer) __THROW ; |
1124 | |
1125 | |
1126 | #ifdef __USE_XOPEN2K |
1127 | |
1128 | extern int pthread_getcpuclockid (pthread_t __thread_id, |
1129 | __clockid_t *__clock_id) |
1130 | __THROW __nonnull ((2)); |
1131 | #endif |
1132 | |
1133 | |
1134 | |
1135 | |
1136 | |
1137 | |
1138 | |
1139 | |
1140 | |
1141 | |
1142 | |
1143 | |
1144 | |
1145 | extern int pthread_atfork (void (*__prepare) (void), |
1146 | void (*__parent) (void), |
1147 | void (*__child) (void)) __THROW; |
1148 | |
1149 | |
1150 | #ifdef __USE_EXTERN_INLINES |
1151 | |
1152 | __extern_inline int |
1153 | __NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2)) |
1154 | { |
1155 | return __thread1 == __thread2; |
1156 | } |
1157 | #endif |
1158 | |
1159 | __END_DECLS |
1160 | |
1161 | #endif |
1162 | |