The OpenD Programming Language

1 /**
2  * D header file for POSIX.
3  *
4  * Copyright: Copyright Sean Kelly 2005 - 2009.
5  * License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6  * Authors:   Sean Kelly, Alex Rønne Petersen
7  * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8  */
9 
10 /*          Copyright Sean Kelly 2005 - 2009.
11  * Distributed under the Boost Software License, Version 1.0.
12  *    (See accompanying file LICENSE or copy at
13  *          http://www.boost.org/LICENSE_1_0.txt)
14  */
15 module core.sys.posix.pthread;
16 
17 import core.sys.posix.config;
18 public import core.sys.posix.sys.types;
19 public import core.sys.posix.sched;
20 public import core.sys.posix.time;
21 
22 import core.stdc.stdint;
23 
24 version (OSX)
25     version = Darwin;
26 else version (iOS)
27     version = Darwin;
28 else version (TVOS)
29     version = Darwin;
30 else version (WatchOS)
31     version = Darwin;
32 
33 version (Posix):
34 extern (C)
35 nothrow:
36 
37 //
38 // Required
39 //
40 /*
41 PTHREAD_CANCEL_ASYNCHRONOUS
42 PTHREAD_CANCEL_ENABLE
43 PTHREAD_CANCEL_DEFERRED
44 PTHREAD_CANCEL_DISABLE
45 PTHREAD_CANCELED
46 PTHREAD_COND_INITIALIZER
47 PTHREAD_CREATE_DETACHED
48 PTHREAD_CREATE_JOINABLE
49 PTHREAD_EXPLICIT_SCHED
50 PTHREAD_INHERIT_SCHED
51 PTHREAD_MUTEX_INITIALIZER
52 PTHREAD_ONCE_INIT
53 PTHREAD_PROCESS_SHARED
54 PTHREAD_PROCESS_PRIVATE
55 
56 int pthread_atfork(void function(), void function(), void function());
57 int pthread_attr_destroy(pthread_attr_t*);
58 int pthread_attr_getdetachstate(const scope pthread_attr_t*, int*);
59 int pthread_attr_getschedparam(const scope pthread_attr_t*, sched_param*);
60 int pthread_attr_init(pthread_attr_t*);
61 int pthread_attr_setdetachstate(pthread_attr_t*, int);
62 int pthread_attr_setschedparam(const scope pthread_attr_t*, sched_param*);
63 int pthread_cancel(pthread_t);
64 void pthread_cleanup_push(void function(void*), void*);
65 void pthread_cleanup_pop(int);
66 int pthread_cond_broadcast(pthread_cond_t*);
67 int pthread_cond_destroy(pthread_cond_t*);
68 int pthread_cond_init(const scope pthread_cond_t*, pthread_condattr_t*);
69 int pthread_cond_signal(pthread_cond_t*);
70 int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const scope timespec*);
71 int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
72 int pthread_condattr_destroy(pthread_condattr_t*);
73 int pthread_condattr_init(pthread_condattr_t*);
74 int pthread_create(pthread_t*, const scope pthread_attr_t*, void* function(void*), void*);
75 int pthread_detach(pthread_t);
76 int pthread_equal(pthread_t, pthread_t);
77 void pthread_exit(void*);
78 void* pthread_getspecific(pthread_key_t);
79 int pthread_join(pthread_t, void**);
80 int pthread_key_create(pthread_key_t*, void function(void*));
81 int pthread_key_delete(pthread_key_t);
82 int pthread_mutex_destroy(pthread_mutex_t*);
83 int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*);
84 int pthread_mutex_lock(pthread_mutex_t*);
85 int pthread_mutex_trylock(pthread_mutex_t*);
86 int pthread_mutex_unlock(pthread_mutex_t*);
87 int pthread_mutexattr_destroy(pthread_mutexattr_t*);
88 int pthread_mutexattr_init(pthread_mutexattr_t*);
89 int pthread_once(pthread_once_t*, void function());
90 int pthread_rwlock_destroy(pthread_rwlock_t*);
91 int pthread_rwlock_init(pthread_rwlock_t*, const scope pthread_rwlockattr_t*);
92 int pthread_rwlock_rdlock(pthread_rwlock_t*);
93 int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
94 int pthread_rwlock_trywrlock(pthread_rwlock_t*);
95 int pthread_rwlock_unlock(pthread_rwlock_t*);
96 int pthread_rwlock_wrlock(pthread_rwlock_t*);
97 int pthread_rwlockattr_destroy(pthread_rwlockattr_t*);
98 int pthread_rwlockattr_init(pthread_rwlockattr_t*);
99 pthread_t pthread_self();
100 int pthread_setcancelstate(int, int*);
101 int pthread_setcanceltype(int, int*);
102 int pthread_setspecific(pthread_key_t, const scope void*);
103 void pthread_testcancel();
104 */
105 version (CRuntime_Glibc)
106 {
107     enum
108     {
109         PTHREAD_CANCEL_ENABLE,
110         PTHREAD_CANCEL_DISABLE
111     }
112 
113     enum
114     {
115         PTHREAD_CANCEL_DEFERRED,
116         PTHREAD_CANCEL_ASYNCHRONOUS
117     }
118 
119     enum PTHREAD_CANCELED = cast(void*) -1;
120 
121     //enum pthread_mutex_t PTHREAD_COND_INITIALIZER = { __LOCK_ALT_INITIALIZER, 0, "", 0 };
122 
123     enum
124     {
125         PTHREAD_CREATE_JOINABLE,
126         PTHREAD_CREATE_DETACHED
127     }
128 
129     enum
130     {
131         PTHREAD_INHERIT_SCHED,
132         PTHREAD_EXPLICIT_SCHED
133     }
134 
135     enum PTHREAD_MUTEX_INITIALIZER  = pthread_mutex_t.init;
136     enum PTHREAD_ONCE_INIT          = pthread_once_t.init;
137 
138     enum
139     {
140         PTHREAD_PROCESS_PRIVATE,
141         PTHREAD_PROCESS_SHARED
142     }
143 }
144 else version (Darwin)
145 {
146     enum
147     {
148         PTHREAD_CANCEL_ENABLE   = 1,
149         PTHREAD_CANCEL_DISABLE  = 0
150     }
151 
152     enum
153     {
154         PTHREAD_CANCEL_DEFERRED     = 2,
155         PTHREAD_CANCEL_ASYNCHRONOUS = 0
156     }
157 
158     enum PTHREAD_CANCELED = cast(void*) -1;
159 
160     //enum pthread_mutex_t PTHREAD_COND_INITIALIZER = { __LOCK_ALT_INITIALIZER, 0, "", 0 };
161 
162     enum
163     {
164         PTHREAD_CREATE_JOINABLE = 1,
165         PTHREAD_CREATE_DETACHED = 2
166     }
167 
168     enum
169     {
170         PTHREAD_INHERIT_SCHED   = 1,
171         PTHREAD_EXPLICIT_SCHED  = 2
172     }
173 
174     enum PTHREAD_MUTEX_INITIALIZER  = pthread_mutex_t(0x32AAABA7);
175     enum PTHREAD_ONCE_INIT          = pthread_once_t(0x30b1bcba);
176 
177     enum
178     {
179         PTHREAD_PROCESS_PRIVATE = 2,
180         PTHREAD_PROCESS_SHARED  = 1
181     }
182 }
183 else version (FreeBSD)
184 {
185     enum
186     {
187         PTHREAD_DETACHED            = 0x1,
188         PTHREAD_INHERIT_SCHED       = 0x4,
189         PTHREAD_NOFLOAT             = 0x8,
190 
191         PTHREAD_CREATE_DETACHED     = PTHREAD_DETACHED,
192         PTHREAD_CREATE_JOINABLE     = 0,
193         PTHREAD_EXPLICIT_SCHED      = 0,
194     }
195 
196     enum
197     {
198         PTHREAD_PROCESS_PRIVATE     = 0,
199         PTHREAD_PROCESS_SHARED      = 1,
200     }
201 
202     enum
203     {
204         PTHREAD_CANCEL_ENABLE       = 0,
205         PTHREAD_CANCEL_DISABLE      = 1,
206         PTHREAD_CANCEL_DEFERRED     = 0,
207         PTHREAD_CANCEL_ASYNCHRONOUS = 2,
208     }
209 
210     enum PTHREAD_CANCELED = cast(void*) -1;
211 
212     enum PTHREAD_NEEDS_INIT = 0;
213     enum PTHREAD_DONE_INIT  = 1;
214 
215     enum PTHREAD_MUTEX_INITIALIZER              = null;
216     enum PTHREAD_ONCE_INIT                      = null;
217     enum PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP  = null;
218     enum PTHREAD_COND_INITIALIZER               = null;
219     enum PTHREAD_RWLOCK_INITIALIZER             = null;
220 }
221 else version (NetBSD)
222 {
223     enum PRI_NONE = -1;
224     enum
225     {
226         PTHREAD_INHERIT_SCHED       = 0x0,
227 
228         PTHREAD_CREATE_DETACHED     = 1,
229         PTHREAD_CREATE_JOINABLE     = 0,
230         PTHREAD_EXPLICIT_SCHED      = 1,
231     }
232 
233     enum
234     {
235         PTHREAD_PROCESS_PRIVATE     = 0,
236         PTHREAD_PROCESS_SHARED      = 1,
237     }
238 
239     enum
240     {
241         PTHREAD_CANCEL_ENABLE       = 0,
242         PTHREAD_CANCEL_DISABLE      = 1,
243         PTHREAD_CANCEL_DEFERRED     = 0,
244         PTHREAD_CANCEL_ASYNCHRONOUS = 1,
245     }
246 
247     enum PTHREAD_CANCELED = cast(void*) 1;
248 
249     enum PTHREAD_DONE_INIT  = 1;
250 
251     enum PTHREAD_MUTEX_INITIALIZER              = pthread_mutex_t(0x33330003);
252 
253     enum PTHREAD_ONCE_INIT                      = pthread_once_t(PTHREAD_MUTEX_INITIALIZER);
254     enum PTHREAD_COND_INITIALIZER               = pthread_cond_t(0x55550005);
255     enum PTHREAD_RWLOCK_INITIALIZER             = pthread_rwlock_t(0x99990009);
256 }
257 else version (OpenBSD)
258 {
259     enum
260     {
261         PTHREAD_DETACHED            = 0x1,
262         PTHREAD_INHERIT_SCHED       = 0x4,
263         PTHREAD_NOFLOAT             = 0x8,
264 
265         PTHREAD_CREATE_DETACHED     = PTHREAD_DETACHED,
266         PTHREAD_CREATE_JOINABLE     = 0,
267         PTHREAD_EXPLICIT_SCHED      = 0,
268     }
269 
270     enum
271     {
272         PTHREAD_PROCESS_PRIVATE     = 0,
273         PTHREAD_PROCESS_SHARED      = 1,
274     }
275 
276     enum
277     {
278         PTHREAD_CANCEL_ENABLE       = 0,
279         PTHREAD_CANCEL_DISABLE      = 1,
280         PTHREAD_CANCEL_DEFERRED     = 0,
281         PTHREAD_CANCEL_ASYNCHRONOUS = 2,
282     }
283 
284     enum PTHREAD_CANCELED = cast(void*) 1;
285 
286     enum
287     {
288         PTHREAD_NEEDS_INIT = 0,
289         PTHREAD_DONE_INIT  = 1,
290     }
291 
292     enum PTHREAD_MUTEX_INITIALIZER              = null;
293     enum PTHREAD_ONCE_INIT                      = pthread_once_t.init;
294     enum PTHREAD_COND_INITIALIZER               = null;
295     enum PTHREAD_RWLOCK_INITIALIZER             = null;
296 }
297 else version (DragonFlyBSD)
298 {
299     enum
300     {
301         PTHREAD_DETACHED            = 0x1,
302         //PTHREAD_SCOPE_SYSTEM        = 0x2,    // defined below
303         PTHREAD_INHERIT_SCHED       = 0x4,
304         PTHREAD_NOFLOAT             = 0x8,
305 
306         PTHREAD_CREATE_DETACHED     = PTHREAD_DETACHED,
307         PTHREAD_CREATE_JOINABLE     = 0,
308         //PTHREAD_SCOPE_PROCESS       = 0,      // defined below
309         PTHREAD_EXPLICIT_SCHED      = 0,
310     }
311 
312     enum
313     {
314         PTHREAD_PROCESS_PRIVATE     = 0,
315         PTHREAD_PROCESS_SHARED      = 1,
316     }
317 
318     enum
319     {
320         PTHREAD_CANCEL_ENABLE       = 0,
321         PTHREAD_CANCEL_DISABLE      = 1,
322         PTHREAD_CANCEL_DEFERRED     = 0,
323         PTHREAD_CANCEL_ASYNCHRONOUS = 2,
324     }
325 
326     enum PTHREAD_CANCELED = cast(void*) -1;
327 
328     enum PTHREAD_NEEDS_INIT = 0;
329     enum PTHREAD_DONE_INIT  = 1;
330 
331     enum PTHREAD_MUTEX_INITIALIZER              = null;
332     enum PTHREAD_ONCE_INIT                      = pthread_once_t.init;
333     enum PTHREAD_COND_INITIALIZER               = null;
334     enum PTHREAD_RWLOCK_INITIALIZER             = null;
335 }
336 else version (Solaris)
337 {
338     enum
339     {
340         PTHREAD_INHERIT_SCHED = 0x01,
341         PTHREAD_NOFLOAT = 0x08,
342         PTHREAD_CREATE_DETACHED = 0x40,
343         PTHREAD_CREATE_JOINABLE = 0x00,
344         PTHREAD_EXPLICIT_SCHED = 0x00,
345     }
346 
347     enum
348     {
349         PTHREAD_PROCESS_PRIVATE = 0,
350         PTHREAD_PROCESS_SHARED = 1,
351     }
352 
353     enum
354     {
355         PTHREAD_CANCEL_ENABLE = 0,
356         PTHREAD_CANCEL_DISABLE = 1,
357         PTHREAD_CANCEL_DEFERRED = 0,
358         PTHREAD_CANCEL_ASYNCHRONOUS = 2,
359     }
360 
361     enum PTHREAD_CANCELED = cast(void*)-19;
362 
363     enum PTHREAD_MUTEX_INITIALIZER  = pthread_mutex_t.init;
364     enum PTHREAD_ONCE_INIT          = pthread_once_t.init;
365 }
366 else version (CRuntime_Bionic)
367 {
368     enum
369     {
370         PTHREAD_CREATE_JOINABLE,
371         PTHREAD_CREATE_DETACHED
372     }
373 
374     enum PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t.init;
375     enum PTHREAD_ONCE_INIT         = pthread_once_t.init;
376 
377     enum
378     {
379         PTHREAD_PROCESS_PRIVATE,
380         PTHREAD_PROCESS_SHARED
381     }
382 }
383 else version (CRuntime_Musl)
384 {
385     enum
386     {
387         PTHREAD_CREATE_JOINABLE = 0,
388         PTHREAD_CREATE_DETACHED = 1
389     }
390 
391     enum PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t.init;
392     enum PTHREAD_ONCE_INIT = pthread_once_t.init;
393 
394     enum
395     {
396         PTHREAD_PROCESS_PRIVATE = 0,
397         PTHREAD_PROCESS_SHARED = 1
398     }
399 }
400 else version (CRuntime_UClibc)
401 {
402     enum
403     {
404         PTHREAD_CANCEL_ENABLE,
405         PTHREAD_CANCEL_DISABLE
406     }
407 
408     enum
409     {
410         PTHREAD_CANCEL_DEFERRED,
411         PTHREAD_CANCEL_ASYNCHRONOUS
412     }
413 
414     enum PTHREAD_CANCELED   = cast(void*) -1;
415 
416     enum PTHREAD_MUTEX_INITIALIZER  = pthread_mutex_t.init;
417     enum PTHREAD_ONCE_INIT          = pthread_once_t.init;
418 
419     enum
420     {
421         PTHREAD_CREATE_JOINABLE,
422         PTHREAD_CREATE_DETACHED
423     }
424 
425     enum
426     {
427         PTHREAD_INHERIT_SCHED,
428         PTHREAD_EXPLICIT_SCHED
429     }
430 
431     enum
432     {
433         PTHREAD_PROCESS_PRIVATE,
434         PTHREAD_PROCESS_SHARED
435     }
436 }
437 else
438 {
439     static assert(false, "Unsupported platform");
440 }
441 
442 int pthread_atfork(void function(), void function(), void function());
443 @nogc {
444     int pthread_atfork(void function() @nogc, void function() @nogc, void function() @nogc);
445     int pthread_attr_destroy(pthread_attr_t*);
446     int pthread_attr_getdetachstate(const scope pthread_attr_t*, int*);
447     int pthread_attr_getschedparam(const scope pthread_attr_t*, sched_param*);
448     int pthread_attr_init(pthread_attr_t*);
449     int pthread_attr_setdetachstate(pthread_attr_t*, int);
450     int pthread_attr_setschedparam(const scope pthread_attr_t*, sched_param*);
451     int pthread_cancel(pthread_t);
452 }
453 
454 alias void function(void*) _pthread_cleanup_routine;
455 alias void function(void*) @nogc _pthread_cleanup_routine_nogc;
456 version (CRuntime_Glibc)
457 {
458     struct _pthread_cleanup_buffer
459     {
460         _pthread_cleanup_routine    __routine;
461         void*                       __arg;
462         int                         __canceltype;
463         _pthread_cleanup_buffer*    __prev;
464     }
465 
466     void _pthread_cleanup_push(_pthread_cleanup_buffer*, _pthread_cleanup_routine, void*);
467     void _pthread_cleanup_push(_pthread_cleanup_buffer*, _pthread_cleanup_routine_nogc, void*) @nogc;
468     void _pthread_cleanup_pop(_pthread_cleanup_buffer*, int);
469 
470     struct pthread_cleanup
471     {
472         _pthread_cleanup_buffer buffer = void;
473 
474         extern (D) void push(F: _pthread_cleanup_routine)(F routine, void* arg )
475         {
476             _pthread_cleanup_push( &buffer, routine, arg );
477         }
478 
479         extern (D) void pop()( int execute )
480         {
481             _pthread_cleanup_pop( &buffer, execute );
482         }
483     }
484 }
485 else version (Darwin)
486 {
487     struct _pthread_cleanup_buffer
488     {
489         _pthread_cleanup_routine    __routine;
490         void*                       __arg;
491         _pthread_cleanup_buffer*    __next;
492     }
493 
494     struct pthread_cleanup
495     {
496         _pthread_cleanup_buffer buffer = void;
497 
498         extern (D) void push(F: _pthread_cleanup_routine)(F routine, void* arg )
499         {
500             pthread_t self       = pthread_self();
501             buffer.__routine     = routine;
502             buffer.__arg         = arg;
503             buffer.__next        = cast(_pthread_cleanup_buffer*) self.__cleanup_stack;
504             self.__cleanup_stack = cast(pthread_handler_rec*) &buffer;
505         }
506 
507         extern (D) void pop()( int execute )
508         {
509             pthread_t self       = pthread_self();
510             self.__cleanup_stack = cast(pthread_handler_rec*) buffer.__next;
511             if ( execute )
512             {
513                 buffer.__routine( buffer.__arg );
514             }
515         }
516     }
517 }
518 else version (FreeBSD)
519 {
520     struct _pthread_cleanup_info
521     {
522         uintptr_t[8]    pthread_cleanup_pad;
523     }
524 
525     struct pthread_cleanup
526     {
527         _pthread_cleanup_info __cleanup_info__ = void;
528 
529         extern (D) void push(F: _pthread_cleanup_routine)(F cleanup_routine, void* cleanup_arg )
530         {
531             __pthread_cleanup_push_imp( cleanup_routine, cleanup_arg, &__cleanup_info__ );
532         }
533 
534         extern (D) void pop()( int execute )
535         {
536             __pthread_cleanup_pop_imp( execute );
537         }
538     }
539 
540     void __pthread_cleanup_push_imp(_pthread_cleanup_routine, void*, _pthread_cleanup_info*);
541     void __pthread_cleanup_push_imp(_pthread_cleanup_routine_nogc, void*, _pthread_cleanup_info*) @nogc;
542     void __pthread_cleanup_pop_imp(int);
543 }
544 else version (DragonFlyBSD)
545 {
546     struct _pthread_cleanup_info
547     {
548         uintptr_t[8]    pthread_cleanup_pad;
549     }
550 
551     struct pthread_cleanup
552     {
553         _pthread_cleanup_info __cleanup_info__ = void;
554 
555         extern (D) void push()( _pthread_cleanup_routine cleanup_routine, void* cleanup_arg )
556         {
557             _pthread_cleanup_push( cleanup_routine, cleanup_arg, &__cleanup_info__ );
558         }
559 
560         extern (D) void pop()( int execute )
561         {
562             _pthread_cleanup_pop( execute );
563         }
564     }
565 
566     void _pthread_cleanup_push(_pthread_cleanup_routine, void*, _pthread_cleanup_info*);
567     void _pthread_cleanup_pop(int);
568 }
569 else version (NetBSD)
570 {
571     struct _pthread_cleanup_store
572     {
573         void*[4]    pthread_cleanup_pad;
574     }
575 
576     struct pthread_cleanup
577     {
578         _pthread_cleanup_store __cleanup_info__ = void;
579 
580         extern (D) void push()( _pthread_cleanup_routine cleanup_routine, void* cleanup_arg )
581         {
582             pthread__cleanup_push( cleanup_routine, cleanup_arg, &__cleanup_info__ );
583         }
584 
585         extern (D) void pop()( int execute )
586         {
587             pthread__cleanup_pop( execute, &__cleanup_info__ );
588         }
589     }
590 
591     void pthread__cleanup_push(_pthread_cleanup_routine, void*, void*);
592     void pthread__cleanup_pop(int, void *);
593 }
594 else version (OpenBSD)
595 {
596     void pthread_cleanup_push(void function(void*), void*);
597     void pthread_cleanup_pop(int);
598 }
599 else version (Solaris)
600 {
601     caddr_t _getfp();
602 
603     struct _pthread_cleanup_info
604     {
605         uintptr_t[4] pthread_cleanup_pad;
606     }
607 
608     struct pthread_cleanup
609     {
610         _pthread_cleanup_info __cleanup_info__ = void;
611 
612         extern (D) void push(F: _pthread_cleanup_routine)(F cleanup_routine, void* cleanup_arg)
613         {
614             __pthread_cleanup_push(cleanup_routine, cleanup_arg, _getfp(), &__cleanup_info__);
615         }
616 
617         extern (D) void pop()(int execute)
618         {
619             __pthread_cleanup_pop(execute, &__cleanup_info__);
620         }
621     }
622 
623     void __pthread_cleanup_push(_pthread_cleanup_routine, void*, caddr_t, _pthread_cleanup_info*);
624     void __pthread_cleanup_push(_pthread_cleanup_routine_nogc, void*, caddr_t, _pthread_cleanup_info*) @nogc;
625     void __pthread_cleanup_pop(int, _pthread_cleanup_info*);
626 }
627 else version (CRuntime_Bionic)
628 {
629     struct __pthread_cleanup_t
630     {
631         __pthread_cleanup_t*     __cleanup_prev;
632         _pthread_cleanup_routine __cleanup_routine;
633         void*                    __cleanup_arg;
634     }
635 
636     void __pthread_cleanup_push(__pthread_cleanup_t*, _pthread_cleanup_routine, void*);
637     void __pthread_cleanup_push(__pthread_cleanup_t*, _pthread_cleanup_routine_nogc, void*) @nogc;
638     void __pthread_cleanup_pop(__pthread_cleanup_t*, int);
639 
640     struct pthread_cleanup
641     {
642         __pthread_cleanup_t __cleanup = void;
643 
644         extern (D) void push(F: _pthread_cleanup_routine)(F routine, void* arg )
645         {
646             __pthread_cleanup_push( &__cleanup, routine, arg );
647         }
648 
649         extern (D) void pop()( int execute )
650         {
651             __pthread_cleanup_pop( &__cleanup, execute );
652         }
653     }
654 }
655 else version (CRuntime_Musl)
656 {
657     struct __ptcb {
658         _pthread_cleanup_routine f;
659         void* __x;
660         __ptcb* __next;
661     }
662     void _pthread_cleanup_push(__ptcb*, _pthread_cleanup_routine, void*);
663     void _pthread_cleanup_pop(__ptcb*, int);
664 
665     struct pthread_cleanup
666     {
667         __ptcb __cleanup = void;
668 
669         extern (D) void push(F: _pthread_cleanup_routine)(F routine, void* arg )
670         {
671             _pthread_cleanup_push( &__cleanup, routine, arg );
672         }
673 
674         extern (D) void pop()( int execute )
675         {
676             _pthread_cleanup_pop( &__cleanup, execute );
677         }
678     }
679 }
680 else version (CRuntime_UClibc)
681 {
682     struct _pthread_cleanup_buffer
683     {
684         _pthread_cleanup_routine    __routine;
685         void*                       __arg;
686         int                         __canceltype;
687         _pthread_cleanup_buffer*    __prev;
688     }
689 
690     void _pthread_cleanup_push(_pthread_cleanup_buffer*, _pthread_cleanup_routine, void*);
691     void _pthread_cleanup_push(_pthread_cleanup_buffer*, _pthread_cleanup_routine_nogc, void*) @nogc;
692     void _pthread_cleanup_pop(_pthread_cleanup_buffer*, int);
693 
694     struct pthread_cleanup
695     {
696         _pthread_cleanup_buffer buffer = void;
697 
698         extern (D) void push(F: _pthread_cleanup_routine)(F routine, void* arg )
699         {
700             _pthread_cleanup_push( &buffer, routine, arg );
701         }
702 
703         extern (D) void pop()( int execute )
704         {
705             _pthread_cleanup_pop( &buffer, execute );
706         }
707     }
708 }
709 else
710 {
711     static assert(false, "Unsupported platform");
712 }
713 
714 @nogc:
715 
716 int pthread_cond_broadcast(pthread_cond_t*);
717 int pthread_cond_destroy(pthread_cond_t*);
718 int pthread_cond_init(const scope pthread_cond_t*, pthread_condattr_t*) @trusted;
719 int pthread_cond_signal(pthread_cond_t*);
720 int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const scope timespec*);
721 int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
722 int pthread_condattr_destroy(pthread_condattr_t*);
723 int pthread_condattr_init(pthread_condattr_t*);
724 int pthread_create(pthread_t*, const scope pthread_attr_t*, void* function(void*), void*);
725 int pthread_detach(pthread_t);
726 int pthread_equal(pthread_t, pthread_t);
727 void pthread_exit(void*);
728 void* pthread_getspecific(pthread_key_t);
729 int pthread_join(pthread_t, void**);
730 int pthread_key_create(pthread_key_t*, void function(void*));
731 int pthread_key_delete(pthread_key_t);
732 int pthread_mutex_destroy(pthread_mutex_t*);
733 int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*) @trusted;
734 int pthread_mutex_lock(pthread_mutex_t*);
735 int pthread_mutex_lock(shared(pthread_mutex_t)*);
736 int pthread_mutex_trylock(pthread_mutex_t*);
737 int pthread_mutex_trylock(shared(pthread_mutex_t)*);
738 int pthread_mutex_unlock(pthread_mutex_t*);
739 int pthread_mutex_unlock(shared(pthread_mutex_t)*);
740 int pthread_mutexattr_destroy(pthread_mutexattr_t*);
741 int pthread_mutexattr_init(pthread_mutexattr_t*) @trusted;
742 int pthread_once(pthread_once_t*, void function());
743 int pthread_rwlock_destroy(pthread_rwlock_t*);
744 int pthread_rwlock_init(pthread_rwlock_t*, const scope pthread_rwlockattr_t*);
745 int pthread_rwlock_rdlock(pthread_rwlock_t*);
746 int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
747 int pthread_rwlock_trywrlock(pthread_rwlock_t*);
748 int pthread_rwlock_unlock(pthread_rwlock_t*);
749 int pthread_rwlock_wrlock(pthread_rwlock_t*);
750 int pthread_rwlockattr_destroy(pthread_rwlockattr_t*);
751 int pthread_rwlockattr_init(pthread_rwlockattr_t*);
752 pthread_t pthread_self();
753 int pthread_setcancelstate(int, int*);
754 int pthread_setcanceltype(int, int*);
755 int pthread_setspecific(pthread_key_t, const scope void*);
756 void pthread_testcancel();
757 
758 //
759 // Barrier (BAR)
760 //
761 /*
762 PTHREAD_BARRIER_SERIAL_THREAD
763 
764 int pthread_barrier_destroy(pthread_barrier_t*);
765 int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
766 int pthread_barrier_wait(pthread_barrier_t*);
767 int pthread_barrierattr_destroy(pthread_barrierattr_t*);
768 int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*); (BAR|TSH)
769 int pthread_barrierattr_init(pthread_barrierattr_t*);
770 int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int); (BAR|TSH)
771 */
772 
773 version (CRuntime_Glibc)
774 {
775     enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
776 
777     int pthread_barrier_destroy(pthread_barrier_t*);
778     int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
779     int pthread_barrier_wait(pthread_barrier_t*);
780     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
781     int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
782     int pthread_barrierattr_init(pthread_barrierattr_t*);
783     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
784 }
785 else version (FreeBSD)
786 {
787     enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
788 
789     int pthread_barrier_destroy(pthread_barrier_t*);
790     int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
791     int pthread_barrier_wait(pthread_barrier_t*);
792     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
793     int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
794     int pthread_barrierattr_init(pthread_barrierattr_t*);
795     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
796 }
797 else version (DragonFlyBSD)
798 {
799     enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
800     enum PTHREAD_KEYS_MAX              = 256;
801     enum PTHREAD_STACK_MIN             = 16384;
802     enum PTHREAD_THREADS_MAX           = c_ulong.max;
803 
804     int pthread_barrier_destroy(pthread_barrier_t*);
805     int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
806     int pthread_barrier_wait(pthread_barrier_t*);
807     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
808     int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
809     int pthread_barrierattr_init(pthread_barrierattr_t*);
810     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
811 }
812 else version (NetBSD)
813 {
814     enum PTHREAD_BARRIER_SERIAL_THREAD = 1234567;
815 
816     int pthread_barrier_destroy(pthread_barrier_t*);
817     int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
818     int pthread_barrier_wait(pthread_barrier_t*);
819     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
820     int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
821     int pthread_barrierattr_init(pthread_barrierattr_t*);
822     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
823 }
824 else version (OpenBSD)
825 {
826     enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
827 
828     int pthread_barrier_destroy(pthread_barrier_t*);
829     int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
830     int pthread_barrier_wait(pthread_barrier_t*);
831     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
832     int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
833     int pthread_barrierattr_init(pthread_barrierattr_t*);
834     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
835 }
836 else version (Darwin)
837 {
838 }
839 else version (Solaris)
840 {
841     enum PTHREAD_BARRIER_SERIAL_THREAD = -2;
842 
843     int pthread_barrier_destroy(pthread_barrier_t*);
844     int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
845     int pthread_barrier_wait(pthread_barrier_t*);
846     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
847     int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
848     int pthread_barrierattr_init(pthread_barrierattr_t*);
849     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
850 }
851 else version (CRuntime_Bionic)
852 {
853 }
854 else version (CRuntime_Musl)
855 {
856     enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
857 
858     int pthread_barrier_destroy(pthread_barrier_t*);
859     int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
860     int pthread_barrier_wait(pthread_barrier_t*);
861     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
862     int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
863     int pthread_barrierattr_init(pthread_barrierattr_t*);
864     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
865 }
866 else version (CRuntime_UClibc)
867 {
868     enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
869 
870     int pthread_barrier_destroy(pthread_barrier_t*);
871     int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
872     int pthread_barrier_wait(pthread_barrier_t*);
873     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
874     int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
875     int pthread_barrierattr_init(pthread_barrierattr_t*);
876     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
877 }
878 else
879 {
880     static assert(false, "Unsupported platform");
881 }
882 
883 //
884 // Clock (CS)
885 //
886 /*
887 int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
888 int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
889 */
890 version (CRuntime_Glibc)
891 {
892     int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
893     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
894 }
895 else version (FreeBSD)
896 {
897     int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
898     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
899 }
900 else version (DragonFlyBSD)
901 {
902     int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
903     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
904 }
905 else version (NetBSD)
906 {
907     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
908 }
909 else version (OpenBSD)
910 {
911     int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
912     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
913 }
914 else version (Darwin)
915 {
916 }
917 else version (Solaris)
918 {
919     int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
920     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
921 }
922 else version (CRuntime_Bionic)
923 {
924 }
925 else version (CRuntime_Musl)
926 {
927     int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
928     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
929 }
930 else version (CRuntime_UClibc)
931 {
932     int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
933     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
934 }
935 else
936 {
937     static assert(false, "Unsupported platform");
938 }
939 
940 //
941 // Spinlock (SPI)
942 //
943 /*
944 int pthread_spin_destroy(pthread_spinlock_t*);
945 int pthread_spin_init(pthread_spinlock_t*, int);
946 int pthread_spin_lock(pthread_spinlock_t*);
947 int pthread_spin_trylock(pthread_spinlock_t*);
948 int pthread_spin_unlock(pthread_spinlock_t*);
949 */
950 
951 version (CRuntime_Glibc)
952 {
953     int pthread_spin_destroy(pthread_spinlock_t*);
954     int pthread_spin_init(pthread_spinlock_t*, int);
955     int pthread_spin_lock(pthread_spinlock_t*);
956     int pthread_spin_trylock(pthread_spinlock_t*);
957     int pthread_spin_unlock(pthread_spinlock_t*);
958 }
959 else version (FreeBSD)
960 {
961     int pthread_spin_init(pthread_spinlock_t*, int);
962     int pthread_spin_destroy(pthread_spinlock_t*);
963     int pthread_spin_lock(pthread_spinlock_t*);
964     int pthread_spin_trylock(pthread_spinlock_t*);
965     int pthread_spin_unlock(pthread_spinlock_t*);
966 }
967 else version (DragonFlyBSD)
968 {
969     int pthread_spin_init(pthread_spinlock_t*, int);
970     int pthread_spin_destroy(pthread_spinlock_t*);
971     int pthread_spin_lock(pthread_spinlock_t*);
972     int pthread_spin_trylock(pthread_spinlock_t*);
973     int pthread_spin_unlock(pthread_spinlock_t*);
974 }
975 else version (NetBSD)
976 {
977     int pthread_spin_init(pthread_spinlock_t*, int);
978     int pthread_spin_destroy(pthread_spinlock_t*);
979     int pthread_spin_lock(pthread_spinlock_t*);
980     int pthread_spin_trylock(pthread_spinlock_t*);
981     int pthread_spin_unlock(pthread_spinlock_t*);
982 }
983 else version (OpenBSD)
984 {
985     int pthread_spin_init(pthread_spinlock_t*, int);
986     int pthread_spin_destroy(pthread_spinlock_t*);
987     int pthread_spin_lock(pthread_spinlock_t*);
988     int pthread_spin_trylock(pthread_spinlock_t*);
989     int pthread_spin_unlock(pthread_spinlock_t*);
990 }
991 else version (Darwin)
992 {
993 }
994 else version (Solaris)
995 {
996     int pthread_spin_init(pthread_spinlock_t*, int);
997     int pthread_spin_destroy(pthread_spinlock_t*);
998     int pthread_spin_lock(pthread_spinlock_t*);
999     int pthread_spin_trylock(pthread_spinlock_t*);
1000     int pthread_spin_unlock(pthread_spinlock_t*);
1001 }
1002 else version (CRuntime_Bionic)
1003 {
1004 }
1005 else version (CRuntime_Musl)
1006 {
1007     int pthread_spin_destroy(pthread_spinlock_t*);
1008     int pthread_spin_init(pthread_spinlock_t*, int);
1009     int pthread_spin_lock(pthread_spinlock_t*);
1010     int pthread_spin_trylock(pthread_spinlock_t*);
1011     int pthread_spin_unlock(pthread_spinlock_t*);
1012 }
1013 else version (CRuntime_UClibc)
1014 {
1015     int pthread_spin_destroy(pthread_spinlock_t*);
1016     int pthread_spin_init(pthread_spinlock_t*, int);
1017     int pthread_spin_lock(pthread_spinlock_t*);
1018     int pthread_spin_trylock(pthread_spinlock_t*);
1019     int pthread_spin_unlock(pthread_spinlock_t*);
1020 }
1021 else
1022 {
1023     static assert(false, "Unsupported platform");
1024 }
1025 
1026 //
1027 // XOpen (XSI)
1028 //
1029 /*
1030 PTHREAD_MUTEX_DEFAULT
1031 PTHREAD_MUTEX_ERRORCHECK
1032 PTHREAD_MUTEX_NORMAL
1033 PTHREAD_MUTEX_RECURSIVE
1034 
1035 int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
1036 int pthread_attr_setguardsize(pthread_attr_t*, size_t);
1037 int pthread_getconcurrency();
1038 int pthread_mutexattr_gettype(const scope pthread_mutexattr_t*, int*);
1039 int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
1040 int pthread_setconcurrency(int);
1041 */
1042 
1043 version (CRuntime_Glibc)
1044 {
1045     enum PTHREAD_MUTEX_NORMAL       = 0;
1046     enum PTHREAD_MUTEX_RECURSIVE    = 1;
1047     enum PTHREAD_MUTEX_ERRORCHECK   = 2;
1048     enum PTHREAD_MUTEX_DEFAULT      = PTHREAD_MUTEX_NORMAL;
1049 
1050     int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
1051     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
1052     int pthread_getconcurrency();
1053     int pthread_mutexattr_gettype(const scope pthread_mutexattr_t*, int*);
1054     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
1055     int pthread_setconcurrency(int);
1056 }
1057 else version (Darwin)
1058 {
1059     enum PTHREAD_MUTEX_NORMAL       = 0;
1060     enum PTHREAD_MUTEX_ERRORCHECK   = 1;
1061     enum PTHREAD_MUTEX_RECURSIVE    = 2;
1062     enum PTHREAD_MUTEX_DEFAULT      = PTHREAD_MUTEX_NORMAL;
1063 
1064     int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
1065     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
1066     int pthread_getconcurrency();
1067     int pthread_mutexattr_gettype(const scope pthread_mutexattr_t*, int*);
1068     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
1069     int pthread_setconcurrency(int);
1070 }
1071 else version (FreeBSD)
1072 {
1073     enum
1074     {
1075         PTHREAD_MUTEX_ERRORCHECK    = 1,
1076         PTHREAD_MUTEX_RECURSIVE     = 2,
1077         PTHREAD_MUTEX_NORMAL        = 3,
1078         PTHREAD_MUTEX_ADAPTIVE_NP   = 4,
1079         PTHREAD_MUTEX_TYPE_MAX
1080     }
1081     enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
1082 
1083     int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
1084     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
1085     int pthread_getconcurrency();
1086     int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
1087     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
1088     int pthread_setconcurrency(int);
1089 }
1090 else version (NetBSD)
1091 {
1092     enum
1093     {
1094         PTHREAD_MUTEX_NORMAL        = 0,
1095         PTHREAD_MUTEX_ERRORCHECK    = 1,
1096         PTHREAD_MUTEX_RECURSIVE     = 2,
1097         PTHREAD_MUTEX_TYPE_MAX
1098     }
1099     enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
1100 
1101     int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
1102     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
1103     int pthread_getconcurrency();
1104     int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
1105     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
1106     int pthread_setconcurrency(int);
1107 }
1108 else version (OpenBSD)
1109 {
1110     enum
1111     {
1112         PTHREAD_MUTEX_ERRORCHECK    = 1,
1113         PTHREAD_MUTEX_RECURSIVE     = 2,
1114         PTHREAD_MUTEX_NORMAL        = 3,
1115         PTHREAD_MUTEX_ADAPTIVE_NP   = 4,
1116         PTHREAD_MUTEX_TYPE_MAX
1117     }
1118     enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
1119 
1120     int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
1121     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
1122     int pthread_getconcurrency();
1123     int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
1124     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
1125     int pthread_setconcurrency(int);
1126 }
1127 else version (DragonFlyBSD)
1128 {
1129     enum
1130     {
1131         PTHREAD_MUTEX_ERRORCHECK    = 1,
1132         PTHREAD_MUTEX_RECURSIVE     = 2,
1133         PTHREAD_MUTEX_NORMAL        = 3,
1134         PTHREAD_MUTEX_TYPE_MAX
1135     }
1136     enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
1137 
1138     int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
1139     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
1140     int pthread_getconcurrency();
1141     int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
1142     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
1143     int pthread_setconcurrency(int);
1144 }
1145 else version (Solaris)
1146 {
1147     enum
1148     {
1149         PTHREAD_MUTEX_ERRORCHECK    = 2,
1150         PTHREAD_MUTEX_RECURSIVE     = 4,
1151         PTHREAD_MUTEX_NORMAL        = 0,
1152     }
1153 
1154     enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL;
1155 
1156     int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
1157     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
1158     int pthread_getconcurrency();
1159     int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
1160     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
1161     int pthread_setconcurrency(int);
1162 }
1163 else version (CRuntime_Bionic)
1164 {
1165     enum PTHREAD_MUTEX_NORMAL     = 0;
1166     enum PTHREAD_MUTEX_RECURSIVE  = 1;
1167     enum PTHREAD_MUTEX_ERRORCHECK = 2;
1168     enum PTHREAD_MUTEX_DEFAULT    = PTHREAD_MUTEX_NORMAL;
1169 
1170     int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
1171     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
1172     int pthread_mutexattr_gettype(const scope pthread_mutexattr_t*, int*);
1173     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
1174 }
1175 else version (CRuntime_Musl)
1176 {
1177     enum {
1178         PTHREAD_MUTEX_NORMAL      = 0,
1179         PTHREAD_MUTEX_RECURSIVE   = 1,
1180         PTHREAD_MUTEX_ERRORCHECK  = 2,
1181         PTHREAD_MUTEX_DEFAULT     = PTHREAD_MUTEX_NORMAL,
1182     }
1183     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
1184 }
1185 else version (CRuntime_UClibc)
1186 {
1187     enum
1188     {
1189       PTHREAD_MUTEX_TIMED_NP,
1190       PTHREAD_MUTEX_RECURSIVE_NP,
1191       PTHREAD_MUTEX_ERRORCHECK_NP,
1192       PTHREAD_MUTEX_ADAPTIVE_NP,
1193       PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
1194       PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
1195       PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
1196       PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL,
1197       PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
1198     }
1199 
1200     int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
1201     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
1202     int pthread_getconcurrency();
1203     int pthread_mutexattr_gettype(const scope pthread_mutexattr_t*, int*);
1204     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
1205     int pthread_setconcurrency(int);
1206 }
1207 else
1208 {
1209     static assert(false, "Unsupported platform");
1210 }
1211 
1212 //
1213 // CPU Time (TCT)
1214 //
1215 /*
1216 int pthread_getcpuclockid(pthread_t, clockid_t*);
1217 */
1218 
1219 version (CRuntime_Glibc)
1220 {
1221     int pthread_getcpuclockid(pthread_t, clockid_t*);
1222 }
1223 else version (FreeBSD)
1224 {
1225     int pthread_getcpuclockid(pthread_t, clockid_t*);
1226 }
1227 else version (DragonFlyBSD)
1228 {
1229     int pthread_getcpuclockid(pthread_t, clockid_t*);
1230 }
1231 else version (NetBSD)
1232 {
1233 }
1234 else version (OpenBSD)
1235 {
1236     int pthread_getcpuclockid(pthread_t, clockid_t*);
1237 }
1238 else version (Darwin)
1239 {
1240 }
1241 else version (Solaris)
1242 {
1243 }
1244 else version (CRuntime_Bionic)
1245 {
1246     int pthread_getcpuclockid(pthread_t, clockid_t*);
1247 }
1248 else version (CRuntime_Musl)
1249 {
1250     int pthread_getcpuclockid(pthread_t, clockid_t*);
1251 }
1252 else version (CRuntime_UClibc)
1253 {
1254     int pthread_getcpuclockid(pthread_t, clockid_t*);
1255 }
1256 else
1257 {
1258     static assert(false, "Unsupported platform");
1259 }
1260 
1261 //
1262 // Timeouts (TMO)
1263 //
1264 /*
1265 int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
1266 int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
1267 int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
1268 */
1269 
1270 version (CRuntime_Glibc)
1271 {
1272     int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
1273     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
1274     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
1275 }
1276 else version (Darwin)
1277 {
1278     int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
1279     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
1280     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
1281 }
1282 else version (FreeBSD)
1283 {
1284     int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
1285     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
1286     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
1287 }
1288 else version (NetBSD)
1289 {
1290     int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
1291     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
1292     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
1293 }
1294 else version (OpenBSD)
1295 {
1296     int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
1297     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
1298     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
1299 }
1300 else version (DragonFlyBSD)
1301 {
1302     int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
1303     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
1304     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
1305 }
1306 else version (Solaris)
1307 {
1308     int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
1309     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
1310     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
1311 }
1312 else version (CRuntime_Bionic)
1313 {
1314     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
1315     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
1316 }
1317 else version (CRuntime_Musl)
1318 {
1319     int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
1320     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
1321     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
1322 }
1323 else version (CRuntime_UClibc)
1324 {
1325     int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
1326     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
1327     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
1328 }
1329 else
1330 {
1331     static assert(false, "Unsupported platform");
1332 }
1333 
1334 //
1335 // Priority (TPI|TPP)
1336 //
1337 /*
1338 PTHREAD_PRIO_INHERIT (TPI)
1339 PTHREAD_PRIO_NONE (TPP|TPI)
1340 PTHREAD_PRIO_PROTECT (TPI)
1341 
1342 int pthread_mutex_getprioceiling(const scope pthread_mutex_t*, int*); (TPP)
1343 int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*); (TPP)
1344 int pthread_mutexattr_getprioceiling(pthread_mutexattr_t*, int*); (TPP)
1345 int pthread_mutexattr_getprotocol(const scope pthread_mutexattr_t*, int*); (TPI|TPP)
1346 int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int); (TPP)
1347 int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int); (TPI|TPP)
1348 */
1349 version (Darwin)
1350 {
1351     enum
1352     {
1353         PTHREAD_PRIO_NONE,
1354         PTHREAD_PRIO_INHERIT,
1355         PTHREAD_PRIO_PROTECT
1356     }
1357 
1358     int pthread_mutex_getprioceiling(const scope pthread_mutex_t*, int*);
1359     int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*);
1360     int pthread_mutexattr_getprioceiling(const scope pthread_mutexattr_t*, int*);
1361     int pthread_mutexattr_getprotocol(const scope pthread_mutexattr_t*, int*);
1362     int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int);
1363     int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int);
1364 }
1365 else version (Solaris)
1366 {
1367     enum
1368     {
1369         PTHREAD_PRIO_NONE    = 0x00,
1370         PTHREAD_PRIO_INHERIT = 0x10,
1371         PTHREAD_PRIO_PROTECT = 0x20,
1372     }
1373 
1374     int pthread_mutex_getprioceiling(const scope pthread_mutex_t*, int*);
1375     int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*);
1376     int pthread_mutexattr_getprioceiling(const scope pthread_mutexattr_t*, int*);
1377     int pthread_mutexattr_getprotocol(const scope pthread_mutexattr_t*, int*);
1378     int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int);
1379     int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int);
1380 }
1381 
1382 //
1383 // Scheduling (TPS)
1384 //
1385 /*
1386 PTHREAD_SCOPE_PROCESS
1387 PTHREAD_SCOPE_SYSTEM
1388 
1389 int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
1390 int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
1391 int pthread_attr_getscope(const scope pthread_attr_t*, int*);
1392 int pthread_attr_setinheritsched(pthread_attr_t*, int);
1393 int pthread_attr_setschedpolicy(pthread_attr_t*, int);
1394 int pthread_attr_setscope(pthread_attr_t*, int);
1395 int pthread_getschedparam(pthread_t, int*, sched_param*);
1396 int pthread_setschedparam(pthread_t, int, const scope sched_param*);
1397 int pthread_setschedprio(pthread_t, int);
1398 */
1399 
1400 version (CRuntime_Glibc)
1401 {
1402     enum
1403     {
1404         PTHREAD_SCOPE_SYSTEM,
1405         PTHREAD_SCOPE_PROCESS
1406     }
1407 
1408     int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
1409     int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
1410     int pthread_attr_getscope(const scope pthread_attr_t*, int*);
1411     int pthread_attr_setinheritsched(pthread_attr_t*, int);
1412     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
1413     int pthread_attr_setscope(pthread_attr_t*, int);
1414     int pthread_getschedparam(pthread_t, int*, sched_param*);
1415     int pthread_setschedparam(pthread_t, int, const scope sched_param*);
1416     int pthread_setschedprio(pthread_t, int);
1417 }
1418 else version (Darwin)
1419 {
1420     enum
1421     {
1422         PTHREAD_SCOPE_SYSTEM    = 1,
1423         PTHREAD_SCOPE_PROCESS   = 2
1424     }
1425 
1426     int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
1427     int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
1428     int pthread_attr_getscope(const scope pthread_attr_t*, int*);
1429     int pthread_attr_setinheritsched(pthread_attr_t*, int);
1430     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
1431     int pthread_attr_setscope(pthread_attr_t*, int);
1432     int pthread_getschedparam(pthread_t, int*, sched_param*);
1433     int pthread_setschedparam(pthread_t, int, const scope sched_param*);
1434     // int pthread_setschedprio(pthread_t, int); // not implemented
1435 }
1436 else version (FreeBSD)
1437 {
1438     enum
1439     {
1440         PTHREAD_SCOPE_PROCESS   = 0,
1441         PTHREAD_SCOPE_SYSTEM    = 0x2
1442     }
1443 
1444     int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
1445     int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
1446     int pthread_attr_getscope(const scope pthread_attr_t*, int*);
1447     int pthread_attr_setinheritsched(pthread_attr_t*, int);
1448     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
1449     int pthread_attr_setscope(const scope pthread_attr_t*, int);
1450     int pthread_getschedparam(pthread_t, int*, sched_param*);
1451     int pthread_setschedparam(pthread_t, int, sched_param*);
1452     // int pthread_setschedprio(pthread_t, int); // not implemented
1453 }
1454 else version (NetBSD)
1455 {
1456     enum
1457     {
1458         PTHREAD_SCOPE_PROCESS   = 0,
1459         PTHREAD_SCOPE_SYSTEM    = 0x1
1460     }
1461 
1462     int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
1463     int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
1464     int pthread_attr_getscope(const scope pthread_attr_t*, int*);
1465     int pthread_attr_setinheritsched(pthread_attr_t*, int);
1466     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
1467     int pthread_attr_setscope(const scope pthread_attr_t*, int);
1468     int pthread_getschedparam(pthread_t, int*, sched_param*);
1469     int pthread_setschedparam(pthread_t, int, sched_param*);
1470     //int pthread_setschedprio(pthread_t, int);
1471 }
1472 else version (OpenBSD)
1473 {
1474     enum
1475     {
1476         PTHREAD_SCOPE_PROCESS   = 0,
1477         PTHREAD_SCOPE_SYSTEM    = 0x2
1478     }
1479 
1480     int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
1481     int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
1482     int pthread_attr_getscope(const scope pthread_attr_t*, int*);
1483     int pthread_attr_setinheritsched(pthread_attr_t*, int);
1484     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
1485     int pthread_attr_setscope(const scope pthread_attr_t*, int);
1486     int pthread_getschedparam(pthread_t, int*, sched_param*);
1487     int pthread_setschedparam(pthread_t, int, sched_param*);
1488     // int pthread_setschedprio(pthread_t, int); // not implemented
1489 }
1490 else version (DragonFlyBSD)
1491 {
1492     enum
1493     {
1494         PTHREAD_SCOPE_PROCESS   = 0,
1495         PTHREAD_SCOPE_SYSTEM    = 0x2
1496     }
1497 
1498     int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
1499     int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
1500     int pthread_attr_getscope(const scope pthread_attr_t*, int*);
1501     int pthread_attr_setinheritsched(pthread_attr_t*, int);
1502     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
1503     int pthread_attr_setscope(const scope pthread_attr_t*, int);
1504     int pthread_getschedparam(pthread_t, int*, sched_param*);
1505     int pthread_setschedparam(pthread_t, int, sched_param*);
1506 }
1507 else version (Solaris)
1508 {
1509     enum
1510     {
1511         PTHREAD_SCOPE_PROCESS = 0,
1512         PTHREAD_SCOPE_SYSTEM = 1,
1513     }
1514 
1515     int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
1516     int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
1517     int pthread_attr_getscope(const scope pthread_attr_t*, int*);
1518     int pthread_attr_setinheritsched(pthread_attr_t*, int);
1519     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
1520     int pthread_attr_setscope(const scope pthread_attr_t*, int);
1521     int pthread_getschedparam(pthread_t, int*, sched_param*);
1522     int pthread_setschedparam(pthread_t, int, sched_param*);
1523     int pthread_setschedprio(pthread_t, int);
1524 }
1525 else version (CRuntime_Bionic)
1526 {
1527     enum
1528     {
1529         PTHREAD_SCOPE_SYSTEM,
1530         PTHREAD_SCOPE_PROCESS
1531     }
1532 
1533     int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
1534     int pthread_attr_getscope(const scope pthread_attr_t*);
1535     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
1536     int pthread_attr_setscope(pthread_attr_t*, int);
1537     int pthread_getschedparam(pthread_t, int*, sched_param*);
1538     int pthread_setschedparam(pthread_t, int, const scope sched_param*);
1539 }
1540 else version (CRuntime_Musl)
1541 {
1542     enum
1543     {
1544         PTHREAD_SCOPE_SYSTEM,
1545         PTHREAD_SCOPE_PROCESS
1546     }
1547 
1548     int pthread_getschedparam(pthread_t, int*, sched_param*);
1549     int pthread_setschedparam(pthread_t, int, const scope sched_param*);
1550     int pthread_setschedprio(pthread_t, int);
1551 }
1552 else version (CRuntime_UClibc)
1553 {
1554     enum
1555     {
1556         PTHREAD_SCOPE_SYSTEM,
1557         PTHREAD_SCOPE_PROCESS
1558     }
1559 
1560     int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
1561     int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
1562     int pthread_attr_getscope(const scope pthread_attr_t*, int*);
1563     int pthread_attr_setinheritsched(pthread_attr_t*, int);
1564     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
1565     int pthread_attr_setscope(pthread_attr_t*, int);
1566     int pthread_getschedparam(pthread_t, int*, sched_param*);
1567     int pthread_setschedparam(pthread_t, int, const scope sched_param*);
1568     int pthread_setschedprio(pthread_t, int);
1569 }
1570 else
1571 {
1572     static assert(false, "Unsupported platform");
1573 }
1574 
1575 //
1576 // Stack (TSA|TSS)
1577 //
1578 /*
1579 int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*); (TSA|TSS)
1580 int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**); (TSA)
1581 int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*); (TSS)
1582 int pthread_attr_setstack(pthread_attr_t*, void*, size_t); (TSA|TSS)
1583 int pthread_attr_setstackaddr(pthread_attr_t*, void*); (TSA)
1584 int pthread_attr_setstacksize(pthread_attr_t*, size_t); (TSS)
1585 */
1586 
1587 version (CRuntime_Glibc)
1588 {
1589     int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
1590     int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
1591     int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
1592     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
1593     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
1594     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
1595 }
1596 else version (Darwin)
1597 {
1598     int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
1599     int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
1600     int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
1601     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
1602     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
1603     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
1604 }
1605 else version (FreeBSD)
1606 {
1607     int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
1608     int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
1609     int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
1610     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
1611     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
1612     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
1613 }
1614 else version (NetBSD)
1615 {
1616     int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
1617     int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
1618     int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
1619     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
1620     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
1621     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
1622 }
1623 else version (OpenBSD)
1624 {
1625     int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
1626     int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
1627     int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
1628     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
1629     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
1630     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
1631 }
1632 else version (DragonFlyBSD)
1633 {
1634     int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
1635     int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
1636     int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
1637     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
1638     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
1639     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
1640 }
1641 else version (Solaris)
1642 {
1643     int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
1644     int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
1645     int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
1646     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
1647     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
1648     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
1649 }
1650 else version (CRuntime_Bionic)
1651 {
1652     int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
1653     int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
1654     int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
1655     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
1656     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
1657     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
1658 }
1659 else version (CRuntime_Musl)
1660 {
1661     int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
1662     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
1663 }
1664 else version (CRuntime_UClibc)
1665 {
1666     int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
1667     int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
1668     int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
1669     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
1670     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
1671     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
1672 }
1673 else
1674 {
1675     static assert(false, "Unsupported platform");
1676 }
1677 
1678 //
1679 // Shared Synchronization (TSH)
1680 //
1681 /*
1682 int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
1683 int pthread_condattr_setpshared(pthread_condattr_t*, int);
1684 int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
1685 int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
1686 int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
1687 int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
1688 */
1689 
1690 version (CRuntime_Glibc)
1691 {
1692     int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
1693     int pthread_condattr_setpshared(pthread_condattr_t*, int);
1694     int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
1695     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
1696     int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
1697     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
1698 }
1699 else version (FreeBSD)
1700 {
1701     int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
1702     int pthread_condattr_setpshared(pthread_condattr_t*, int);
1703     int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
1704     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
1705     int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
1706     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
1707 }
1708 else version (NetBSD)
1709 {
1710     int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
1711     int pthread_condattr_setpshared(pthread_condattr_t*, int);
1712     int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
1713     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
1714     int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
1715     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
1716 }
1717 else version (OpenBSD)
1718 {
1719 }
1720 else version (DragonFlyBSD)
1721 {
1722     int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
1723     int pthread_condattr_setpshared(pthread_condattr_t*, int);
1724     int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
1725     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
1726     int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
1727     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
1728 }
1729 else version (Darwin)
1730 {
1731     int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
1732     int pthread_condattr_setpshared(pthread_condattr_t*, int);
1733     int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
1734     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
1735     int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
1736     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
1737 }
1738 else version (Solaris)
1739 {
1740     int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
1741     int pthread_condattr_setpshared(pthread_condattr_t*, int);
1742     int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
1743     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
1744     int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
1745     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
1746 }
1747 else version (CRuntime_Bionic)
1748 {
1749     int pthread_condattr_getpshared(pthread_condattr_t*, int*);
1750     int pthread_condattr_setpshared(pthread_condattr_t*, int);
1751     int pthread_mutexattr_getpshared(pthread_mutexattr_t*, int*);
1752     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
1753     int pthread_rwlockattr_getpshared(pthread_rwlockattr_t*, int*);
1754     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
1755 }
1756 else version (CRuntime_Musl)
1757 {
1758     int pthread_condattr_getpshared(pthread_condattr_t*, int*);
1759     int pthread_condattr_setpshared(pthread_condattr_t*, int);
1760     int pthread_mutexattr_getpshared(pthread_mutexattr_t*, int*);
1761     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
1762     int pthread_rwlockattr_getpshared(pthread_rwlockattr_t*, int*);
1763     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
1764 }
1765 else version (CRuntime_UClibc)
1766 {
1767     int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
1768     int pthread_condattr_setpshared(pthread_condattr_t*, int);
1769     int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
1770     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
1771     int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
1772     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
1773 }
1774 else
1775 {
1776     static assert(false, "Unsupported platform");
1777 }