]> git.saurik.com Git - apple/libpthread.git/blame - include/pthread/pthread.h
libpthread-454.80.2.tar.gz
[apple/libpthread.git] / include / 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>
f1a1da6c
A
56#include <pthread/sched.h>
57#include <time.h>
58#include <sys/_pthread/_pthread_types.h>
59#include <sys/_pthread/_pthread_attr_t.h>
60#include <sys/_pthread/_pthread_cond_t.h>
61#include <sys/_pthread/_pthread_condattr_t.h>
62#include <sys/_pthread/_pthread_key_t.h>
63#include <sys/_pthread/_pthread_mutex_t.h>
64#include <sys/_pthread/_pthread_mutexattr_t.h>
65#include <sys/_pthread/_pthread_once_t.h>
66#include <sys/_pthread/_pthread_rwlock_t.h>
67#include <sys/_pthread/_pthread_rwlockattr_t.h>
68#include <sys/_pthread/_pthread_t.h>
69
70#include <pthread/qos.h>
71
a0619f9c 72#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(__cplusplus)
f1a1da6c
A
73
74#include <sys/_types/_mach_port_t.h>
75#include <sys/_types/_sigset_t.h>
76
a0619f9c 77#endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE || __cplusplus */
f1a1da6c
A
78
79/*
80 * These symbols indicate which [optional] features are available
81 * They can be tested at compile time via '#ifdef XXX'
82 * The way to check for pthreads is like so:
83
84 * #include <unistd.h>
85 * #ifdef _POSIX_THREADS
86 * #include <pthread.h>
87 * #endif
88
89 */
90
91/* These will be moved to unistd.h */
92
93/*
94 * Note: These data structures are meant to be opaque. Only enough
95 * structure is exposed to support initializers.
96 * All of the typedefs will be moved to <sys/types.h>
97 */
98
99#include <sys/cdefs.h>
100#include <Availability.h>
101
2546420a
A
102#if __has_feature(assume_nonnull)
103_Pragma("clang assume_nonnull begin")
104#endif
f1a1da6c
A
105__BEGIN_DECLS
106/*
107 * Threads
108 */
109
110
111/*
112 * Cancel cleanup handler management. Note, since these are implemented as macros,
113 * they *MUST* occur in matched pairs!
114 */
115
116#define pthread_cleanup_push(func, val) \
117 { \
118 struct __darwin_pthread_handler_rec __handler; \
119 pthread_t __self = pthread_self(); \
120 __handler.__routine = func; \
121 __handler.__arg = val; \
122 __handler.__next = __self->__cleanup_stack; \
123 __self->__cleanup_stack = &__handler;
124
125#define pthread_cleanup_pop(execute) \
126 /* Note: 'handler' must be in this same lexical context! */ \
127 __self->__cleanup_stack = __handler.__next; \
128 if (execute) (__handler.__routine)(__handler.__arg); \
129 }
130
131/*
132 * Thread attributes
133 */
134
135#define PTHREAD_CREATE_JOINABLE 1
136#define PTHREAD_CREATE_DETACHED 2
137
138#define PTHREAD_INHERIT_SCHED 1
139#define PTHREAD_EXPLICIT_SCHED 2
140
141#define PTHREAD_CANCEL_ENABLE 0x01 /* Cancel takes place at next cancellation point */
142#define PTHREAD_CANCEL_DISABLE 0x00 /* Cancel postponed */
143#define PTHREAD_CANCEL_DEFERRED 0x02 /* Cancel waits until cancellation point */
144#define PTHREAD_CANCEL_ASYNCHRONOUS 0x00 /* Cancel occurs immediately */
145
146/* Value returned from pthread_join() when a thread is canceled */
147#define PTHREAD_CANCELED ((void *) 1)
148
149/* We only support PTHREAD_SCOPE_SYSTEM */
150#define PTHREAD_SCOPE_SYSTEM 1
151#define PTHREAD_SCOPE_PROCESS 2
152
f1a1da6c
A
153#define PTHREAD_PROCESS_SHARED 1
154#define PTHREAD_PROCESS_PRIVATE 2
155
156/*
157 * Mutex protocol attributes
158 */
159#define PTHREAD_PRIO_NONE 0
160#define PTHREAD_PRIO_INHERIT 1
161#define PTHREAD_PRIO_PROTECT 2
162
163/*
164 * Mutex type attributes
165 */
166#define PTHREAD_MUTEX_NORMAL 0
167#define PTHREAD_MUTEX_ERRORCHECK 1
168#define PTHREAD_MUTEX_RECURSIVE 2
169#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
170
214d78a2
A
171/*
172 * Mutex policy attributes
173 */
174#define PTHREAD_MUTEX_POLICY_FAIRSHARE_NP 1
175#define PTHREAD_MUTEX_POLICY_FIRSTFIT_NP 3
176
f1a1da6c
A
177/*
178 * RWLock variables
179 */
180#define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWLOCK_SIG_init, {0}}
181
182/*
183 * Mutex variables
184 */
185#define PTHREAD_MUTEX_INITIALIZER {_PTHREAD_MUTEX_SIG_init, {0}}
186
187/* <rdar://problem/10854763> */
c6e5f90c 188#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)) || defined(__DRIVERKIT_VERSION_MIN_REQUIRED)
f1a1da6c
A
189# if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
190# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER {_PTHREAD_ERRORCHECK_MUTEX_SIG_init, {0}}
191# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER {_PTHREAD_RECURSIVE_MUTEX_SIG_init, {0}}
192# endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE */
193#endif
194
2546420a
A
195/* <rdar://problem/25944576> */
196#define _PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT \
197 defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREAD_EPOCH) || (SWIFT_SDK_OVERLAY_PTHREAD_EPOCH < 1))
198
f1a1da6c
A
199/*
200 * Condition variable attributes
201 */
202
203/*
204 * Condition variables
205 */
206
207#define PTHREAD_COND_INITIALIZER {_PTHREAD_COND_SIG_init, {0}}
208
209/*
210 * Initialization control (once) variables
211 */
212
213#define PTHREAD_ONCE_INIT {_PTHREAD_ONCE_SIG_init, {0}}
214
215/*
216 * Prototypes for all PTHREAD interfaces
217 */
a0619f9c 218__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
219int pthread_atfork(void (* _Nullable)(void), void (* _Nullable)(void),
220 void (* _Nullable)(void));
f1a1da6c 221
a0619f9c 222__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
223int pthread_attr_destroy(pthread_attr_t *);
224
a0619f9c 225__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
226int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
227
a0619f9c 228__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
229int pthread_attr_getguardsize(const pthread_attr_t * __restrict, size_t * __restrict);
230
a0619f9c 231__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
232int pthread_attr_getinheritsched(const pthread_attr_t * __restrict, int * __restrict);
233
a0619f9c 234__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
235int pthread_attr_getschedparam(const pthread_attr_t * __restrict,
236 struct sched_param * __restrict);
237
a0619f9c 238__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
239int pthread_attr_getschedpolicy(const pthread_attr_t * __restrict, int * __restrict);
240
a0619f9c 241__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
242int pthread_attr_getscope(const pthread_attr_t * __restrict, int * __restrict);
243
a0619f9c 244__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
245int pthread_attr_getstack(const pthread_attr_t * __restrict,
246 void * _Nullable * _Nonnull __restrict, size_t * __restrict);
f1a1da6c 247
a0619f9c 248__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
249int pthread_attr_getstackaddr(const pthread_attr_t * __restrict,
250 void * _Nullable * _Nonnull __restrict);
f1a1da6c 251
a0619f9c 252__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
253int pthread_attr_getstacksize(const pthread_attr_t * __restrict, size_t * __restrict);
254
a0619f9c 255__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
256int pthread_attr_init(pthread_attr_t *);
257
a0619f9c 258__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
259int pthread_attr_setdetachstate(pthread_attr_t *, int);
260
a0619f9c 261__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
262int pthread_attr_setguardsize(pthread_attr_t *, size_t);
263
a0619f9c 264__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
265int pthread_attr_setinheritsched(pthread_attr_t *, int);
266
a0619f9c 267__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
268int pthread_attr_setschedparam(pthread_attr_t * __restrict,
269 const struct sched_param * __restrict);
270
a0619f9c 271__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
272int pthread_attr_setschedpolicy(pthread_attr_t *, int);
273
a0619f9c 274__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
275int pthread_attr_setscope(pthread_attr_t *, int);
276
a0619f9c 277__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
278int pthread_attr_setstack(pthread_attr_t *, void *, size_t);
279
a0619f9c 280__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
281int pthread_attr_setstackaddr(pthread_attr_t *, void *);
282
a0619f9c 283__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
284int pthread_attr_setstacksize(pthread_attr_t *, size_t);
285
a0619f9c 286__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
287int pthread_cancel(pthread_t) __DARWIN_ALIAS(pthread_cancel);
288
a0619f9c 289__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
290int pthread_cond_broadcast(pthread_cond_t *);
291
a0619f9c 292__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
293int pthread_cond_destroy(pthread_cond_t *);
294
a0619f9c 295__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
296int pthread_cond_init(
297 pthread_cond_t * __restrict,
298 const pthread_condattr_t * _Nullable __restrict)
299 __DARWIN_ALIAS(pthread_cond_init);
f1a1da6c 300
a0619f9c 301__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
302int pthread_cond_signal(pthread_cond_t *);
303
a0619f9c 304__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
305int pthread_cond_timedwait(
306 pthread_cond_t * __restrict, pthread_mutex_t * __restrict,
307 const struct timespec * _Nullable __restrict)
308 __DARWIN_ALIAS_C(pthread_cond_timedwait);
f1a1da6c 309
a0619f9c 310__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
311int pthread_cond_wait(pthread_cond_t * __restrict,
312 pthread_mutex_t * __restrict) __DARWIN_ALIAS_C(pthread_cond_wait);
313
a0619f9c 314__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
315int pthread_condattr_destroy(pthread_condattr_t *);
316
a0619f9c 317__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
318int pthread_condattr_init(pthread_condattr_t *);
319
a0619f9c 320__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
321int pthread_condattr_getpshared(const pthread_condattr_t * __restrict,
322 int * __restrict);
323
a0619f9c 324__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
325int pthread_condattr_setpshared(pthread_condattr_t *, int);
326
a0619f9c 327__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
328#if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT
329int pthread_create(pthread_t _Nullable * _Nonnull __restrict,
330 const pthread_attr_t * _Nullable __restrict,
331 void * _Nullable (* _Nonnull)(void * _Nullable),
332 void * _Nullable __restrict);
333#else
334int pthread_create(pthread_t * __restrict,
335 const pthread_attr_t * _Nullable __restrict,
336 void *(* _Nonnull)(void *), void * _Nullable __restrict);
337#endif // _PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT
f1a1da6c 338
a0619f9c 339__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
340int pthread_detach(pthread_t);
341
a0619f9c 342__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a 343int pthread_equal(pthread_t _Nullable, pthread_t _Nullable);
f1a1da6c 344
a0619f9c 345__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a 346void pthread_exit(void * _Nullable) __dead2;
f1a1da6c 347
a0619f9c 348__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
349int pthread_getconcurrency(void);
350
a0619f9c 351__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
352int pthread_getschedparam(pthread_t , int * _Nullable __restrict,
353 struct sched_param * _Nullable __restrict);
f1a1da6c 354
a0619f9c 355__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a 356void* _Nullable pthread_getspecific(pthread_key_t);
f1a1da6c 357
a0619f9c 358__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
359int pthread_join(pthread_t , void * _Nullable * _Nullable)
360 __DARWIN_ALIAS_C(pthread_join);
f1a1da6c 361
a0619f9c 362__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a 363int pthread_key_create(pthread_key_t *, void (* _Nullable)(void *));
f1a1da6c 364
a0619f9c 365__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
366int pthread_key_delete(pthread_key_t);
367
a0619f9c 368__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
369int pthread_mutex_destroy(pthread_mutex_t *);
370
a0619f9c 371__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
372int pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict,
373 int * __restrict);
374
a0619f9c 375__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c 376int pthread_mutex_init(pthread_mutex_t * __restrict,
2546420a 377 const pthread_mutexattr_t * _Nullable __restrict);
f1a1da6c 378
a0619f9c 379__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
380int pthread_mutex_lock(pthread_mutex_t *);
381
a0619f9c 382__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
383int pthread_mutex_setprioceiling(pthread_mutex_t * __restrict, int,
384 int * __restrict);
385
a0619f9c 386__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
387int pthread_mutex_trylock(pthread_mutex_t *);
388
a0619f9c 389__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
390int pthread_mutex_unlock(pthread_mutex_t *);
391
a0619f9c 392__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
393int pthread_mutexattr_destroy(pthread_mutexattr_t *) __DARWIN_ALIAS(pthread_mutexattr_destroy);
394
a0619f9c 395__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
396int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * __restrict,
397 int * __restrict);
398
a0619f9c 399__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
400int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * __restrict,
401 int * __restrict);
402
a0619f9c 403__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
404int pthread_mutexattr_getpshared(const pthread_mutexattr_t * __restrict,
405 int * __restrict);
406
a0619f9c 407__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
408int pthread_mutexattr_gettype(const pthread_mutexattr_t * __restrict,
409 int * __restrict);
410
214d78a2
A
411__API_AVAILABLE(macos(10.13.4), ios(11.3), watchos(4.3), tvos(11.3))
412int pthread_mutexattr_getpolicy_np(const pthread_mutexattr_t * __restrict,
413 int * __restrict);
414
a0619f9c 415__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
416int pthread_mutexattr_init(pthread_mutexattr_t *);
417
a0619f9c 418__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
419int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
420
a0619f9c 421__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
422int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
423
a0619f9c 424__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
425int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
426
a0619f9c 427__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
428int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
429
214d78a2
A
430__API_AVAILABLE(macos(10.7), ios(5.0))
431int pthread_mutexattr_setpolicy_np(pthread_mutexattr_t *, int);
432
2546420a 433__SWIFT_UNAVAILABLE_MSG("Use lazily initialized globals instead")
a0619f9c 434__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a 435int pthread_once(pthread_once_t *, void (* _Nonnull)(void));
f1a1da6c 436
a0619f9c 437__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
438int pthread_rwlock_destroy(pthread_rwlock_t * ) __DARWIN_ALIAS(pthread_rwlock_destroy);
439
a0619f9c 440__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c 441int pthread_rwlock_init(pthread_rwlock_t * __restrict,
2546420a
A
442 const pthread_rwlockattr_t * _Nullable __restrict)
443 __DARWIN_ALIAS(pthread_rwlock_init);
f1a1da6c 444
a0619f9c 445__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
446int pthread_rwlock_rdlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_rdlock);
447
a0619f9c 448__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
449int pthread_rwlock_tryrdlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_tryrdlock);
450
a0619f9c 451__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
452int pthread_rwlock_trywrlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_trywrlock);
453
a0619f9c 454__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
455int pthread_rwlock_wrlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_wrlock);
456
a0619f9c 457__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
458int pthread_rwlock_unlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_unlock);
459
a0619f9c 460__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
461int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
462
a0619f9c 463__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
464int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * __restrict,
465 int * __restrict);
466
a0619f9c 467__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
468int pthread_rwlockattr_init(pthread_rwlockattr_t *);
469
a0619f9c 470__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
471int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
472
a0619f9c 473__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
474pthread_t pthread_self(void);
475
a0619f9c 476__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
477int pthread_setcancelstate(int , int * _Nullable)
478 __DARWIN_ALIAS(pthread_setcancelstate);
f1a1da6c 479
a0619f9c 480__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
481int pthread_setcanceltype(int , int * _Nullable)
482 __DARWIN_ALIAS(pthread_setcanceltype);
f1a1da6c 483
a0619f9c 484__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
485int pthread_setconcurrency(int);
486
a0619f9c 487__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
488int pthread_setschedparam(pthread_t, int, const struct sched_param *);
489
a0619f9c 490__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a 491int pthread_setspecific(pthread_key_t , const void * _Nullable);
f1a1da6c 492
a0619f9c 493__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
494void pthread_testcancel(void) __DARWIN_ALIAS(pthread_testcancel);
495
a0619f9c 496#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(__cplusplus)
f1a1da6c
A
497
498/* returns non-zero if pthread_create or cthread_fork have been called */
a0619f9c 499__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
500int pthread_is_threaded_np(void);
501
a0619f9c 502__API_AVAILABLE(macos(10.6), ios(3.2))
2546420a 503int pthread_threadid_np(pthread_t _Nullable,__uint64_t* _Nullable);
f1a1da6c
A
504
505/*SPI to set and get pthread name*/
a0619f9c 506__API_AVAILABLE(macos(10.6), ios(3.2))
f1a1da6c
A
507int pthread_getname_np(pthread_t,char*,size_t);
508
a0619f9c 509__API_AVAILABLE(macos(10.6), ios(3.2))
f1a1da6c
A
510int pthread_setname_np(const char*);
511
512/* returns non-zero if the current thread is the main thread */
a0619f9c 513__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
514int pthread_main_np(void);
515
516/* return the mach thread bound to the pthread */
a0619f9c 517__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
518mach_port_t pthread_mach_thread_np(pthread_t);
519
a0619f9c 520__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
521size_t pthread_get_stacksize_np(pthread_t);
522
a0619f9c 523__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
524void* pthread_get_stackaddr_np(pthread_t);
525
526/* Like pthread_cond_signal(), but only wake up the specified pthread */
a0619f9c 527__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a 528int pthread_cond_signal_thread_np(pthread_cond_t *, pthread_t _Nullable);
f1a1da6c
A
529
530/* Like pthread_cond_timedwait, but use a relative timeout */
a0619f9c 531__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c 532int pthread_cond_timedwait_relative_np(pthread_cond_t *, pthread_mutex_t *,
2546420a 533 const struct timespec * _Nullable);
f1a1da6c
A
534
535/* Like pthread_create(), but leaves the thread suspended */
a0619f9c 536__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
537#if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT
538int pthread_create_suspended_np(
539 pthread_t _Nullable * _Nonnull, const pthread_attr_t * _Nullable,
540 void * _Nullable (* _Nonnull)(void * _Nullable), void * _Nullable);
541#else
542int pthread_create_suspended_np(pthread_t *, const pthread_attr_t * _Nullable,
543 void *(* _Nonnull)(void *), void * _Nullable);
544#endif
f1a1da6c 545
a0619f9c 546__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
547int pthread_kill(pthread_t, int);
548
a0619f9c 549__API_AVAILABLE(macos(10.5), ios(2.0))
2546420a 550_Nullable pthread_t pthread_from_mach_thread_np(mach_port_t);
f1a1da6c 551
a0619f9c 552__API_AVAILABLE(macos(10.4), ios(2.0))
2546420a
A
553int pthread_sigmask(int, const sigset_t * _Nullable, sigset_t * _Nullable)
554 __DARWIN_ALIAS(pthread_sigmask);
f1a1da6c 555
a0619f9c 556__API_AVAILABLE(macos(10.4), ios(2.0))
f1a1da6c
A
557void pthread_yield_np(void);
558
c1f56ec9 559__API_AVAILABLE(macos(10.16))
6dae708f 560__API_UNAVAILABLE(ios, tvos, watchos, bridgeos, driverkit)
c1f56ec9
A
561void pthread_jit_write_protect_np(int enabled);
562
563__API_AVAILABLE(macos(10.16))
6dae708f 564__API_UNAVAILABLE(ios, tvos, watchos, bridgeos, driverkit)
c1f56ec9
A
565int pthread_jit_write_protect_supported_np(void);
566
567/*!
568 * @function pthread_cpu_number_np
569 *
570 * @param cpu_number_out
571 * The CPU number that the thread was running on at the time of query.
572 * This cpu number is in the interval [0, ncpus) (from sysctlbyname("hw.ncpu"))
573 *
574 * @result
575 * This function returns 0 or the value of errno if an error occurred.
576 *
577 * @note
578 * Optimizations of per-CPU datastructures based on the result of this function
579 * still require synchronization since it is not guaranteed that the thread will
580 * still be on the same CPU by the time the function returns.
581 */
582__API_AVAILABLE(macos(11.0), ios(14.2), tvos(14.2), watchos(7.1))
583int
584pthread_cpu_number_np(size_t *cpu_number_out);
585
a0619f9c 586#endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE || __cplusplus */
f1a1da6c 587__END_DECLS
2546420a
A
588#if __has_feature(assume_nonnull)
589_Pragma("clang assume_nonnull end")
590#endif
591
f1a1da6c 592#endif /* _PTHREAD_H */