]> git.saurik.com Git - apple/libpthread.git/blame - pthread/pthread.h
libpthread-218.60.3.tar.gz
[apple/libpthread.git] / pthread / pthread.h
CommitLineData
f1a1da6c
A
1/*
2 * Copyright (c) 2000-2012 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*
24 * Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991
25 * All Rights Reserved
26 *
27 * Permission to use, copy, modify, and distribute this software and
28 * its documentation for any purpose and without fee is hereby granted,
29 * provided that the above copyright notice appears in all copies and
30 * that both the copyright notice and this permission notice appear in
31 * supporting documentation.
32 *
33 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
34 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
35 * FOR A PARTICULAR PURPOSE.
36 *
37 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
38 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
40 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
41 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
42 *
43 */
44/*
45 * MkLinux
46 */
47
48/*
49 * POSIX Threads - IEEE 1003.1c
50 */
51
52#ifndef _PTHREAD_H
53#define _PTHREAD_H
54
55#include <_types.h>
56#ifndef __POSIX_LIB__
57#include <pthread/pthread_impl.h>
58#endif
59#include <pthread/sched.h>
60#include <time.h>
61#include <sys/_pthread/_pthread_types.h>
62#include <sys/_pthread/_pthread_attr_t.h>
63#include <sys/_pthread/_pthread_cond_t.h>
64#include <sys/_pthread/_pthread_condattr_t.h>
65#include <sys/_pthread/_pthread_key_t.h>
66#include <sys/_pthread/_pthread_mutex_t.h>
67#include <sys/_pthread/_pthread_mutexattr_t.h>
68#include <sys/_pthread/_pthread_once_t.h>
69#include <sys/_pthread/_pthread_rwlock_t.h>
70#include <sys/_pthread/_pthread_rwlockattr_t.h>
71#include <sys/_pthread/_pthread_t.h>
72
73#include <pthread/qos.h>
74
75#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
76
77#include <sys/_types/_mach_port_t.h>
78#include <sys/_types/_sigset_t.h>
79
80#endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE */
81
82/*
83 * These symbols indicate which [optional] features are available
84 * They can be tested at compile time via '#ifdef XXX'
85 * The way to check for pthreads is like so:
86
87 * #include <unistd.h>
88 * #ifdef _POSIX_THREADS
89 * #include <pthread.h>
90 * #endif
91
92 */
93
94/* These will be moved to unistd.h */
95
96/*
97 * Note: These data structures are meant to be opaque. Only enough
98 * structure is exposed to support initializers.
99 * All of the typedefs will be moved to <sys/types.h>
100 */
101
102#include <sys/cdefs.h>
103#include <Availability.h>
104
2546420a
A
105#if __has_feature(assume_nonnull)
106_Pragma("clang assume_nonnull begin")
107#endif
f1a1da6c
A
108__BEGIN_DECLS
109/*
110 * Threads
111 */
112
113
114/*
115 * Cancel cleanup handler management. Note, since these are implemented as macros,
116 * they *MUST* occur in matched pairs!
117 */
118
119#define pthread_cleanup_push(func, val) \
120 { \
121 struct __darwin_pthread_handler_rec __handler; \
122 pthread_t __self = pthread_self(); \
123 __handler.__routine = func; \
124 __handler.__arg = val; \
125 __handler.__next = __self->__cleanup_stack; \
126 __self->__cleanup_stack = &__handler;
127
128#define pthread_cleanup_pop(execute) \
129 /* Note: 'handler' must be in this same lexical context! */ \
130 __self->__cleanup_stack = __handler.__next; \
131 if (execute) (__handler.__routine)(__handler.__arg); \
132 }
133
134/*
135 * Thread attributes
136 */
137
138#define PTHREAD_CREATE_JOINABLE 1
139#define PTHREAD_CREATE_DETACHED 2
140
141#define PTHREAD_INHERIT_SCHED 1
142#define PTHREAD_EXPLICIT_SCHED 2
143
144#define PTHREAD_CANCEL_ENABLE 0x01 /* Cancel takes place at next cancellation point */
145#define PTHREAD_CANCEL_DISABLE 0x00 /* Cancel postponed */
146#define PTHREAD_CANCEL_DEFERRED 0x02 /* Cancel waits until cancellation point */
147#define PTHREAD_CANCEL_ASYNCHRONOUS 0x00 /* Cancel occurs immediately */
148
149/* Value returned from pthread_join() when a thread is canceled */
150#define PTHREAD_CANCELED ((void *) 1)
151
152/* We only support PTHREAD_SCOPE_SYSTEM */
153#define PTHREAD_SCOPE_SYSTEM 1
154#define PTHREAD_SCOPE_PROCESS 2
155
f1a1da6c
A
156#define PTHREAD_PROCESS_SHARED 1
157#define PTHREAD_PROCESS_PRIVATE 2
158
159/*
160 * Mutex protocol attributes
161 */
162#define PTHREAD_PRIO_NONE 0
163#define PTHREAD_PRIO_INHERIT 1
164#define PTHREAD_PRIO_PROTECT 2
165
166/*
167 * Mutex type attributes
168 */
169#define PTHREAD_MUTEX_NORMAL 0
170#define PTHREAD_MUTEX_ERRORCHECK 1
171#define PTHREAD_MUTEX_RECURSIVE 2
172#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
173
174/*
175 * RWLock variables
176 */
177#define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWLOCK_SIG_init, {0}}
178
179/*
180 * Mutex variables
181 */
182#define PTHREAD_MUTEX_INITIALIZER {_PTHREAD_MUTEX_SIG_init, {0}}
183
184/* <rdar://problem/10854763> */
185#if ((__MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070) || (__IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000))
186# if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
187# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER {_PTHREAD_ERRORCHECK_MUTEX_SIG_init, {0}}
188# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER {_PTHREAD_RECURSIVE_MUTEX_SIG_init, {0}}
189# endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE */
190#endif
191
2546420a
A
192/* <rdar://problem/25944576> */
193#define _PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT \
194 defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREAD_EPOCH) || (SWIFT_SDK_OVERLAY_PTHREAD_EPOCH < 1))
195
f1a1da6c
A
196/*
197 * Condition variable attributes
198 */
199
200/*
201 * Condition variables
202 */
203
204#define PTHREAD_COND_INITIALIZER {_PTHREAD_COND_SIG_init, {0}}
205
206/*
207 * Initialization control (once) variables
208 */
209
210#define PTHREAD_ONCE_INIT {_PTHREAD_ONCE_SIG_init, {0}}
211
212/*
213 * Prototypes for all PTHREAD interfaces
214 */
215__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
216int pthread_atfork(void (* _Nullable)(void), void (* _Nullable)(void),
217 void (* _Nullable)(void));
f1a1da6c
A
218
219__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
220int pthread_attr_destroy(pthread_attr_t *);
221
222__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
223int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
224
225__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
226int pthread_attr_getguardsize(const pthread_attr_t * __restrict, size_t * __restrict);
227
228__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
229int pthread_attr_getinheritsched(const pthread_attr_t * __restrict, int * __restrict);
230
231__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
232int pthread_attr_getschedparam(const pthread_attr_t * __restrict,
233 struct sched_param * __restrict);
234
235__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
236int pthread_attr_getschedpolicy(const pthread_attr_t * __restrict, int * __restrict);
237
238__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
239int pthread_attr_getscope(const pthread_attr_t * __restrict, int * __restrict);
240
241__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
242int pthread_attr_getstack(const pthread_attr_t * __restrict,
243 void * _Nullable * _Nonnull __restrict, size_t * __restrict);
f1a1da6c
A
244
245__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
246int pthread_attr_getstackaddr(const pthread_attr_t * __restrict,
247 void * _Nullable * _Nonnull __restrict);
f1a1da6c
A
248
249__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
250int pthread_attr_getstacksize(const pthread_attr_t * __restrict, size_t * __restrict);
251
252__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
253int pthread_attr_init(pthread_attr_t *);
254
255__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
256int pthread_attr_setdetachstate(pthread_attr_t *, int);
257
258__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
259int pthread_attr_setguardsize(pthread_attr_t *, size_t);
260
261__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
262int pthread_attr_setinheritsched(pthread_attr_t *, int);
263
264__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
265int pthread_attr_setschedparam(pthread_attr_t * __restrict,
266 const struct sched_param * __restrict);
267
268__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
269int pthread_attr_setschedpolicy(pthread_attr_t *, int);
270
271__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
272int pthread_attr_setscope(pthread_attr_t *, int);
273
274__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
275int pthread_attr_setstack(pthread_attr_t *, void *, size_t);
276
277__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
278int pthread_attr_setstackaddr(pthread_attr_t *, void *);
279
280__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
281int pthread_attr_setstacksize(pthread_attr_t *, size_t);
282
283__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
284int pthread_cancel(pthread_t) __DARWIN_ALIAS(pthread_cancel);
285
286__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
287int pthread_cond_broadcast(pthread_cond_t *);
288
289__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
290int pthread_cond_destroy(pthread_cond_t *);
291
292__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
293int pthread_cond_init(
294 pthread_cond_t * __restrict,
295 const pthread_condattr_t * _Nullable __restrict)
296 __DARWIN_ALIAS(pthread_cond_init);
f1a1da6c
A
297
298__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
299int pthread_cond_signal(pthread_cond_t *);
300
301__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
302int pthread_cond_timedwait(
303 pthread_cond_t * __restrict, pthread_mutex_t * __restrict,
304 const struct timespec * _Nullable __restrict)
305 __DARWIN_ALIAS_C(pthread_cond_timedwait);
f1a1da6c
A
306
307__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
308int pthread_cond_wait(pthread_cond_t * __restrict,
309 pthread_mutex_t * __restrict) __DARWIN_ALIAS_C(pthread_cond_wait);
310
311__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
312int pthread_condattr_destroy(pthread_condattr_t *);
313
314__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
315int pthread_condattr_init(pthread_condattr_t *);
316
317__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
318int pthread_condattr_getpshared(const pthread_condattr_t * __restrict,
319 int * __restrict);
320
321__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
322int pthread_condattr_setpshared(pthread_condattr_t *, int);
323
324__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
325#if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT
326int pthread_create(pthread_t _Nullable * _Nonnull __restrict,
327 const pthread_attr_t * _Nullable __restrict,
328 void * _Nullable (* _Nonnull)(void * _Nullable),
329 void * _Nullable __restrict);
330#else
331int pthread_create(pthread_t * __restrict,
332 const pthread_attr_t * _Nullable __restrict,
333 void *(* _Nonnull)(void *), void * _Nullable __restrict);
334#endif // _PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT
f1a1da6c
A
335
336__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
337int pthread_detach(pthread_t);
338
339__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a 340int pthread_equal(pthread_t _Nullable, pthread_t _Nullable);
f1a1da6c
A
341
342__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a 343void pthread_exit(void * _Nullable) __dead2;
f1a1da6c
A
344
345__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
346int pthread_getconcurrency(void);
347
348__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
349int pthread_getschedparam(pthread_t , int * _Nullable __restrict,
350 struct sched_param * _Nullable __restrict);
f1a1da6c
A
351
352__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a 353void* _Nullable pthread_getspecific(pthread_key_t);
f1a1da6c
A
354
355__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
356int pthread_join(pthread_t , void * _Nullable * _Nullable)
357 __DARWIN_ALIAS_C(pthread_join);
f1a1da6c
A
358
359__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a 360int pthread_key_create(pthread_key_t *, void (* _Nullable)(void *));
f1a1da6c
A
361
362__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
363int pthread_key_delete(pthread_key_t);
364
365__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
366int pthread_mutex_destroy(pthread_mutex_t *);
367
368__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
369int pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict,
370 int * __restrict);
371
372__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
373int pthread_mutex_init(pthread_mutex_t * __restrict,
2546420a 374 const pthread_mutexattr_t * _Nullable __restrict);
f1a1da6c
A
375
376__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
377int pthread_mutex_lock(pthread_mutex_t *);
378
379__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
380int pthread_mutex_setprioceiling(pthread_mutex_t * __restrict, int,
381 int * __restrict);
382
383__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
384int pthread_mutex_trylock(pthread_mutex_t *);
385
386__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
387int pthread_mutex_unlock(pthread_mutex_t *);
388
389__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
390int pthread_mutexattr_destroy(pthread_mutexattr_t *) __DARWIN_ALIAS(pthread_mutexattr_destroy);
391
392__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
393int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * __restrict,
394 int * __restrict);
395
396__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
397int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * __restrict,
398 int * __restrict);
399
400__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
401int pthread_mutexattr_getpshared(const pthread_mutexattr_t * __restrict,
402 int * __restrict);
403
404__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
405int pthread_mutexattr_gettype(const pthread_mutexattr_t * __restrict,
406 int * __restrict);
407
408__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
409int pthread_mutexattr_init(pthread_mutexattr_t *);
410
411__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
412int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
413
414__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
415int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
416
417__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
418int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
419
420__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
421int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
422
2546420a 423__SWIFT_UNAVAILABLE_MSG("Use lazily initialized globals instead")
f1a1da6c 424__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a 425int pthread_once(pthread_once_t *, void (* _Nonnull)(void));
f1a1da6c
A
426
427__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
428int pthread_rwlock_destroy(pthread_rwlock_t * ) __DARWIN_ALIAS(pthread_rwlock_destroy);
429
430__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
431int pthread_rwlock_init(pthread_rwlock_t * __restrict,
2546420a
A
432 const pthread_rwlockattr_t * _Nullable __restrict)
433 __DARWIN_ALIAS(pthread_rwlock_init);
f1a1da6c
A
434
435__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
436int pthread_rwlock_rdlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_rdlock);
437
438__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
439int pthread_rwlock_tryrdlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_tryrdlock);
440
441__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
442int pthread_rwlock_trywrlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_trywrlock);
443
444__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
445int pthread_rwlock_wrlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_wrlock);
446
447__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
448int pthread_rwlock_unlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_unlock);
449
450__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
451int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
452
453__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
454int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * __restrict,
455 int * __restrict);
456
457__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
458int pthread_rwlockattr_init(pthread_rwlockattr_t *);
459
460__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
461int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
462
463__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
464pthread_t pthread_self(void);
465
466__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
467int pthread_setcancelstate(int , int * _Nullable)
468 __DARWIN_ALIAS(pthread_setcancelstate);
f1a1da6c
A
469
470__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
471int pthread_setcanceltype(int , int * _Nullable)
472 __DARWIN_ALIAS(pthread_setcanceltype);
f1a1da6c
A
473
474__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
475int pthread_setconcurrency(int);
476
477__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
478int pthread_setschedparam(pthread_t, int, const struct sched_param *);
479
480__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a 481int pthread_setspecific(pthread_key_t , const void * _Nullable);
f1a1da6c
A
482
483__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
484void pthread_testcancel(void) __DARWIN_ALIAS(pthread_testcancel);
485
486#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
487
488/* returns non-zero if pthread_create or cthread_fork have been called */
489__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
490int pthread_is_threaded_np(void);
491
492__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
2546420a 493int pthread_threadid_np(pthread_t _Nullable,__uint64_t* _Nullable);
f1a1da6c
A
494
495/*SPI to set and get pthread name*/
496__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
497int pthread_getname_np(pthread_t,char*,size_t);
498
499__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
500int pthread_setname_np(const char*);
501
502/* returns non-zero if the current thread is the main thread */
503__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
504int pthread_main_np(void);
505
506/* return the mach thread bound to the pthread */
507__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
508mach_port_t pthread_mach_thread_np(pthread_t);
509
510__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
511size_t pthread_get_stacksize_np(pthread_t);
512
513__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
514void* pthread_get_stackaddr_np(pthread_t);
515
516/* Like pthread_cond_signal(), but only wake up the specified pthread */
517__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a 518int pthread_cond_signal_thread_np(pthread_cond_t *, pthread_t _Nullable);
f1a1da6c
A
519
520/* Like pthread_cond_timedwait, but use a relative timeout */
521__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
522int pthread_cond_timedwait_relative_np(pthread_cond_t *, pthread_mutex_t *,
2546420a 523 const struct timespec * _Nullable);
f1a1da6c
A
524
525/* Like pthread_create(), but leaves the thread suspended */
526__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
527#if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT
528int pthread_create_suspended_np(
529 pthread_t _Nullable * _Nonnull, const pthread_attr_t * _Nullable,
530 void * _Nullable (* _Nonnull)(void * _Nullable), void * _Nullable);
531#else
532int pthread_create_suspended_np(pthread_t *, const pthread_attr_t * _Nullable,
533 void *(* _Nonnull)(void *), void * _Nullable);
534#endif
f1a1da6c
A
535
536__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
537int pthread_kill(pthread_t, int);
538
539__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
2546420a 540_Nullable pthread_t pthread_from_mach_thread_np(mach_port_t);
f1a1da6c
A
541
542__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
2546420a
A
543int pthread_sigmask(int, const sigset_t * _Nullable, sigset_t * _Nullable)
544 __DARWIN_ALIAS(pthread_sigmask);
f1a1da6c
A
545
546__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
547void pthread_yield_np(void);
548
549#endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE */
550__END_DECLS
2546420a
A
551#if __has_feature(assume_nonnull)
552_Pragma("clang assume_nonnull end")
553#endif
554
f1a1da6c 555#endif /* _PTHREAD_H */