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