]>
Commit | Line | Data |
---|---|---|
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 | ||
a0619f9c | 75 | #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(__cplusplus) |
f1a1da6c A |
76 | |
77 | #include <sys/_types/_mach_port_t.h> | |
78 | #include <sys/_types/_sigset_t.h> | |
79 | ||
a0619f9c | 80 | #endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE || __cplusplus */ |
f1a1da6c A |
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 | ||
214d78a2 A |
174 | /* |
175 | * Mutex policy attributes | |
176 | */ | |
177 | #define PTHREAD_MUTEX_POLICY_FAIRSHARE_NP 1 | |
178 | #define PTHREAD_MUTEX_POLICY_FIRSTFIT_NP 3 | |
179 | ||
f1a1da6c A |
180 | /* |
181 | * RWLock variables | |
182 | */ | |
183 | #define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWLOCK_SIG_init, {0}} | |
184 | ||
185 | /* | |
186 | * Mutex variables | |
187 | */ | |
188 | #define PTHREAD_MUTEX_INITIALIZER {_PTHREAD_MUTEX_SIG_init, {0}} | |
189 | ||
190 | /* <rdar://problem/10854763> */ | |
191 | #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)) | |
192 | # if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) | |
193 | # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER {_PTHREAD_ERRORCHECK_MUTEX_SIG_init, {0}} | |
194 | # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER {_PTHREAD_RECURSIVE_MUTEX_SIG_init, {0}} | |
195 | # endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE */ | |
196 | #endif | |
197 | ||
2546420a A |
198 | /* <rdar://problem/25944576> */ |
199 | #define _PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT \ | |
200 | defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREAD_EPOCH) || (SWIFT_SDK_OVERLAY_PTHREAD_EPOCH < 1)) | |
201 | ||
f1a1da6c A |
202 | /* |
203 | * Condition variable attributes | |
204 | */ | |
205 | ||
206 | /* | |
207 | * Condition variables | |
208 | */ | |
209 | ||
210 | #define PTHREAD_COND_INITIALIZER {_PTHREAD_COND_SIG_init, {0}} | |
211 | ||
212 | /* | |
213 | * Initialization control (once) variables | |
214 | */ | |
215 | ||
216 | #define PTHREAD_ONCE_INIT {_PTHREAD_ONCE_SIG_init, {0}} | |
217 | ||
218 | /* | |
219 | * Prototypes for all PTHREAD interfaces | |
220 | */ | |
a0619f9c | 221 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
222 | int pthread_atfork(void (* _Nullable)(void), void (* _Nullable)(void), |
223 | void (* _Nullable)(void)); | |
f1a1da6c | 224 | |
a0619f9c | 225 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
226 | int pthread_attr_destroy(pthread_attr_t *); |
227 | ||
a0619f9c | 228 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
229 | int pthread_attr_getdetachstate(const pthread_attr_t *, int *); |
230 | ||
a0619f9c | 231 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
232 | int pthread_attr_getguardsize(const pthread_attr_t * __restrict, size_t * __restrict); |
233 | ||
a0619f9c | 234 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
235 | int pthread_attr_getinheritsched(const pthread_attr_t * __restrict, int * __restrict); |
236 | ||
a0619f9c | 237 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
238 | int pthread_attr_getschedparam(const pthread_attr_t * __restrict, |
239 | struct sched_param * __restrict); | |
240 | ||
a0619f9c | 241 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
242 | int pthread_attr_getschedpolicy(const pthread_attr_t * __restrict, int * __restrict); |
243 | ||
a0619f9c | 244 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
245 | int pthread_attr_getscope(const pthread_attr_t * __restrict, int * __restrict); |
246 | ||
a0619f9c | 247 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
248 | int pthread_attr_getstack(const pthread_attr_t * __restrict, |
249 | void * _Nullable * _Nonnull __restrict, size_t * __restrict); | |
f1a1da6c | 250 | |
a0619f9c | 251 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
252 | int pthread_attr_getstackaddr(const pthread_attr_t * __restrict, |
253 | void * _Nullable * _Nonnull __restrict); | |
f1a1da6c | 254 | |
a0619f9c | 255 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
256 | int pthread_attr_getstacksize(const pthread_attr_t * __restrict, size_t * __restrict); |
257 | ||
a0619f9c | 258 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
259 | int pthread_attr_init(pthread_attr_t *); |
260 | ||
a0619f9c | 261 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
262 | int pthread_attr_setdetachstate(pthread_attr_t *, int); |
263 | ||
a0619f9c | 264 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
265 | int pthread_attr_setguardsize(pthread_attr_t *, size_t); |
266 | ||
a0619f9c | 267 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
268 | int pthread_attr_setinheritsched(pthread_attr_t *, int); |
269 | ||
a0619f9c | 270 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
271 | int pthread_attr_setschedparam(pthread_attr_t * __restrict, |
272 | const struct sched_param * __restrict); | |
273 | ||
a0619f9c | 274 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
275 | int pthread_attr_setschedpolicy(pthread_attr_t *, int); |
276 | ||
a0619f9c | 277 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
278 | int pthread_attr_setscope(pthread_attr_t *, int); |
279 | ||
a0619f9c | 280 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
281 | int pthread_attr_setstack(pthread_attr_t *, void *, size_t); |
282 | ||
a0619f9c | 283 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
284 | int pthread_attr_setstackaddr(pthread_attr_t *, void *); |
285 | ||
a0619f9c | 286 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
287 | int pthread_attr_setstacksize(pthread_attr_t *, size_t); |
288 | ||
a0619f9c | 289 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
290 | int pthread_cancel(pthread_t) __DARWIN_ALIAS(pthread_cancel); |
291 | ||
a0619f9c | 292 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
293 | int pthread_cond_broadcast(pthread_cond_t *); |
294 | ||
a0619f9c | 295 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
296 | int pthread_cond_destroy(pthread_cond_t *); |
297 | ||
a0619f9c | 298 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
299 | int pthread_cond_init( |
300 | pthread_cond_t * __restrict, | |
301 | const pthread_condattr_t * _Nullable __restrict) | |
302 | __DARWIN_ALIAS(pthread_cond_init); | |
f1a1da6c | 303 | |
a0619f9c | 304 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
305 | int pthread_cond_signal(pthread_cond_t *); |
306 | ||
a0619f9c | 307 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
308 | int pthread_cond_timedwait( |
309 | pthread_cond_t * __restrict, pthread_mutex_t * __restrict, | |
310 | const struct timespec * _Nullable __restrict) | |
311 | __DARWIN_ALIAS_C(pthread_cond_timedwait); | |
f1a1da6c | 312 | |
a0619f9c | 313 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
314 | int pthread_cond_wait(pthread_cond_t * __restrict, |
315 | pthread_mutex_t * __restrict) __DARWIN_ALIAS_C(pthread_cond_wait); | |
316 | ||
a0619f9c | 317 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
318 | int pthread_condattr_destroy(pthread_condattr_t *); |
319 | ||
a0619f9c | 320 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
321 | int pthread_condattr_init(pthread_condattr_t *); |
322 | ||
a0619f9c | 323 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
324 | int pthread_condattr_getpshared(const pthread_condattr_t * __restrict, |
325 | int * __restrict); | |
326 | ||
a0619f9c | 327 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
328 | int pthread_condattr_setpshared(pthread_condattr_t *, int); |
329 | ||
a0619f9c | 330 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
331 | #if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT |
332 | int pthread_create(pthread_t _Nullable * _Nonnull __restrict, | |
333 | const pthread_attr_t * _Nullable __restrict, | |
334 | void * _Nullable (* _Nonnull)(void * _Nullable), | |
335 | void * _Nullable __restrict); | |
336 | #else | |
337 | int pthread_create(pthread_t * __restrict, | |
338 | const pthread_attr_t * _Nullable __restrict, | |
339 | void *(* _Nonnull)(void *), void * _Nullable __restrict); | |
340 | #endif // _PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT | |
f1a1da6c | 341 | |
a0619f9c | 342 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
343 | int pthread_detach(pthread_t); |
344 | ||
a0619f9c | 345 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a | 346 | int pthread_equal(pthread_t _Nullable, pthread_t _Nullable); |
f1a1da6c | 347 | |
a0619f9c | 348 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a | 349 | void pthread_exit(void * _Nullable) __dead2; |
f1a1da6c | 350 | |
a0619f9c | 351 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
352 | int pthread_getconcurrency(void); |
353 | ||
a0619f9c | 354 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
355 | int pthread_getschedparam(pthread_t , int * _Nullable __restrict, |
356 | struct sched_param * _Nullable __restrict); | |
f1a1da6c | 357 | |
a0619f9c | 358 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a | 359 | void* _Nullable pthread_getspecific(pthread_key_t); |
f1a1da6c | 360 | |
a0619f9c | 361 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
362 | int pthread_join(pthread_t , void * _Nullable * _Nullable) |
363 | __DARWIN_ALIAS_C(pthread_join); | |
f1a1da6c | 364 | |
a0619f9c | 365 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a | 366 | int pthread_key_create(pthread_key_t *, void (* _Nullable)(void *)); |
f1a1da6c | 367 | |
a0619f9c | 368 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
369 | int pthread_key_delete(pthread_key_t); |
370 | ||
a0619f9c | 371 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
372 | int pthread_mutex_destroy(pthread_mutex_t *); |
373 | ||
a0619f9c | 374 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
375 | int pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict, |
376 | int * __restrict); | |
377 | ||
a0619f9c | 378 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c | 379 | int pthread_mutex_init(pthread_mutex_t * __restrict, |
2546420a | 380 | const pthread_mutexattr_t * _Nullable __restrict); |
f1a1da6c | 381 | |
a0619f9c | 382 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
383 | int pthread_mutex_lock(pthread_mutex_t *); |
384 | ||
a0619f9c | 385 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
386 | int pthread_mutex_setprioceiling(pthread_mutex_t * __restrict, int, |
387 | int * __restrict); | |
388 | ||
a0619f9c | 389 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
390 | int pthread_mutex_trylock(pthread_mutex_t *); |
391 | ||
a0619f9c | 392 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
393 | int pthread_mutex_unlock(pthread_mutex_t *); |
394 | ||
a0619f9c | 395 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
396 | int pthread_mutexattr_destroy(pthread_mutexattr_t *) __DARWIN_ALIAS(pthread_mutexattr_destroy); |
397 | ||
a0619f9c | 398 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
399 | int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * __restrict, |
400 | int * __restrict); | |
401 | ||
a0619f9c | 402 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
403 | int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * __restrict, |
404 | int * __restrict); | |
405 | ||
a0619f9c | 406 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
407 | int pthread_mutexattr_getpshared(const pthread_mutexattr_t * __restrict, |
408 | int * __restrict); | |
409 | ||
a0619f9c | 410 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
411 | int pthread_mutexattr_gettype(const pthread_mutexattr_t * __restrict, |
412 | int * __restrict); | |
413 | ||
214d78a2 A |
414 | __API_AVAILABLE(macos(10.13.4), ios(11.3), watchos(4.3), tvos(11.3)) |
415 | int pthread_mutexattr_getpolicy_np(const pthread_mutexattr_t * __restrict, | |
416 | int * __restrict); | |
417 | ||
a0619f9c | 418 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
419 | int pthread_mutexattr_init(pthread_mutexattr_t *); |
420 | ||
a0619f9c | 421 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
422 | int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int); |
423 | ||
a0619f9c | 424 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
425 | int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int); |
426 | ||
a0619f9c | 427 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
428 | int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); |
429 | ||
a0619f9c | 430 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
431 | int pthread_mutexattr_settype(pthread_mutexattr_t *, int); |
432 | ||
214d78a2 A |
433 | __API_AVAILABLE(macos(10.7), ios(5.0)) |
434 | int pthread_mutexattr_setpolicy_np(pthread_mutexattr_t *, int); | |
435 | ||
2546420a | 436 | __SWIFT_UNAVAILABLE_MSG("Use lazily initialized globals instead") |
a0619f9c | 437 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a | 438 | int pthread_once(pthread_once_t *, void (* _Nonnull)(void)); |
f1a1da6c | 439 | |
a0619f9c | 440 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
441 | int pthread_rwlock_destroy(pthread_rwlock_t * ) __DARWIN_ALIAS(pthread_rwlock_destroy); |
442 | ||
a0619f9c | 443 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c | 444 | int pthread_rwlock_init(pthread_rwlock_t * __restrict, |
2546420a A |
445 | const pthread_rwlockattr_t * _Nullable __restrict) |
446 | __DARWIN_ALIAS(pthread_rwlock_init); | |
f1a1da6c | 447 | |
a0619f9c | 448 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
449 | int pthread_rwlock_rdlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_rdlock); |
450 | ||
a0619f9c | 451 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
452 | int pthread_rwlock_tryrdlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_tryrdlock); |
453 | ||
a0619f9c | 454 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
455 | int pthread_rwlock_trywrlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_trywrlock); |
456 | ||
a0619f9c | 457 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
458 | int pthread_rwlock_wrlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_wrlock); |
459 | ||
a0619f9c | 460 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
461 | int pthread_rwlock_unlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_unlock); |
462 | ||
a0619f9c | 463 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
464 | int pthread_rwlockattr_destroy(pthread_rwlockattr_t *); |
465 | ||
a0619f9c | 466 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
467 | int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * __restrict, |
468 | int * __restrict); | |
469 | ||
a0619f9c | 470 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
471 | int pthread_rwlockattr_init(pthread_rwlockattr_t *); |
472 | ||
a0619f9c | 473 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
474 | int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int); |
475 | ||
a0619f9c | 476 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
477 | pthread_t pthread_self(void); |
478 | ||
a0619f9c | 479 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
480 | int pthread_setcancelstate(int , int * _Nullable) |
481 | __DARWIN_ALIAS(pthread_setcancelstate); | |
f1a1da6c | 482 | |
a0619f9c | 483 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
484 | int pthread_setcanceltype(int , int * _Nullable) |
485 | __DARWIN_ALIAS(pthread_setcanceltype); | |
f1a1da6c | 486 | |
a0619f9c | 487 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
488 | int pthread_setconcurrency(int); |
489 | ||
a0619f9c | 490 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
491 | int pthread_setschedparam(pthread_t, int, const struct sched_param *); |
492 | ||
a0619f9c | 493 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a | 494 | int pthread_setspecific(pthread_key_t , const void * _Nullable); |
f1a1da6c | 495 | |
a0619f9c | 496 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
497 | void pthread_testcancel(void) __DARWIN_ALIAS(pthread_testcancel); |
498 | ||
a0619f9c | 499 | #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(__cplusplus) |
f1a1da6c A |
500 | |
501 | /* returns non-zero if pthread_create or cthread_fork have been called */ | |
a0619f9c | 502 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
503 | int pthread_is_threaded_np(void); |
504 | ||
a0619f9c | 505 | __API_AVAILABLE(macos(10.6), ios(3.2)) |
2546420a | 506 | int pthread_threadid_np(pthread_t _Nullable,__uint64_t* _Nullable); |
f1a1da6c A |
507 | |
508 | /*SPI to set and get pthread name*/ | |
a0619f9c | 509 | __API_AVAILABLE(macos(10.6), ios(3.2)) |
f1a1da6c A |
510 | int pthread_getname_np(pthread_t,char*,size_t); |
511 | ||
a0619f9c | 512 | __API_AVAILABLE(macos(10.6), ios(3.2)) |
f1a1da6c A |
513 | int pthread_setname_np(const char*); |
514 | ||
515 | /* returns non-zero if the current thread is the main thread */ | |
a0619f9c | 516 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
517 | int pthread_main_np(void); |
518 | ||
519 | /* return the mach thread bound to the pthread */ | |
a0619f9c | 520 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
521 | mach_port_t pthread_mach_thread_np(pthread_t); |
522 | ||
a0619f9c | 523 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
524 | size_t pthread_get_stacksize_np(pthread_t); |
525 | ||
a0619f9c | 526 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
527 | void* pthread_get_stackaddr_np(pthread_t); |
528 | ||
529 | /* Like pthread_cond_signal(), but only wake up the specified pthread */ | |
a0619f9c | 530 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a | 531 | int pthread_cond_signal_thread_np(pthread_cond_t *, pthread_t _Nullable); |
f1a1da6c A |
532 | |
533 | /* Like pthread_cond_timedwait, but use a relative timeout */ | |
a0619f9c | 534 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c | 535 | int pthread_cond_timedwait_relative_np(pthread_cond_t *, pthread_mutex_t *, |
2546420a | 536 | const struct timespec * _Nullable); |
f1a1da6c A |
537 | |
538 | /* Like pthread_create(), but leaves the thread suspended */ | |
a0619f9c | 539 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
540 | #if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT |
541 | int pthread_create_suspended_np( | |
542 | pthread_t _Nullable * _Nonnull, const pthread_attr_t * _Nullable, | |
543 | void * _Nullable (* _Nonnull)(void * _Nullable), void * _Nullable); | |
544 | #else | |
545 | int pthread_create_suspended_np(pthread_t *, const pthread_attr_t * _Nullable, | |
546 | void *(* _Nonnull)(void *), void * _Nullable); | |
547 | #endif | |
f1a1da6c | 548 | |
a0619f9c | 549 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
550 | int pthread_kill(pthread_t, int); |
551 | ||
a0619f9c | 552 | __API_AVAILABLE(macos(10.5), ios(2.0)) |
2546420a | 553 | _Nullable pthread_t pthread_from_mach_thread_np(mach_port_t); |
f1a1da6c | 554 | |
a0619f9c | 555 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
2546420a A |
556 | int pthread_sigmask(int, const sigset_t * _Nullable, sigset_t * _Nullable) |
557 | __DARWIN_ALIAS(pthread_sigmask); | |
f1a1da6c | 558 | |
a0619f9c | 559 | __API_AVAILABLE(macos(10.4), ios(2.0)) |
f1a1da6c A |
560 | void pthread_yield_np(void); |
561 | ||
a0619f9c | 562 | #endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE || __cplusplus */ |
f1a1da6c | 563 | __END_DECLS |
2546420a A |
564 | #if __has_feature(assume_nonnull) |
565 | _Pragma("clang assume_nonnull end") | |
566 | #endif | |
567 | ||
f1a1da6c | 568 | #endif /* _PTHREAD_H */ |