Rev 4874 | Rev 6099 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4874 | Rev 4921 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* pthread.h |
1 | /* pthread.h |
2 | * |
2 | * |
3 | * Written by Joel Sherrill |
3 | * Written by Joel Sherrill |
4 | * |
4 | * |
5 | * COPYRIGHT (c) 1989-2010. |
5 | * COPYRIGHT (c) 1989-2013. |
6 | * On-Line Applications Research Corporation (OAR). |
6 | * On-Line Applications Research Corporation (OAR). |
7 | * |
7 | * |
8 | * Permission to use, copy, modify, and distribute this software for any |
8 | * Permission to use, copy, modify, and distribute this software for any |
9 | * purpose without fee is hereby granted, provided that this entire notice |
9 | * purpose without fee is hereby granted, provided that this entire notice |
10 | * is included in all copies of any software which is or includes a copy |
10 | * is included in all copies of any software which is or includes a copy |
Line 13... | Line 13... | ||
13 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
13 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
14 | * WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION |
14 | * WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION |
15 | * OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS |
15 | * OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS |
16 | * SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
16 | * SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
17 | * |
17 | * |
18 | * $Id: pthread.h,v 1.9 2010/12/08 14:44:06 corinna Exp $ |
18 | * $Id: pthread.h,v 1.12 2013/11/29 23:35:34 joel Exp $ |
19 | */ |
19 | */ |
Line 20... | Line 20... | ||
20 | 20 | ||
21 | #ifndef __PTHREAD_h |
21 | #ifndef __PTHREAD_h |
Line 30... | Line 30... | ||
30 | #if defined(_POSIX_THREADS) |
30 | #if defined(_POSIX_THREADS) |
Line 31... | Line 31... | ||
31 | 31 | ||
32 | #include |
32 | #include |
33 | #include |
33 | #include |
- | 34 | #include |
|
- | 35 | #include |
|
- | 36 | ||
- | 37 | struct _pthread_cleanup_context { |
|
- | 38 | void (*_routine)(void *); |
|
- | 39 | void *_arg; |
|
- | 40 | int _canceltype; |
|
- | 41 | struct _pthread_cleanup_context *_previous; |
|
Line 34... | Line 42... | ||
34 | #include |
42 | }; |
35 | 43 | ||
36 | /* Register Fork Handlers */ |
44 | /* Register Fork Handlers */ |
Line 102... | Line 110... | ||
102 | /* This is used to statically initialize a pthread_cond_t. Example: |
110 | /* This is used to statically initialize a pthread_cond_t. Example: |
Line 103... | Line 111... | ||
103 | 111 | ||
104 | pthread_cond_t cond = PTHREAD_COND_INITIALIZER; |
112 | pthread_cond_t cond = PTHREAD_COND_INITIALIZER; |
Line 105... | Line 113... | ||
105 | */ |
113 | */ |
Line 106... | Line 114... | ||
106 | 114 | ||
Line 107... | Line 115... | ||
107 | #define PTHREAD_COND_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF) |
115 | #define PTHREAD_COND_INITIALIZER ((pthread_cond_t) 0xFFFFFFFF) |
108 | 116 | ||
Line 204... | Line 212... | ||
204 | int _EXFUN(pthread_attr_getguardsize, |
212 | int _EXFUN(pthread_attr_getguardsize, |
205 | (_CONST pthread_attr_t *__attr, size_t *__guardsize)); |
213 | (_CONST pthread_attr_t *__attr, size_t *__guardsize)); |
206 | int _EXFUN(pthread_attr_setguardsize, |
214 | int _EXFUN(pthread_attr_setguardsize, |
207 | (pthread_attr_t *__attr, size_t __guardsize)); |
215 | (pthread_attr_t *__attr, size_t __guardsize)); |
Line -... | Line 216... | ||
- | 216 | ||
- | 217 | /* POSIX thread APIs beyond the POSIX standard but provided |
|
- | 218 | * in GNU/Linux. They may be provided by other OSes for |
|
- | 219 | * compatibility. |
|
- | 220 | */ |
|
- | 221 | #if defined(__GNU_VISIBLE) |
|
- | 222 | #if defined(__rtems__) |
|
- | 223 | int _EXFUN(pthread_attr_setaffinity_np, |
|
- | 224 | (pthread_attr_t *__attr, size_t __cpusetsize, |
|
- | 225 | const cpu_set_t *__cpuset)); |
|
- | 226 | int _EXFUN(pthread_attr_getaffinity_np, |
|
- | 227 | (const pthread_attr_t *__attr, size_t __cpusetsize, |
|
- | 228 | cpu_set_t *__cpuset)); |
|
- | 229 | ||
- | 230 | int _EXFUN(pthread_setaffinity_np, |
|
- | 231 | (pthread_t __id, size_t __cpusetsize, const cpu_set_t *__cpuset)); |
|
- | 232 | int _EXFUN(pthread_getaffinity_np, |
|
- | 233 | (const pthread_t __id, size_t __cpusetsize, cpu_set_t *__cpuset)); |
|
- | 234 | ||
- | 235 | int _EXFUN(pthread_getattr_np, |
|
- | 236 | (pthread_t __id, pthread_attr_t *__attr)); |
|
- | 237 | #endif /* defined(__rtems__) */ |
|
- | 238 | #endif /* defined(__GNU_VISIBLE) */ |
|
208 | 239 | ||
Line 209... | Line 240... | ||
209 | /* Thread Creation, P1003.1c/Draft 10, p. 144 */ |
240 | /* Thread Creation, P1003.1c/Draft 10, p. 144 */ |
210 | 241 | ||
211 | int _EXFUN(pthread_create, |
242 | int _EXFUN(pthread_create, |
Line 278... | Line 309... | ||
278 | int _EXFUN(pthread_setcanceltype, (int __type, int *__oldtype)); |
309 | int _EXFUN(pthread_setcanceltype, (int __type, int *__oldtype)); |
279 | void _EXFUN(pthread_testcancel, (void)); |
310 | void _EXFUN(pthread_testcancel, (void)); |
Line 280... | Line 311... | ||
280 | 311 | ||
Line 281... | Line 312... | ||
281 | /* Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184 */ |
312 | /* Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184 */ |
- | 313 | ||
- | 314 | void _EXFUN(_pthread_cleanup_push, |
|
- | 315 | (struct _pthread_cleanup_context *_context, |
|
- | 316 | void (*_routine)(void *), void *_arg)); |
|
- | 317 | ||
- | 318 | void _EXFUN(_pthread_cleanup_pop, |
|
- | 319 | (struct _pthread_cleanup_context *_context, |
|
- | 320 | int _execute)); |
|
- | 321 | ||
- | 322 | /* It is intentional to open and close the scope in two different macros */ |
|
- | 323 | #define pthread_cleanup_push(_routine, _arg) \ |
|
- | 324 | do { \ |
|
- | 325 | struct _pthread_cleanup_context _pthread_clup_ctx; \ |
|
- | 326 | _pthread_cleanup_push(&_pthread_clup_ctx, (_routine), (_arg)) |
|
- | 327 | ||
- | 328 | #define pthread_cleanup_pop(_execute) \ |
|
- | 329 | _pthread_cleanup_pop(&_pthread_clup_ctx, (_execute)); \ |
|
- | 330 | } while (0) |
|
- | 331 | ||
- | 332 | #if defined(_GNU_SOURCE) |
|
282 | 333 | void _EXFUN(_pthread_cleanup_push_defer, |
|
- | 334 | (struct _pthread_cleanup_context *_context, |
|
283 | void _EXFUN(pthread_cleanup_push, |
335 | void (*_routine)(void *), void *_arg)); |
- | 336 | ||
- | 337 | void _EXFUN(_pthread_cleanup_pop_restore, |
|
- | 338 | (struct _pthread_cleanup_context *_context, |
|
- | 339 | int _execute)); |
|
- | 340 | ||
- | 341 | /* It is intentional to open and close the scope in two different macros */ |
|
- | 342 | #define pthread_cleanup_push_defer_np(_routine, _arg) \ |
|
- | 343 | do { \ |
|
- | 344 | struct _pthread_cleanup_context _pthread_clup_ctx; \ |
|
- | 345 | _pthread_cleanup_push_defer(&_pthread_clup_ctx, (_routine), (_arg)) |
|
- | 346 | ||
- | 347 | #define pthread_cleanup_pop_restore_np(_execute) \ |
|
- | 348 | _pthread_cleanup_pop_restore(&_pthread_clup_ctx, (_execute)); \ |
|
Line 284... | Line 349... | ||
284 | (void (*__routine)( void * ), void *__arg)); |
349 | } while (0) |
Line 285... | Line 350... | ||
285 | void _EXFUN(pthread_cleanup_pop, (int __execute)); |
350 | #endif /* defined(_GNU_SOURCE) */ |
Line 326... | Line 391... | ||
326 | 391 | ||
Line 327... | Line 392... | ||
327 | #endif /* defined(_POSIX_SPIN_LOCKS) */ |
392 | #endif /* defined(_POSIX_SPIN_LOCKS) */ |
Line -... | Line 393... | ||
- | 393 | ||
- | 394 | #if defined(_POSIX_READER_WRITER_LOCKS) |
|
- | 395 | ||
- | 396 | /* This is used to statically initialize a pthread_rwlock_t. Example: |
|
- | 397 | ||
- | 398 | pthread_mutex_t mutex = PTHREAD_RWLOCK_INITIALIZER; |
|
- | 399 | */ |
|
328 | 400 | ||
329 | #if defined(_POSIX_READER_WRITER_LOCKS) |
401 | #define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) 0xFFFFFFFF) |
330 | 402 | ||
331 | int _EXFUN(pthread_rwlockattr_init, (pthread_rwlockattr_t *__attr)); |
403 | int _EXFUN(pthread_rwlockattr_init, (pthread_rwlockattr_t *__attr)); |
332 | int _EXFUN(pthread_rwlockattr_destroy, (pthread_rwlockattr_t *__attr)); |
404 | int _EXFUN(pthread_rwlockattr_destroy, (pthread_rwlockattr_t *__attr)); |