| 1 | /* Copyright (C) 2002-2020 Free Software Foundation, Inc. | 
|---|
| 2 | This file is part of the GNU C Library. | 
|---|
| 3 |  | 
|---|
| 4 | The GNU C Library is free software; you can redistribute it and/or | 
|---|
| 5 | modify it under the terms of the GNU Lesser General Public | 
|---|
| 6 | License as published by the Free Software Foundation; either | 
|---|
| 7 | version 2.1 of the License, or (at your option) any later version. | 
|---|
| 8 |  | 
|---|
| 9 | The GNU C Library is distributed in the hope that it will be useful, | 
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
| 12 | Lesser General Public License for more details. | 
|---|
| 13 |  | 
|---|
| 14 | You should have received a copy of the GNU Lesser General Public | 
|---|
| 15 | License along with the GNU C Library; if not, see | 
|---|
| 16 | <https://www.gnu.org/licenses/>.  */ | 
|---|
| 17 |  | 
|---|
| 18 | #ifndef _PTHREAD_H | 
|---|
| 19 | #define _PTHREAD_H	1 | 
|---|
| 20 |  | 
|---|
| 21 | #include <features.h> | 
|---|
| 22 | #include <sched.h> | 
|---|
| 23 | #include <time.h> | 
|---|
| 24 |  | 
|---|
| 25 | #include <bits/endian.h> | 
|---|
| 26 | #include <bits/pthreadtypes.h> | 
|---|
| 27 | #include <bits/setjmp.h> | 
|---|
| 28 | #include <bits/wordsize.h> | 
|---|
| 29 | #include <bits/types/struct_timespec.h> | 
|---|
| 30 | #include <bits/types/__sigset_t.h> | 
|---|
| 31 |  | 
|---|
| 32 |  | 
|---|
| 33 | /* Detach state.  */ | 
|---|
| 34 | enum | 
|---|
| 35 | { | 
|---|
| 36 | PTHREAD_CREATE_JOINABLE, | 
|---|
| 37 | #define PTHREAD_CREATE_JOINABLE	PTHREAD_CREATE_JOINABLE | 
|---|
| 38 | PTHREAD_CREATE_DETACHED | 
|---|
| 39 | #define PTHREAD_CREATE_DETACHED	PTHREAD_CREATE_DETACHED | 
|---|
| 40 | }; | 
|---|
| 41 |  | 
|---|
| 42 |  | 
|---|
| 43 | /* Mutex types.  */ | 
|---|
| 44 | enum | 
|---|
| 45 | { | 
|---|
| 46 | PTHREAD_MUTEX_TIMED_NP, | 
|---|
| 47 | PTHREAD_MUTEX_RECURSIVE_NP, | 
|---|
| 48 | PTHREAD_MUTEX_ERRORCHECK_NP, | 
|---|
| 49 | PTHREAD_MUTEX_ADAPTIVE_NP | 
|---|
| 50 | #if defined __USE_UNIX98 || defined __USE_XOPEN2K8 | 
|---|
| 51 | , | 
|---|
| 52 | PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, | 
|---|
| 53 | PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, | 
|---|
| 54 | PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, | 
|---|
| 55 | PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL | 
|---|
| 56 | #endif | 
|---|
| 57 | #ifdef __USE_GNU | 
|---|
| 58 | /* For compatibility.  */ | 
|---|
| 59 | , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP | 
|---|
| 60 | #endif | 
|---|
| 61 | }; | 
|---|
| 62 |  | 
|---|
| 63 |  | 
|---|
| 64 | #ifdef __USE_XOPEN2K | 
|---|
| 65 | /* Robust mutex or not flags.  */ | 
|---|
| 66 | enum | 
|---|
| 67 | { | 
|---|
| 68 | PTHREAD_MUTEX_STALLED, | 
|---|
| 69 | PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED, | 
|---|
| 70 | PTHREAD_MUTEX_ROBUST, | 
|---|
| 71 | PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST | 
|---|
| 72 | }; | 
|---|
| 73 | #endif | 
|---|
| 74 |  | 
|---|
| 75 |  | 
|---|
| 76 | #if defined __USE_POSIX199506 || defined __USE_UNIX98 | 
|---|
| 77 | /* Mutex protocols.  */ | 
|---|
| 78 | enum | 
|---|
| 79 | { | 
|---|
| 80 | PTHREAD_PRIO_NONE, | 
|---|
| 81 | PTHREAD_PRIO_INHERIT, | 
|---|
| 82 | PTHREAD_PRIO_PROTECT | 
|---|
| 83 | }; | 
|---|
| 84 | #endif | 
|---|
| 85 |  | 
|---|
| 86 |  | 
|---|
| 87 | #define PTHREAD_MUTEX_INITIALIZER \ | 
|---|
| 88 | { {  __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_TIMED_NP) } } | 
|---|
| 89 | #ifdef __USE_GNU | 
|---|
| 90 | # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ | 
|---|
| 91 | { {  __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_RECURSIVE_NP) } } | 
|---|
| 92 | # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ | 
|---|
| 93 | { {  __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ERRORCHECK_NP) } } | 
|---|
| 94 | # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \ | 
|---|
| 95 | { {  __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ADAPTIVE_NP) } } | 
|---|
| 96 | #endif | 
|---|
| 97 |  | 
|---|
| 98 |  | 
|---|
| 99 | /* Read-write lock types.  */ | 
|---|
| 100 | #if defined __USE_UNIX98 || defined __USE_XOPEN2K | 
|---|
| 101 | enum | 
|---|
| 102 | { | 
|---|
| 103 | PTHREAD_RWLOCK_PREFER_READER_NP, | 
|---|
| 104 | PTHREAD_RWLOCK_PREFER_WRITER_NP, | 
|---|
| 105 | PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, | 
|---|
| 106 | PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP | 
|---|
| 107 | }; | 
|---|
| 108 |  | 
|---|
| 109 |  | 
|---|
| 110 | /* Read-write lock initializers.  */ | 
|---|
| 111 | # define PTHREAD_RWLOCK_INITIALIZER \ | 
|---|
| 112 | { { __PTHREAD_RWLOCK_INITIALIZER (PTHREAD_RWLOCK_DEFAULT_NP) } } | 
|---|
| 113 | # ifdef __USE_GNU | 
|---|
| 114 | #  define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ | 
|---|
| 115 | { { __PTHREAD_RWLOCK_INITIALIZER (PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) } } | 
|---|
| 116 | # endif | 
|---|
| 117 | #endif  /* Unix98 or XOpen2K */ | 
|---|
| 118 |  | 
|---|
| 119 |  | 
|---|
| 120 | /* Scheduler inheritance.  */ | 
|---|
| 121 | enum | 
|---|
| 122 | { | 
|---|
| 123 | PTHREAD_INHERIT_SCHED, | 
|---|
| 124 | #define PTHREAD_INHERIT_SCHED   PTHREAD_INHERIT_SCHED | 
|---|
| 125 | PTHREAD_EXPLICIT_SCHED | 
|---|
| 126 | #define PTHREAD_EXPLICIT_SCHED  PTHREAD_EXPLICIT_SCHED | 
|---|
| 127 | }; | 
|---|
| 128 |  | 
|---|
| 129 |  | 
|---|
| 130 | /* Scope handling.  */ | 
|---|
| 131 | enum | 
|---|
| 132 | { | 
|---|
| 133 | PTHREAD_SCOPE_SYSTEM, | 
|---|
| 134 | #define PTHREAD_SCOPE_SYSTEM    PTHREAD_SCOPE_SYSTEM | 
|---|
| 135 | PTHREAD_SCOPE_PROCESS | 
|---|
| 136 | #define PTHREAD_SCOPE_PROCESS   PTHREAD_SCOPE_PROCESS | 
|---|
| 137 | }; | 
|---|
| 138 |  | 
|---|
| 139 |  | 
|---|
| 140 | /* Process shared or private flag.  */ | 
|---|
| 141 | enum | 
|---|
| 142 | { | 
|---|
| 143 | PTHREAD_PROCESS_PRIVATE, | 
|---|
| 144 | #define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE | 
|---|
| 145 | PTHREAD_PROCESS_SHARED | 
|---|
| 146 | #define PTHREAD_PROCESS_SHARED  PTHREAD_PROCESS_SHARED | 
|---|
| 147 | }; | 
|---|
| 148 |  | 
|---|
| 149 |  | 
|---|
| 150 |  | 
|---|
| 151 | /* Conditional variable handling.  */ | 
|---|
| 152 | #define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } } | 
|---|
| 153 |  | 
|---|
| 154 |  | 
|---|
| 155 | /* Cleanup buffers */ | 
|---|
| 156 | struct _pthread_cleanup_buffer | 
|---|
| 157 | { | 
|---|
| 158 | void (*__routine) (void *);             /* Function to call.  */ | 
|---|
| 159 | void *__arg;                            /* Its argument.  */ | 
|---|
| 160 | int __canceltype;                       /* Saved cancellation type. */ | 
|---|
| 161 | struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions.  */ | 
|---|
| 162 | }; | 
|---|
| 163 |  | 
|---|
| 164 | /* Cancellation */ | 
|---|
| 165 | enum | 
|---|
| 166 | { | 
|---|
| 167 | PTHREAD_CANCEL_ENABLE, | 
|---|
| 168 | #define PTHREAD_CANCEL_ENABLE   PTHREAD_CANCEL_ENABLE | 
|---|
| 169 | PTHREAD_CANCEL_DISABLE | 
|---|
| 170 | #define PTHREAD_CANCEL_DISABLE  PTHREAD_CANCEL_DISABLE | 
|---|
| 171 | }; | 
|---|
| 172 | enum | 
|---|
| 173 | { | 
|---|
| 174 | PTHREAD_CANCEL_DEFERRED, | 
|---|
| 175 | #define PTHREAD_CANCEL_DEFERRED	PTHREAD_CANCEL_DEFERRED | 
|---|
| 176 | PTHREAD_CANCEL_ASYNCHRONOUS | 
|---|
| 177 | #define PTHREAD_CANCEL_ASYNCHRONOUS	PTHREAD_CANCEL_ASYNCHRONOUS | 
|---|
| 178 | }; | 
|---|
| 179 | #define PTHREAD_CANCELED ((void *) -1) | 
|---|
| 180 |  | 
|---|
| 181 |  | 
|---|
| 182 | /* Single execution handling.  */ | 
|---|
| 183 | #define PTHREAD_ONCE_INIT 0 | 
|---|
| 184 |  | 
|---|
| 185 |  | 
|---|
| 186 | #ifdef __USE_XOPEN2K | 
|---|
| 187 | /* Value returned by 'pthread_barrier_wait' for one of the threads after | 
|---|
| 188 | the required number of threads have called this function. | 
|---|
| 189 | -1 is distinct from 0 and all errno constants */ | 
|---|
| 190 | # define PTHREAD_BARRIER_SERIAL_THREAD -1 | 
|---|
| 191 | #endif | 
|---|
| 192 |  | 
|---|
| 193 |  | 
|---|
| 194 | __BEGIN_DECLS | 
|---|
| 195 |  | 
|---|
| 196 | /* Create a new thread, starting with execution of START-ROUTINE | 
|---|
| 197 | getting passed ARG.  Creation attributed come from ATTR.  The new | 
|---|
| 198 | handle is stored in *NEWTHREAD.  */ | 
|---|
| 199 | extern int pthread_create (pthread_t *__restrict __newthread, | 
|---|
| 200 | const pthread_attr_t *__restrict __attr, | 
|---|
| 201 | void *(*__start_routine) (void *), | 
|---|
| 202 | void *__restrict __arg) __THROWNL __nonnull ((1, 3)); | 
|---|
| 203 |  | 
|---|
| 204 | /* Terminate calling thread. | 
|---|
| 205 |  | 
|---|
| 206 | The registered cleanup handlers are called via exception handling | 
|---|
| 207 | so we cannot mark this function with __THROW.*/ | 
|---|
| 208 | extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__)); | 
|---|
| 209 |  | 
|---|
| 210 | /* Make calling thread wait for termination of the thread TH.  The | 
|---|
| 211 | exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN | 
|---|
| 212 | is not NULL. | 
|---|
| 213 |  | 
|---|
| 214 | This function is a cancellation point and therefore not marked with | 
|---|
| 215 | __THROW.  */ | 
|---|
| 216 | extern int pthread_join (pthread_t __th, void **__thread_return); | 
|---|
| 217 |  | 
|---|
| 218 | #ifdef __USE_GNU | 
|---|
| 219 | /* Check whether thread TH has terminated.  If yes return the status of | 
|---|
| 220 | the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL.  */ | 
|---|
| 221 | extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW; | 
|---|
| 222 |  | 
|---|
| 223 | /* Make calling thread wait for termination of the thread TH, but only | 
|---|
| 224 | until TIMEOUT.  The exit status of the thread is stored in | 
|---|
| 225 | *THREAD_RETURN, if THREAD_RETURN is not NULL. | 
|---|
| 226 |  | 
|---|
| 227 | This function is a cancellation point and therefore not marked with | 
|---|
| 228 | __THROW.  */ | 
|---|
| 229 | extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return, | 
|---|
| 230 | const struct timespec *__abstime); | 
|---|
| 231 |  | 
|---|
| 232 | /* Make calling thread wait for termination of the thread TH, but only | 
|---|
| 233 | until TIMEOUT measured against the clock specified by CLOCKID.  The | 
|---|
| 234 | exit status of the thread is stored in *THREAD_RETURN, if | 
|---|
| 235 | THREAD_RETURN is not NULL. | 
|---|
| 236 |  | 
|---|
| 237 | This function is a cancellation point and therefore not marked with | 
|---|
| 238 | __THROW.  */ | 
|---|
| 239 | extern int pthread_clockjoin_np (pthread_t __th, void **__thread_return, | 
|---|
| 240 | clockid_t __clockid, | 
|---|
| 241 | const struct timespec *__abstime); | 
|---|
| 242 | #endif | 
|---|
| 243 |  | 
|---|
| 244 | /* Indicate that the thread TH is never to be joined with PTHREAD_JOIN. | 
|---|
| 245 | The resources of TH will therefore be freed immediately when it | 
|---|
| 246 | terminates, instead of waiting for another thread to perform PTHREAD_JOIN | 
|---|
| 247 | on it.  */ | 
|---|
| 248 | extern int pthread_detach (pthread_t __th) __THROW; | 
|---|
| 249 |  | 
|---|
| 250 |  | 
|---|
| 251 | /* Obtain the identifier of the current thread.  */ | 
|---|
| 252 | extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__)); | 
|---|
| 253 |  | 
|---|
| 254 | /* Compare two thread identifiers.  */ | 
|---|
| 255 | extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) | 
|---|
| 256 | __THROW __attribute__ ((__const__)); | 
|---|
| 257 |  | 
|---|
| 258 |  | 
|---|
| 259 | /* Thread attribute handling.  */ | 
|---|
| 260 |  | 
|---|
| 261 | /* Initialize thread attribute *ATTR with default attributes | 
|---|
| 262 | (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER, | 
|---|
| 263 | no user-provided stack).  */ | 
|---|
| 264 | extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1)); | 
|---|
| 265 |  | 
|---|
| 266 | /* Destroy thread attribute *ATTR.  */ | 
|---|
| 267 | extern int pthread_attr_destroy (pthread_attr_t *__attr) | 
|---|
| 268 | __THROW __nonnull ((1)); | 
|---|
| 269 |  | 
|---|
| 270 | /* Get detach state attribute.  */ | 
|---|
| 271 | extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr, | 
|---|
| 272 | int *__detachstate) | 
|---|
| 273 | __THROW __nonnull ((1, 2)); | 
|---|
| 274 |  | 
|---|
| 275 | /* Set detach state attribute.  */ | 
|---|
| 276 | extern int pthread_attr_setdetachstate (pthread_attr_t *__attr, | 
|---|
| 277 | int __detachstate) | 
|---|
| 278 | __THROW __nonnull ((1)); | 
|---|
| 279 |  | 
|---|
| 280 |  | 
|---|
| 281 | /* Get the size of the guard area created for stack overflow protection.  */ | 
|---|
| 282 | extern int pthread_attr_getguardsize (const pthread_attr_t *__attr, | 
|---|
| 283 | size_t *__guardsize) | 
|---|
| 284 | __THROW __nonnull ((1, 2)); | 
|---|
| 285 |  | 
|---|
| 286 | /* Set the size of the guard area created for stack overflow protection.  */ | 
|---|
| 287 | extern int pthread_attr_setguardsize (pthread_attr_t *__attr, | 
|---|
| 288 | size_t __guardsize) | 
|---|
| 289 | __THROW __nonnull ((1)); | 
|---|
| 290 |  | 
|---|
| 291 |  | 
|---|
| 292 | /* Return in *PARAM the scheduling parameters of *ATTR.  */ | 
|---|
| 293 | extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr, | 
|---|
| 294 | struct sched_param *__restrict __param) | 
|---|
| 295 | __THROW __nonnull ((1, 2)); | 
|---|
| 296 |  | 
|---|
| 297 | /* Set scheduling parameters (priority, etc) in *ATTR according to PARAM.  */ | 
|---|
| 298 | extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr, | 
|---|
| 299 | const struct sched_param *__restrict | 
|---|
| 300 | __param) __THROW __nonnull ((1, 2)); | 
|---|
| 301 |  | 
|---|
| 302 | /* Return in *POLICY the scheduling policy of *ATTR.  */ | 
|---|
| 303 | extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict | 
|---|
| 304 | __attr, int *__restrict __policy) | 
|---|
| 305 | __THROW __nonnull ((1, 2)); | 
|---|
| 306 |  | 
|---|
| 307 | /* Set scheduling policy in *ATTR according to POLICY.  */ | 
|---|
| 308 | extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy) | 
|---|
| 309 | __THROW __nonnull ((1)); | 
|---|
| 310 |  | 
|---|
| 311 | /* Return in *INHERIT the scheduling inheritance mode of *ATTR.  */ | 
|---|
| 312 | extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict | 
|---|
| 313 | __attr, int *__restrict __inherit) | 
|---|
| 314 | __THROW __nonnull ((1, 2)); | 
|---|
| 315 |  | 
|---|
| 316 | /* Set scheduling inheritance mode in *ATTR according to INHERIT.  */ | 
|---|
| 317 | extern int pthread_attr_setinheritsched (pthread_attr_t *__attr, | 
|---|
| 318 | int __inherit) | 
|---|
| 319 | __THROW __nonnull ((1)); | 
|---|
| 320 |  | 
|---|
| 321 |  | 
|---|
| 322 | /* Return in *SCOPE the scheduling contention scope of *ATTR.  */ | 
|---|
| 323 | extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr, | 
|---|
| 324 | int *__restrict __scope) | 
|---|
| 325 | __THROW __nonnull ((1, 2)); | 
|---|
| 326 |  | 
|---|
| 327 | /* Set scheduling contention scope in *ATTR according to SCOPE.  */ | 
|---|
| 328 | extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope) | 
|---|
| 329 | __THROW __nonnull ((1)); | 
|---|
| 330 |  | 
|---|
| 331 | /* Return the previously set address for the stack.  */ | 
|---|
| 332 | extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict | 
|---|
| 333 | __attr, void **__restrict __stackaddr) | 
|---|
| 334 | __THROW __nonnull ((1, 2)) __attribute_deprecated__; | 
|---|
| 335 |  | 
|---|
| 336 | /* Set the starting address of the stack of the thread to be created. | 
|---|
| 337 | Depending on whether the stack grows up or down the value must either | 
|---|
| 338 | be higher or lower than all the address in the memory block.  The | 
|---|
| 339 | minimal size of the block must be PTHREAD_STACK_MIN.  */ | 
|---|
| 340 | extern int pthread_attr_setstackaddr (pthread_attr_t *__attr, | 
|---|
| 341 | void *__stackaddr) | 
|---|
| 342 | __THROW __nonnull ((1)) __attribute_deprecated__; | 
|---|
| 343 |  | 
|---|
| 344 | /* Return the currently used minimal stack size.  */ | 
|---|
| 345 | extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict | 
|---|
| 346 | __attr, size_t *__restrict __stacksize) | 
|---|
| 347 | __THROW __nonnull ((1, 2)); | 
|---|
| 348 |  | 
|---|
| 349 | /* Add information about the minimum stack size needed for the thread | 
|---|
| 350 | to be started.  This size must never be less than PTHREAD_STACK_MIN | 
|---|
| 351 | and must also not exceed the system limits.  */ | 
|---|
| 352 | extern int pthread_attr_setstacksize (pthread_attr_t *__attr, | 
|---|
| 353 | size_t __stacksize) | 
|---|
| 354 | __THROW __nonnull ((1)); | 
|---|
| 355 |  | 
|---|
| 356 | #ifdef __USE_XOPEN2K | 
|---|
| 357 | /* Return the previously set address for the stack.  */ | 
|---|
| 358 | extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr, | 
|---|
| 359 | void **__restrict __stackaddr, | 
|---|
| 360 | size_t *__restrict __stacksize) | 
|---|
| 361 | __THROW __nonnull ((1, 2, 3)); | 
|---|
| 362 |  | 
|---|
| 363 | /* The following two interfaces are intended to replace the last two.  They | 
|---|
| 364 | require setting the address as well as the size since only setting the | 
|---|
| 365 | address will make the implementation on some architectures impossible.  */ | 
|---|
| 366 | extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr, | 
|---|
| 367 | size_t __stacksize) __THROW __nonnull ((1)); | 
|---|
| 368 | #endif | 
|---|
| 369 |  | 
|---|
| 370 | #ifdef __USE_GNU | 
|---|
| 371 | /* Thread created with attribute ATTR will be limited to run only on | 
|---|
| 372 | the processors represented in CPUSET.  */ | 
|---|
| 373 | extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr, | 
|---|
| 374 | size_t __cpusetsize, | 
|---|
| 375 | const cpu_set_t *__cpuset) | 
|---|
| 376 | __THROW __nonnull ((1, 3)); | 
|---|
| 377 |  | 
|---|
| 378 | /* Get bit set in CPUSET representing the processors threads created with | 
|---|
| 379 | ATTR can run on.  */ | 
|---|
| 380 | extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr, | 
|---|
| 381 | size_t __cpusetsize, | 
|---|
| 382 | cpu_set_t *__cpuset) | 
|---|
| 383 | __THROW __nonnull ((1, 3)); | 
|---|
| 384 |  | 
|---|
| 385 | /* Get the default attributes used by pthread_create in this process.  */ | 
|---|
| 386 | extern int pthread_getattr_default_np (pthread_attr_t *__attr) | 
|---|
| 387 | __THROW __nonnull ((1)); | 
|---|
| 388 |  | 
|---|
| 389 | /* Store *SIGMASK as the signal mask for the new thread in *ATTR.  */ | 
|---|
| 390 | extern int pthread_attr_setsigmask_np (pthread_attr_t *__attr, | 
|---|
| 391 | const __sigset_t *sigmask); | 
|---|
| 392 |  | 
|---|
| 393 | /* Store the signal mask of *ATTR in *SIGMASK.  If there is no signal | 
|---|
| 394 | mask stored, return PTHREAD_ATTR_NOSIGMASK_NP.  Return zero on | 
|---|
| 395 | success.  */ | 
|---|
| 396 | extern int pthread_attr_getsigmask_np (const pthread_attr_t *__attr, | 
|---|
| 397 | __sigset_t *sigmask); | 
|---|
| 398 |  | 
|---|
| 399 | /* Special return value from pthread_attr_getsigmask_np if the signal | 
|---|
| 400 | mask has not been set.  */ | 
|---|
| 401 | #define PTHREAD_ATTR_NO_SIGMASK_NP (-1) | 
|---|
| 402 |  | 
|---|
| 403 | /* Set the default attributes to be used by pthread_create in this | 
|---|
| 404 | process.  */ | 
|---|
| 405 | extern int pthread_setattr_default_np (const pthread_attr_t *__attr) | 
|---|
| 406 | __THROW __nonnull ((1)); | 
|---|
| 407 |  | 
|---|
| 408 | /* Initialize thread attribute *ATTR with attributes corresponding to the | 
|---|
| 409 | already running thread TH.  It shall be called on uninitialized ATTR | 
|---|
| 410 | and destroyed with pthread_attr_destroy when no longer needed.  */ | 
|---|
| 411 | extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) | 
|---|
| 412 | __THROW __nonnull ((2)); | 
|---|
| 413 | #endif | 
|---|
| 414 |  | 
|---|
| 415 |  | 
|---|
| 416 | /* Functions for scheduling control.  */ | 
|---|
| 417 |  | 
|---|
| 418 | /* Set the scheduling parameters for TARGET_THREAD according to POLICY | 
|---|
| 419 | and *PARAM.  */ | 
|---|
| 420 | extern int pthread_setschedparam (pthread_t __target_thread, int __policy, | 
|---|
| 421 | const struct sched_param *__param) | 
|---|
| 422 | __THROW __nonnull ((3)); | 
|---|
| 423 |  | 
|---|
| 424 | /* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */ | 
|---|
| 425 | extern int pthread_getschedparam (pthread_t __target_thread, | 
|---|
| 426 | int *__restrict __policy, | 
|---|
| 427 | struct sched_param *__restrict __param) | 
|---|
| 428 | __THROW __nonnull ((2, 3)); | 
|---|
| 429 |  | 
|---|
| 430 | /* Set the scheduling priority for TARGET_THREAD.  */ | 
|---|
| 431 | extern int pthread_setschedprio (pthread_t __target_thread, int __prio) | 
|---|
| 432 | __THROW; | 
|---|
| 433 |  | 
|---|
| 434 |  | 
|---|
| 435 | #ifdef __USE_GNU | 
|---|
| 436 | /* Get thread name visible in the kernel and its interfaces.  */ | 
|---|
| 437 | extern int pthread_getname_np (pthread_t __target_thread, char *__buf, | 
|---|
| 438 | size_t __buflen) | 
|---|
| 439 | __THROW __nonnull ((2)); | 
|---|
| 440 |  | 
|---|
| 441 | /* Set thread name visible in the kernel and its interfaces.  */ | 
|---|
| 442 | extern int pthread_setname_np (pthread_t __target_thread, const char *__name) | 
|---|
| 443 | __THROW __nonnull ((2)); | 
|---|
| 444 | #endif | 
|---|
| 445 |  | 
|---|
| 446 |  | 
|---|
| 447 | #ifdef __USE_UNIX98 | 
|---|
| 448 | /* Determine level of concurrency.  */ | 
|---|
| 449 | extern int pthread_getconcurrency (void) __THROW; | 
|---|
| 450 |  | 
|---|
| 451 | /* Set new concurrency level to LEVEL.  */ | 
|---|
| 452 | extern int pthread_setconcurrency (int __level) __THROW; | 
|---|
| 453 | #endif | 
|---|
| 454 |  | 
|---|
| 455 | #ifdef __USE_GNU | 
|---|
| 456 | /* Yield the processor to another thread or process. | 
|---|
| 457 | This function is similar to the POSIX `sched_yield' function but | 
|---|
| 458 | might be differently implemented in the case of a m-on-n thread | 
|---|
| 459 | implementation.  */ | 
|---|
| 460 | extern int pthread_yield (void) __THROW; | 
|---|
| 461 |  | 
|---|
| 462 |  | 
|---|
| 463 | /* Limit specified thread TH to run only on the processors represented | 
|---|
| 464 | in CPUSET.  */ | 
|---|
| 465 | extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize, | 
|---|
| 466 | const cpu_set_t *__cpuset) | 
|---|
| 467 | __THROW __nonnull ((3)); | 
|---|
| 468 |  | 
|---|
| 469 | /* Get bit set in CPUSET representing the processors TH can run on.  */ | 
|---|
| 470 | extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize, | 
|---|
| 471 | cpu_set_t *__cpuset) | 
|---|
| 472 | __THROW __nonnull ((3)); | 
|---|
| 473 | #endif | 
|---|
| 474 |  | 
|---|
| 475 |  | 
|---|
| 476 | /* Functions for handling initialization.  */ | 
|---|
| 477 |  | 
|---|
| 478 | /* Guarantee that the initialization function INIT_ROUTINE will be called | 
|---|
| 479 | only once, even if pthread_once is executed several times with the | 
|---|
| 480 | same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or | 
|---|
| 481 | extern variable initialized to PTHREAD_ONCE_INIT. | 
|---|
| 482 |  | 
|---|
| 483 | The initialization functions might throw exception which is why | 
|---|
| 484 | this function is not marked with __THROW.  */ | 
|---|
| 485 | extern int pthread_once (pthread_once_t *__once_control, | 
|---|
| 486 | void (*__init_routine) (void)) __nonnull ((1, 2)); | 
|---|
| 487 |  | 
|---|
| 488 |  | 
|---|
| 489 | /* Functions for handling cancellation. | 
|---|
| 490 |  | 
|---|
| 491 | Note that these functions are explicitly not marked to not throw an | 
|---|
| 492 | exception in C++ code.  If cancellation is implemented by unwinding | 
|---|
| 493 | this is necessary to have the compiler generate the unwind information.  */ | 
|---|
| 494 |  | 
|---|
| 495 | /* Set cancelability state of current thread to STATE, returning old | 
|---|
| 496 | state in *OLDSTATE if OLDSTATE is not NULL.  */ | 
|---|
| 497 | extern int pthread_setcancelstate (int __state, int *__oldstate); | 
|---|
| 498 |  | 
|---|
| 499 | /* Set cancellation state of current thread to TYPE, returning the old | 
|---|
| 500 | type in *OLDTYPE if OLDTYPE is not NULL.  */ | 
|---|
| 501 | extern int pthread_setcanceltype (int __type, int *__oldtype); | 
|---|
| 502 |  | 
|---|
| 503 | /* Cancel THREAD immediately or at the next possibility.  */ | 
|---|
| 504 | extern int pthread_cancel (pthread_t __th); | 
|---|
| 505 |  | 
|---|
| 506 | /* Test for pending cancellation for the current thread and terminate | 
|---|
| 507 | the thread as per pthread_exit(PTHREAD_CANCELED) if it has been | 
|---|
| 508 | cancelled.  */ | 
|---|
| 509 | extern void pthread_testcancel (void); | 
|---|
| 510 |  | 
|---|
| 511 |  | 
|---|
| 512 | /* Cancellation handling with integration into exception handling.  */ | 
|---|
| 513 |  | 
|---|
| 514 | typedef struct | 
|---|
| 515 | { | 
|---|
| 516 | struct | 
|---|
| 517 | { | 
|---|
| 518 | __jmp_buf __cancel_jmp_buf; | 
|---|
| 519 | int __mask_was_saved; | 
|---|
| 520 | } __cancel_jmp_buf[1]; | 
|---|
| 521 | void *__pad[4]; | 
|---|
| 522 | } __pthread_unwind_buf_t __attribute__ ((__aligned__)); | 
|---|
| 523 |  | 
|---|
| 524 | /* No special attributes by default.  */ | 
|---|
| 525 | #ifndef __cleanup_fct_attribute | 
|---|
| 526 | # define __cleanup_fct_attribute | 
|---|
| 527 | #endif | 
|---|
| 528 |  | 
|---|
| 529 |  | 
|---|
| 530 | /* Structure to hold the cleanup handler information.  */ | 
|---|
| 531 | struct __pthread_cleanup_frame | 
|---|
| 532 | { | 
|---|
| 533 | void (*__cancel_routine) (void *); | 
|---|
| 534 | void *__cancel_arg; | 
|---|
| 535 | int __do_it; | 
|---|
| 536 | int __cancel_type; | 
|---|
| 537 | }; | 
|---|
| 538 |  | 
|---|
| 539 | #if defined __GNUC__ && defined __EXCEPTIONS | 
|---|
| 540 | # ifdef __cplusplus | 
|---|
| 541 | /* Class to handle cancellation handler invocation.  */ | 
|---|
| 542 | class __pthread_cleanup_class | 
|---|
| 543 | { | 
|---|
| 544 | void (*__cancel_routine) (void *); | 
|---|
| 545 | void *__cancel_arg; | 
|---|
| 546 | int __do_it; | 
|---|
| 547 | int __cancel_type; | 
|---|
| 548 |  | 
|---|
| 549 | public: | 
|---|
| 550 | __pthread_cleanup_class (void (*__fct) (void *), void *__arg) | 
|---|
| 551 | : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { } | 
|---|
| 552 | ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); } | 
|---|
| 553 | void __setdoit (int __newval) { __do_it = __newval; } | 
|---|
| 554 | void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, | 
|---|
| 555 | &__cancel_type); } | 
|---|
| 556 | void __restore () const { pthread_setcanceltype (__cancel_type, 0); } | 
|---|
| 557 | }; | 
|---|
| 558 |  | 
|---|
| 559 | /* Install a cleanup handler: ROUTINE will be called with arguments ARG | 
|---|
| 560 | when the thread is canceled or calls pthread_exit.  ROUTINE will also | 
|---|
| 561 | be called with arguments ARG when the matching pthread_cleanup_pop | 
|---|
| 562 | is executed with non-zero EXECUTE argument. | 
|---|
| 563 |  | 
|---|
| 564 | pthread_cleanup_push and pthread_cleanup_pop are macros and must always | 
|---|
| 565 | be used in matching pairs at the same nesting level of braces.  */ | 
|---|
| 566 | #  define pthread_cleanup_push(routine, arg) \ | 
|---|
| 567 | do {									      \ | 
|---|
| 568 | __pthread_cleanup_class __clframe (routine, arg) | 
|---|
| 569 |  | 
|---|
| 570 | /* Remove a cleanup handler installed by the matching pthread_cleanup_push. | 
|---|
| 571 | If EXECUTE is non-zero, the handler function is called. */ | 
|---|
| 572 | #  define pthread_cleanup_pop(execute) \ | 
|---|
| 573 | __clframe.__setdoit (execute);					      \ | 
|---|
| 574 | } while (0) | 
|---|
| 575 |  | 
|---|
| 576 | #  ifdef __USE_GNU | 
|---|
| 577 | /* Install a cleanup handler as pthread_cleanup_push does, but also | 
|---|
| 578 | saves the current cancellation type and sets it to deferred | 
|---|
| 579 | cancellation.  */ | 
|---|
| 580 | #   define pthread_cleanup_push_defer_np(routine, arg) \ | 
|---|
| 581 | do {									      \ | 
|---|
| 582 | __pthread_cleanup_class __clframe (routine, arg);			      \ | 
|---|
| 583 | __clframe.__defer () | 
|---|
| 584 |  | 
|---|
| 585 | /* Remove a cleanup handler as pthread_cleanup_pop does, but also | 
|---|
| 586 | restores the cancellation type that was in effect when the matching | 
|---|
| 587 | pthread_cleanup_push_defer was called.  */ | 
|---|
| 588 | #   define pthread_cleanup_pop_restore_np(execute) \ | 
|---|
| 589 | __clframe.__restore ();						      \ | 
|---|
| 590 | __clframe.__setdoit (execute);					      \ | 
|---|
| 591 | } while (0) | 
|---|
| 592 | #  endif | 
|---|
| 593 | # else | 
|---|
| 594 | /* Function called to call the cleanup handler.  As an extern inline | 
|---|
| 595 | function the compiler is free to decide inlining the change when | 
|---|
| 596 | needed or fall back on the copy which must exist somewhere | 
|---|
| 597 | else.  */ | 
|---|
| 598 | __extern_inline void | 
|---|
| 599 | __pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame) | 
|---|
| 600 | { | 
|---|
| 601 | if (__frame->__do_it) | 
|---|
| 602 | __frame->__cancel_routine (__frame->__cancel_arg); | 
|---|
| 603 | } | 
|---|
| 604 |  | 
|---|
| 605 | /* Install a cleanup handler: ROUTINE will be called with arguments ARG | 
|---|
| 606 | when the thread is canceled or calls pthread_exit.  ROUTINE will also | 
|---|
| 607 | be called with arguments ARG when the matching pthread_cleanup_pop | 
|---|
| 608 | is executed with non-zero EXECUTE argument. | 
|---|
| 609 |  | 
|---|
| 610 | pthread_cleanup_push and pthread_cleanup_pop are macros and must always | 
|---|
| 611 | be used in matching pairs at the same nesting level of braces.  */ | 
|---|
| 612 | #  define pthread_cleanup_push(routine, arg) \ | 
|---|
| 613 | do {									      \ | 
|---|
| 614 | struct __pthread_cleanup_frame __clframe				      \ | 
|---|
| 615 | __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))		      \ | 
|---|
| 616 | = { .__cancel_routine = (routine), .__cancel_arg = (arg),	 	      \ | 
|---|
| 617 | .__do_it = 1 }; | 
|---|
| 618 |  | 
|---|
| 619 | /* Remove a cleanup handler installed by the matching pthread_cleanup_push. | 
|---|
| 620 | If EXECUTE is non-zero, the handler function is called. */ | 
|---|
| 621 | #  define pthread_cleanup_pop(execute) \ | 
|---|
| 622 | __clframe.__do_it = (execute);					      \ | 
|---|
| 623 | } while (0) | 
|---|
| 624 |  | 
|---|
| 625 | #  ifdef __USE_GNU | 
|---|
| 626 | /* Install a cleanup handler as pthread_cleanup_push does, but also | 
|---|
| 627 | saves the current cancellation type and sets it to deferred | 
|---|
| 628 | cancellation.  */ | 
|---|
| 629 | #   define pthread_cleanup_push_defer_np(routine, arg) \ | 
|---|
| 630 | do {									      \ | 
|---|
| 631 | struct __pthread_cleanup_frame __clframe				      \ | 
|---|
| 632 | __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))		      \ | 
|---|
| 633 | = { .__cancel_routine = (routine), .__cancel_arg = (arg),		      \ | 
|---|
| 634 | .__do_it = 1 };						      \ | 
|---|
| 635 | (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,		      \ | 
|---|
| 636 | &__clframe.__cancel_type) | 
|---|
| 637 |  | 
|---|
| 638 | /* Remove a cleanup handler as pthread_cleanup_pop does, but also | 
|---|
| 639 | restores the cancellation type that was in effect when the matching | 
|---|
| 640 | pthread_cleanup_push_defer was called.  */ | 
|---|
| 641 | #   define pthread_cleanup_pop_restore_np(execute) \ | 
|---|
| 642 | (void) pthread_setcanceltype (__clframe.__cancel_type, NULL);	      \ | 
|---|
| 643 | __clframe.__do_it = (execute);					      \ | 
|---|
| 644 | } while (0) | 
|---|
| 645 | #  endif | 
|---|
| 646 | # endif | 
|---|
| 647 | #else | 
|---|
| 648 | /* Install a cleanup handler: ROUTINE will be called with arguments ARG | 
|---|
| 649 | when the thread is canceled or calls pthread_exit.  ROUTINE will also | 
|---|
| 650 | be called with arguments ARG when the matching pthread_cleanup_pop | 
|---|
| 651 | is executed with non-zero EXECUTE argument. | 
|---|
| 652 |  | 
|---|
| 653 | pthread_cleanup_push and pthread_cleanup_pop are macros and must always | 
|---|
| 654 | be used in matching pairs at the same nesting level of braces.  */ | 
|---|
| 655 | # define pthread_cleanup_push(routine, arg) \ | 
|---|
| 656 | do {									      \ | 
|---|
| 657 | __pthread_unwind_buf_t __cancel_buf;				      \ | 
|---|
| 658 | void (*__cancel_routine) (void *) = (routine);			      \ | 
|---|
| 659 | void *__cancel_arg = (arg);						      \ | 
|---|
| 660 | int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \ | 
|---|
| 661 | __cancel_buf.__cancel_jmp_buf, 0);    \ | 
|---|
| 662 | if (__glibc_unlikely (__not_first_call))				      \ | 
|---|
| 663 | {									      \ | 
|---|
| 664 | __cancel_routine (__cancel_arg);				      \ | 
|---|
| 665 | __pthread_unwind_next (&__cancel_buf);				      \ | 
|---|
| 666 | /* NOTREACHED */						      \ | 
|---|
| 667 | }									      \ | 
|---|
| 668 | \ | 
|---|
| 669 | __pthread_register_cancel (&__cancel_buf);				      \ | 
|---|
| 670 | do { | 
|---|
| 671 | extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf) | 
|---|
| 672 | __cleanup_fct_attribute; | 
|---|
| 673 |  | 
|---|
| 674 | /* Remove a cleanup handler installed by the matching pthread_cleanup_push. | 
|---|
| 675 | If EXECUTE is non-zero, the handler function is called. */ | 
|---|
| 676 | # define pthread_cleanup_pop(execute) \ | 
|---|
| 677 | do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\ | 
|---|
| 678 | } while (0);							      \ | 
|---|
| 679 | __pthread_unregister_cancel (&__cancel_buf);			      \ | 
|---|
| 680 | if (execute)							      \ | 
|---|
| 681 | __cancel_routine (__cancel_arg);					      \ | 
|---|
| 682 | } while (0) | 
|---|
| 683 | extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf) | 
|---|
| 684 | __cleanup_fct_attribute; | 
|---|
| 685 |  | 
|---|
| 686 | # ifdef __USE_GNU | 
|---|
| 687 | /* Install a cleanup handler as pthread_cleanup_push does, but also | 
|---|
| 688 | saves the current cancellation type and sets it to deferred | 
|---|
| 689 | cancellation.  */ | 
|---|
| 690 | #  define pthread_cleanup_push_defer_np(routine, arg) \ | 
|---|
| 691 | do {									      \ | 
|---|
| 692 | __pthread_unwind_buf_t __cancel_buf;				      \ | 
|---|
| 693 | void (*__cancel_routine) (void *) = (routine);			      \ | 
|---|
| 694 | void *__cancel_arg = (arg);						      \ | 
|---|
| 695 | int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \ | 
|---|
| 696 | __cancel_buf.__cancel_jmp_buf, 0);    \ | 
|---|
| 697 | if (__glibc_unlikely (__not_first_call))				      \ | 
|---|
| 698 | {									      \ | 
|---|
| 699 | __cancel_routine (__cancel_arg);				      \ | 
|---|
| 700 | __pthread_unwind_next (&__cancel_buf);				      \ | 
|---|
| 701 | /* NOTREACHED */						      \ | 
|---|
| 702 | }									      \ | 
|---|
| 703 | \ | 
|---|
| 704 | __pthread_register_cancel_defer (&__cancel_buf);			      \ | 
|---|
| 705 | do { | 
|---|
| 706 | extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf) | 
|---|
| 707 | __cleanup_fct_attribute; | 
|---|
| 708 |  | 
|---|
| 709 | /* Remove a cleanup handler as pthread_cleanup_pop does, but also | 
|---|
| 710 | restores the cancellation type that was in effect when the matching | 
|---|
| 711 | pthread_cleanup_push_defer was called.  */ | 
|---|
| 712 | #  define pthread_cleanup_pop_restore_np(execute) \ | 
|---|
| 713 | do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\ | 
|---|
| 714 | } while (0);							      \ | 
|---|
| 715 | __pthread_unregister_cancel_restore (&__cancel_buf);		      \ | 
|---|
| 716 | if (execute)							      \ | 
|---|
| 717 | __cancel_routine (__cancel_arg);					      \ | 
|---|
| 718 | } while (0) | 
|---|
| 719 | extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf) | 
|---|
| 720 | __cleanup_fct_attribute; | 
|---|
| 721 | # endif | 
|---|
| 722 |  | 
|---|
| 723 | /* Internal interface to initiate cleanup.  */ | 
|---|
| 724 | extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf) | 
|---|
| 725 | __cleanup_fct_attribute __attribute__ ((__noreturn__)) | 
|---|
| 726 | # ifndef SHARED | 
|---|
| 727 | __attribute__ ((__weak__)) | 
|---|
| 728 | # endif | 
|---|
| 729 | ; | 
|---|
| 730 | #endif | 
|---|
| 731 |  | 
|---|
| 732 | /* Function used in the macros.  */ | 
|---|
| 733 | struct __jmp_buf_tag; | 
|---|
| 734 | extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL; | 
|---|
| 735 |  | 
|---|
| 736 |  | 
|---|
| 737 | /* Mutex handling.  */ | 
|---|
| 738 |  | 
|---|
| 739 | /* Initialize a mutex.  */ | 
|---|
| 740 | extern int pthread_mutex_init (pthread_mutex_t *__mutex, | 
|---|
| 741 | const pthread_mutexattr_t *__mutexattr) | 
|---|
| 742 | __THROW __nonnull ((1)); | 
|---|
| 743 |  | 
|---|
| 744 | /* Destroy a mutex.  */ | 
|---|
| 745 | extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) | 
|---|
| 746 | __THROW __nonnull ((1)); | 
|---|
| 747 |  | 
|---|
| 748 | /* Try locking a mutex.  */ | 
|---|
| 749 | extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) | 
|---|
| 750 | __THROWNL __nonnull ((1)); | 
|---|
| 751 |  | 
|---|
| 752 | /* Lock a mutex.  */ | 
|---|
| 753 | extern int pthread_mutex_lock (pthread_mutex_t *__mutex) | 
|---|
| 754 | __THROWNL __nonnull ((1)); | 
|---|
| 755 |  | 
|---|
| 756 | #ifdef __USE_XOPEN2K | 
|---|
| 757 | /* Wait until lock becomes available, or specified time passes. */ | 
|---|
| 758 | extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex, | 
|---|
| 759 | const struct timespec *__restrict | 
|---|
| 760 | __abstime) __THROWNL __nonnull ((1, 2)); | 
|---|
| 761 | #endif | 
|---|
| 762 |  | 
|---|
| 763 | #ifdef __USE_GNU | 
|---|
| 764 | extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex, | 
|---|
| 765 | clockid_t __clockid, | 
|---|
| 766 | const struct timespec *__restrict | 
|---|
| 767 | __abstime) __THROWNL __nonnull ((1, 3)); | 
|---|
| 768 | #endif | 
|---|
| 769 |  | 
|---|
| 770 | /* Unlock a mutex.  */ | 
|---|
| 771 | extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) | 
|---|
| 772 | __THROWNL __nonnull ((1)); | 
|---|
| 773 |  | 
|---|
| 774 |  | 
|---|
| 775 | /* Get the priority ceiling of MUTEX.  */ | 
|---|
| 776 | extern int pthread_mutex_getprioceiling (const pthread_mutex_t * | 
|---|
| 777 | __restrict __mutex, | 
|---|
| 778 | int *__restrict __prioceiling) | 
|---|
| 779 | __THROW __nonnull ((1, 2)); | 
|---|
| 780 |  | 
|---|
| 781 | /* Set the priority ceiling of MUTEX to PRIOCEILING, return old | 
|---|
| 782 | priority ceiling value in *OLD_CEILING.  */ | 
|---|
| 783 | extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex, | 
|---|
| 784 | int __prioceiling, | 
|---|
| 785 | int *__restrict __old_ceiling) | 
|---|
| 786 | __THROW __nonnull ((1, 3)); | 
|---|
| 787 |  | 
|---|
| 788 |  | 
|---|
| 789 | #ifdef __USE_XOPEN2K8 | 
|---|
| 790 | /* Declare the state protected by MUTEX as consistent.  */ | 
|---|
| 791 | extern int pthread_mutex_consistent (pthread_mutex_t *__mutex) | 
|---|
| 792 | __THROW __nonnull ((1)); | 
|---|
| 793 | # ifdef __USE_GNU | 
|---|
| 794 | extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex) | 
|---|
| 795 | __THROW __nonnull ((1)); | 
|---|
| 796 | # endif | 
|---|
| 797 | #endif | 
|---|
| 798 |  | 
|---|
| 799 |  | 
|---|
| 800 | /* Functions for handling mutex attributes.  */ | 
|---|
| 801 |  | 
|---|
| 802 | /* Initialize mutex attribute object ATTR with default attributes | 
|---|
| 803 | (kind is PTHREAD_MUTEX_TIMED_NP).  */ | 
|---|
| 804 | extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) | 
|---|
| 805 | __THROW __nonnull ((1)); | 
|---|
| 806 |  | 
|---|
| 807 | /* Destroy mutex attribute object ATTR.  */ | 
|---|
| 808 | extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) | 
|---|
| 809 | __THROW __nonnull ((1)); | 
|---|
| 810 |  | 
|---|
| 811 | /* Get the process-shared flag of the mutex attribute ATTR.  */ | 
|---|
| 812 | extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t * | 
|---|
| 813 | __restrict __attr, | 
|---|
| 814 | int *__restrict __pshared) | 
|---|
| 815 | __THROW __nonnull ((1, 2)); | 
|---|
| 816 |  | 
|---|
| 817 | /* Set the process-shared flag of the mutex attribute ATTR.  */ | 
|---|
| 818 | extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr, | 
|---|
| 819 | int __pshared) | 
|---|
| 820 | __THROW __nonnull ((1)); | 
|---|
| 821 |  | 
|---|
| 822 | #if defined __USE_UNIX98 || defined __USE_XOPEN2K8 | 
|---|
| 823 | /* Return in *KIND the mutex kind attribute in *ATTR.  */ | 
|---|
| 824 | extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict | 
|---|
| 825 | __attr, int *__restrict __kind) | 
|---|
| 826 | __THROW __nonnull ((1, 2)); | 
|---|
| 827 |  | 
|---|
| 828 | /* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL, | 
|---|
| 829 | PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or | 
|---|
| 830 | PTHREAD_MUTEX_DEFAULT).  */ | 
|---|
| 831 | extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) | 
|---|
| 832 | __THROW __nonnull ((1)); | 
|---|
| 833 | #endif | 
|---|
| 834 |  | 
|---|
| 835 | /* Return in *PROTOCOL the mutex protocol attribute in *ATTR.  */ | 
|---|
| 836 | extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t * | 
|---|
| 837 | __restrict __attr, | 
|---|
| 838 | int *__restrict __protocol) | 
|---|
| 839 | __THROW __nonnull ((1, 2)); | 
|---|
| 840 |  | 
|---|
| 841 | /* Set the mutex protocol attribute in *ATTR to PROTOCOL (either | 
|---|
| 842 | PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT).  */ | 
|---|
| 843 | extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr, | 
|---|
| 844 | int __protocol) | 
|---|
| 845 | __THROW __nonnull ((1)); | 
|---|
| 846 |  | 
|---|
| 847 | /* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR.  */ | 
|---|
| 848 | extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t * | 
|---|
| 849 | __restrict __attr, | 
|---|
| 850 | int *__restrict __prioceiling) | 
|---|
| 851 | __THROW __nonnull ((1, 2)); | 
|---|
| 852 |  | 
|---|
| 853 | /* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING.  */ | 
|---|
| 854 | extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr, | 
|---|
| 855 | int __prioceiling) | 
|---|
| 856 | __THROW __nonnull ((1)); | 
|---|
| 857 |  | 
|---|
| 858 | #ifdef __USE_XOPEN2K | 
|---|
| 859 | /* Get the robustness flag of the mutex attribute ATTR.  */ | 
|---|
| 860 | extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr, | 
|---|
| 861 | int *__robustness) | 
|---|
| 862 | __THROW __nonnull ((1, 2)); | 
|---|
| 863 | # ifdef __USE_GNU | 
|---|
| 864 | extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr, | 
|---|
| 865 | int *__robustness) | 
|---|
| 866 | __THROW __nonnull ((1, 2)); | 
|---|
| 867 | # endif | 
|---|
| 868 |  | 
|---|
| 869 | /* Set the robustness flag of the mutex attribute ATTR.  */ | 
|---|
| 870 | extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr, | 
|---|
| 871 | int __robustness) | 
|---|
| 872 | __THROW __nonnull ((1)); | 
|---|
| 873 | # ifdef __USE_GNU | 
|---|
| 874 | extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr, | 
|---|
| 875 | int __robustness) | 
|---|
| 876 | __THROW __nonnull ((1)); | 
|---|
| 877 | # endif | 
|---|
| 878 | #endif | 
|---|
| 879 |  | 
|---|
| 880 |  | 
|---|
| 881 | #if defined __USE_UNIX98 || defined __USE_XOPEN2K | 
|---|
| 882 | /* Functions for handling read-write locks.  */ | 
|---|
| 883 |  | 
|---|
| 884 | /* Initialize read-write lock RWLOCK using attributes ATTR, or use | 
|---|
| 885 | the default values if later is NULL.  */ | 
|---|
| 886 | extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock, | 
|---|
| 887 | const pthread_rwlockattr_t *__restrict | 
|---|
| 888 | __attr) __THROW __nonnull ((1)); | 
|---|
| 889 |  | 
|---|
| 890 | /* Destroy read-write lock RWLOCK.  */ | 
|---|
| 891 | extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) | 
|---|
| 892 | __THROW __nonnull ((1)); | 
|---|
| 893 |  | 
|---|
| 894 | /* Acquire read lock for RWLOCK.  */ | 
|---|
| 895 | extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) | 
|---|
| 896 | __THROWNL __nonnull ((1)); | 
|---|
| 897 |  | 
|---|
| 898 | /* Try to acquire read lock for RWLOCK.  */ | 
|---|
| 899 | extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) | 
|---|
| 900 | __THROWNL __nonnull ((1)); | 
|---|
| 901 |  | 
|---|
| 902 | # ifdef __USE_XOPEN2K | 
|---|
| 903 | /* Try to acquire read lock for RWLOCK or return after specfied time.  */ | 
|---|
| 904 | extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock, | 
|---|
| 905 | const struct timespec *__restrict | 
|---|
| 906 | __abstime) __THROWNL __nonnull ((1, 2)); | 
|---|
| 907 | # endif | 
|---|
| 908 |  | 
|---|
| 909 | # ifdef __USE_GNU | 
|---|
| 910 | extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock, | 
|---|
| 911 | clockid_t __clockid, | 
|---|
| 912 | const struct timespec *__restrict | 
|---|
| 913 | __abstime) __THROWNL __nonnull ((1, 3)); | 
|---|
| 914 | # endif | 
|---|
| 915 |  | 
|---|
| 916 | /* Acquire write lock for RWLOCK.  */ | 
|---|
| 917 | extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) | 
|---|
| 918 | __THROWNL __nonnull ((1)); | 
|---|
| 919 |  | 
|---|
| 920 | /* Try to acquire write lock for RWLOCK.  */ | 
|---|
| 921 | extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) | 
|---|
| 922 | __THROWNL __nonnull ((1)); | 
|---|
| 923 |  | 
|---|
| 924 | # ifdef __USE_XOPEN2K | 
|---|
| 925 | /* Try to acquire write lock for RWLOCK or return after specfied time.  */ | 
|---|
| 926 | extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock, | 
|---|
| 927 | const struct timespec *__restrict | 
|---|
| 928 | __abstime) __THROWNL __nonnull ((1, 2)); | 
|---|
| 929 | # endif | 
|---|
| 930 |  | 
|---|
| 931 | # ifdef __USE_GNU | 
|---|
| 932 | extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock, | 
|---|
| 933 | clockid_t __clockid, | 
|---|
| 934 | const struct timespec *__restrict | 
|---|
| 935 | __abstime) __THROWNL __nonnull ((1, 3)); | 
|---|
| 936 | # endif | 
|---|
| 937 |  | 
|---|
| 938 | /* Unlock RWLOCK.  */ | 
|---|
| 939 | extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) | 
|---|
| 940 | __THROWNL __nonnull ((1)); | 
|---|
| 941 |  | 
|---|
| 942 |  | 
|---|
| 943 | /* Functions for handling read-write lock attributes.  */ | 
|---|
| 944 |  | 
|---|
| 945 | /* Initialize attribute object ATTR with default values.  */ | 
|---|
| 946 | extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) | 
|---|
| 947 | __THROW __nonnull ((1)); | 
|---|
| 948 |  | 
|---|
| 949 | /* Destroy attribute object ATTR.  */ | 
|---|
| 950 | extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) | 
|---|
| 951 | __THROW __nonnull ((1)); | 
|---|
| 952 |  | 
|---|
| 953 | /* Return current setting of process-shared attribute of ATTR in PSHARED.  */ | 
|---|
| 954 | extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * | 
|---|
| 955 | __restrict __attr, | 
|---|
| 956 | int *__restrict __pshared) | 
|---|
| 957 | __THROW __nonnull ((1, 2)); | 
|---|
| 958 |  | 
|---|
| 959 | /* Set process-shared attribute of ATTR to PSHARED.  */ | 
|---|
| 960 | extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr, | 
|---|
| 961 | int __pshared) | 
|---|
| 962 | __THROW __nonnull ((1)); | 
|---|
| 963 |  | 
|---|
| 964 | /* Return current setting of reader/writer preference.  */ | 
|---|
| 965 | extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t * | 
|---|
| 966 | __restrict __attr, | 
|---|
| 967 | int *__restrict __pref) | 
|---|
| 968 | __THROW __nonnull ((1, 2)); | 
|---|
| 969 |  | 
|---|
| 970 | /* Set reader/write preference.  */ | 
|---|
| 971 | extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr, | 
|---|
| 972 | int __pref) __THROW __nonnull ((1)); | 
|---|
| 973 | #endif | 
|---|
| 974 |  | 
|---|
| 975 |  | 
|---|
| 976 | /* Functions for handling conditional variables.  */ | 
|---|
| 977 |  | 
|---|
| 978 | /* Initialize condition variable COND using attributes ATTR, or use | 
|---|
| 979 | the default values if later is NULL.  */ | 
|---|
| 980 | extern int pthread_cond_init (pthread_cond_t *__restrict __cond, | 
|---|
| 981 | const pthread_condattr_t *__restrict __cond_attr) | 
|---|
| 982 | __THROW __nonnull ((1)); | 
|---|
| 983 |  | 
|---|
| 984 | /* Destroy condition variable COND.  */ | 
|---|
| 985 | extern int pthread_cond_destroy (pthread_cond_t *__cond) | 
|---|
| 986 | __THROW __nonnull ((1)); | 
|---|
| 987 |  | 
|---|
| 988 | /* Wake up one thread waiting for condition variable COND.  */ | 
|---|
| 989 | extern int pthread_cond_signal (pthread_cond_t *__cond) | 
|---|
| 990 | __THROWNL __nonnull ((1)); | 
|---|
| 991 |  | 
|---|
| 992 | /* Wake up all threads waiting for condition variables COND.  */ | 
|---|
| 993 | extern int pthread_cond_broadcast (pthread_cond_t *__cond) | 
|---|
| 994 | __THROWNL __nonnull ((1)); | 
|---|
| 995 |  | 
|---|
| 996 | /* Wait for condition variable COND to be signaled or broadcast. | 
|---|
| 997 | MUTEX is assumed to be locked before. | 
|---|
| 998 |  | 
|---|
| 999 | This function is a cancellation point and therefore not marked with | 
|---|
| 1000 | __THROW.  */ | 
|---|
| 1001 | extern int pthread_cond_wait (pthread_cond_t *__restrict __cond, | 
|---|
| 1002 | pthread_mutex_t *__restrict __mutex) | 
|---|
| 1003 | __nonnull ((1, 2)); | 
|---|
| 1004 |  | 
|---|
| 1005 | /* Wait for condition variable COND to be signaled or broadcast until | 
|---|
| 1006 | ABSTIME.  MUTEX is assumed to be locked before.  ABSTIME is an | 
|---|
| 1007 | absolute time specification; zero is the beginning of the epoch | 
|---|
| 1008 | (00:00:00 GMT, January 1, 1970). | 
|---|
| 1009 |  | 
|---|
| 1010 | This function is a cancellation point and therefore not marked with | 
|---|
| 1011 | __THROW.  */ | 
|---|
| 1012 | extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond, | 
|---|
| 1013 | pthread_mutex_t *__restrict __mutex, | 
|---|
| 1014 | const struct timespec *__restrict __abstime) | 
|---|
| 1015 | __nonnull ((1, 2, 3)); | 
|---|
| 1016 |  | 
|---|
| 1017 | # ifdef __USE_GNU | 
|---|
| 1018 | /* Wait for condition variable COND to be signaled or broadcast until | 
|---|
| 1019 | ABSTIME measured by the specified clock. MUTEX is assumed to be | 
|---|
| 1020 | locked before. CLOCK is the clock to use. ABSTIME is an absolute | 
|---|
| 1021 | time specification against CLOCK's epoch. | 
|---|
| 1022 |  | 
|---|
| 1023 | This function is a cancellation point and therefore not marked with | 
|---|
| 1024 | __THROW. */ | 
|---|
| 1025 | extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond, | 
|---|
| 1026 | pthread_mutex_t *__restrict __mutex, | 
|---|
| 1027 | __clockid_t __clock_id, | 
|---|
| 1028 | const struct timespec *__restrict __abstime) | 
|---|
| 1029 | __nonnull ((1, 2, 4)); | 
|---|
| 1030 | # endif | 
|---|
| 1031 |  | 
|---|
| 1032 | /* Functions for handling condition variable attributes.  */ | 
|---|
| 1033 |  | 
|---|
| 1034 | /* Initialize condition variable attribute ATTR.  */ | 
|---|
| 1035 | extern int pthread_condattr_init (pthread_condattr_t *__attr) | 
|---|
| 1036 | __THROW __nonnull ((1)); | 
|---|
| 1037 |  | 
|---|
| 1038 | /* Destroy condition variable attribute ATTR.  */ | 
|---|
| 1039 | extern int pthread_condattr_destroy (pthread_condattr_t *__attr) | 
|---|
| 1040 | __THROW __nonnull ((1)); | 
|---|
| 1041 |  | 
|---|
| 1042 | /* Get the process-shared flag of the condition variable attribute ATTR.  */ | 
|---|
| 1043 | extern int pthread_condattr_getpshared (const pthread_condattr_t * | 
|---|
| 1044 | __restrict __attr, | 
|---|
| 1045 | int *__restrict __pshared) | 
|---|
| 1046 | __THROW __nonnull ((1, 2)); | 
|---|
| 1047 |  | 
|---|
| 1048 | /* Set the process-shared flag of the condition variable attribute ATTR.  */ | 
|---|
| 1049 | extern int pthread_condattr_setpshared (pthread_condattr_t *__attr, | 
|---|
| 1050 | int __pshared) __THROW __nonnull ((1)); | 
|---|
| 1051 |  | 
|---|
| 1052 | #ifdef __USE_XOPEN2K | 
|---|
| 1053 | /* Get the clock selected for the condition variable attribute ATTR.  */ | 
|---|
| 1054 | extern int pthread_condattr_getclock (const pthread_condattr_t * | 
|---|
| 1055 | __restrict __attr, | 
|---|
| 1056 | __clockid_t *__restrict __clock_id) | 
|---|
| 1057 | __THROW __nonnull ((1, 2)); | 
|---|
| 1058 |  | 
|---|
| 1059 | /* Set the clock selected for the condition variable attribute ATTR.  */ | 
|---|
| 1060 | extern int pthread_condattr_setclock (pthread_condattr_t *__attr, | 
|---|
| 1061 | __clockid_t __clock_id) | 
|---|
| 1062 | __THROW __nonnull ((1)); | 
|---|
| 1063 | #endif | 
|---|
| 1064 |  | 
|---|
| 1065 |  | 
|---|
| 1066 | #ifdef __USE_XOPEN2K | 
|---|
| 1067 | /* Functions to handle spinlocks.  */ | 
|---|
| 1068 |  | 
|---|
| 1069 | /* Initialize the spinlock LOCK.  If PSHARED is nonzero the spinlock can | 
|---|
| 1070 | be shared between different processes.  */ | 
|---|
| 1071 | extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared) | 
|---|
| 1072 | __THROW __nonnull ((1)); | 
|---|
| 1073 |  | 
|---|
| 1074 | /* Destroy the spinlock LOCK.  */ | 
|---|
| 1075 | extern int pthread_spin_destroy (pthread_spinlock_t *__lock) | 
|---|
| 1076 | __THROW __nonnull ((1)); | 
|---|
| 1077 |  | 
|---|
| 1078 | /* Wait until spinlock LOCK is retrieved.  */ | 
|---|
| 1079 | extern int pthread_spin_lock (pthread_spinlock_t *__lock) | 
|---|
| 1080 | __THROWNL __nonnull ((1)); | 
|---|
| 1081 |  | 
|---|
| 1082 | /* Try to lock spinlock LOCK.  */ | 
|---|
| 1083 | extern int pthread_spin_trylock (pthread_spinlock_t *__lock) | 
|---|
| 1084 | __THROWNL __nonnull ((1)); | 
|---|
| 1085 |  | 
|---|
| 1086 | /* Release spinlock LOCK.  */ | 
|---|
| 1087 | extern int pthread_spin_unlock (pthread_spinlock_t *__lock) | 
|---|
| 1088 | __THROWNL __nonnull ((1)); | 
|---|
| 1089 |  | 
|---|
| 1090 |  | 
|---|
| 1091 | /* Functions to handle barriers.  */ | 
|---|
| 1092 |  | 
|---|
| 1093 | /* Initialize BARRIER with the attributes in ATTR.  The barrier is | 
|---|
| 1094 | opened when COUNT waiters arrived.  */ | 
|---|
| 1095 | extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier, | 
|---|
| 1096 | const pthread_barrierattr_t *__restrict | 
|---|
| 1097 | __attr, unsigned int __count) | 
|---|
| 1098 | __THROW __nonnull ((1)); | 
|---|
| 1099 |  | 
|---|
| 1100 | /* Destroy a previously dynamically initialized barrier BARRIER.  */ | 
|---|
| 1101 | extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) | 
|---|
| 1102 | __THROW __nonnull ((1)); | 
|---|
| 1103 |  | 
|---|
| 1104 | /* Wait on barrier BARRIER.  */ | 
|---|
| 1105 | extern int pthread_barrier_wait (pthread_barrier_t *__barrier) | 
|---|
| 1106 | __THROWNL __nonnull ((1)); | 
|---|
| 1107 |  | 
|---|
| 1108 |  | 
|---|
| 1109 | /* Initialize barrier attribute ATTR.  */ | 
|---|
| 1110 | extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) | 
|---|
| 1111 | __THROW __nonnull ((1)); | 
|---|
| 1112 |  | 
|---|
| 1113 | /* Destroy previously dynamically initialized barrier attribute ATTR.  */ | 
|---|
| 1114 | extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) | 
|---|
| 1115 | __THROW __nonnull ((1)); | 
|---|
| 1116 |  | 
|---|
| 1117 | /* Get the process-shared flag of the barrier attribute ATTR.  */ | 
|---|
| 1118 | extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t * | 
|---|
| 1119 | __restrict __attr, | 
|---|
| 1120 | int *__restrict __pshared) | 
|---|
| 1121 | __THROW __nonnull ((1, 2)); | 
|---|
| 1122 |  | 
|---|
| 1123 | /* Set the process-shared flag of the barrier attribute ATTR.  */ | 
|---|
| 1124 | extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr, | 
|---|
| 1125 | int __pshared) | 
|---|
| 1126 | __THROW __nonnull ((1)); | 
|---|
| 1127 | #endif | 
|---|
| 1128 |  | 
|---|
| 1129 |  | 
|---|
| 1130 | /* Functions for handling thread-specific data.  */ | 
|---|
| 1131 |  | 
|---|
| 1132 | /* Create a key value identifying a location in the thread-specific | 
|---|
| 1133 | data area.  Each thread maintains a distinct thread-specific data | 
|---|
| 1134 | area.  DESTR_FUNCTION, if non-NULL, is called with the value | 
|---|
| 1135 | associated to that key when the key is destroyed. | 
|---|
| 1136 | DESTR_FUNCTION is not called if the value associated is NULL when | 
|---|
| 1137 | the key is destroyed.  */ | 
|---|
| 1138 | extern int pthread_key_create (pthread_key_t *__key, | 
|---|
| 1139 | void (*__destr_function) (void *)) | 
|---|
| 1140 | __THROW __nonnull ((1)); | 
|---|
| 1141 |  | 
|---|
| 1142 | /* Destroy KEY.  */ | 
|---|
| 1143 | extern int pthread_key_delete (pthread_key_t __key) __THROW; | 
|---|
| 1144 |  | 
|---|
| 1145 | /* Return current value of the thread-specific data slot identified by KEY.  */ | 
|---|
| 1146 | extern void *pthread_getspecific (pthread_key_t __key) __THROW; | 
|---|
| 1147 |  | 
|---|
| 1148 | /* Store POINTER in the thread-specific data slot identified by KEY. */ | 
|---|
| 1149 | extern int pthread_setspecific (pthread_key_t __key, | 
|---|
| 1150 | const void *__pointer) __THROW ; | 
|---|
| 1151 |  | 
|---|
| 1152 |  | 
|---|
| 1153 | #ifdef __USE_XOPEN2K | 
|---|
| 1154 | /* Get ID of CPU-time clock for thread THREAD_ID.  */ | 
|---|
| 1155 | extern int pthread_getcpuclockid (pthread_t __thread_id, | 
|---|
| 1156 | __clockid_t *__clock_id) | 
|---|
| 1157 | __THROW __nonnull ((2)); | 
|---|
| 1158 | #endif | 
|---|
| 1159 |  | 
|---|
| 1160 |  | 
|---|
| 1161 | /* Install handlers to be called when a new process is created with FORK. | 
|---|
| 1162 | The PREPARE handler is called in the parent process just before performing | 
|---|
| 1163 | FORK. The PARENT handler is called in the parent process just after FORK. | 
|---|
| 1164 | The CHILD handler is called in the child process.  Each of the three | 
|---|
| 1165 | handlers can be NULL, meaning that no handler needs to be called at that | 
|---|
| 1166 | point. | 
|---|
| 1167 | PTHREAD_ATFORK can be called several times, in which case the PREPARE | 
|---|
| 1168 | handlers are called in LIFO order (last added with PTHREAD_ATFORK, | 
|---|
| 1169 | first called before FORK), and the PARENT and CHILD handlers are called | 
|---|
| 1170 | in FIFO (first added, first called).  */ | 
|---|
| 1171 |  | 
|---|
| 1172 | extern int pthread_atfork (void (*__prepare) (void), | 
|---|
| 1173 | void (*__parent) (void), | 
|---|
| 1174 | void (*__child) (void)) __THROW; | 
|---|
| 1175 |  | 
|---|
| 1176 |  | 
|---|
| 1177 | #ifdef __USE_EXTERN_INLINES | 
|---|
| 1178 | /* Optimizations.  */ | 
|---|
| 1179 | __extern_inline int | 
|---|
| 1180 | __NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2)) | 
|---|
| 1181 | { | 
|---|
| 1182 | return __thread1 == __thread2; | 
|---|
| 1183 | } | 
|---|
| 1184 | #endif | 
|---|
| 1185 |  | 
|---|
| 1186 | __END_DECLS | 
|---|
| 1187 |  | 
|---|
| 1188 | #endif	/* pthread.h */ | 
|---|
| 1189 |  | 
|---|