The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /* $OpenBSD: thread_private.h,v 1.18 2006/02/22 07:16:31 otto Exp $ */ |
| 2 | |
| 3 | /* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */ |
| 4 | |
| 5 | #ifndef _THREAD_PRIVATE_H_ |
| 6 | #define _THREAD_PRIVATE_H_ |
| 7 | |
| 8 | #include <pthread.h> |
| 9 | |
| 10 | /* |
| 11 | * This file defines the thread library interface to libc. Thread |
| 12 | * libraries must implement the functions described here for proper |
| 13 | * inter-operation with libc. libc contains weak versions of the |
| 14 | * described functions for operation in a non-threaded environment. |
| 15 | */ |
| 16 | |
| 17 | /* |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 18 | * helper macro to make unique names in the thread namespace |
| 19 | */ |
| 20 | #define __THREAD_NAME(name) __CONCAT(_thread_tagname_,name) |
| 21 | |
| 22 | struct __thread_private_tag_t { |
| 23 | pthread_mutex_t _private_lock; |
| 24 | pthread_key_t _private_key; |
| 25 | }; |
| 26 | |
| 27 | #define _THREAD_PRIVATE_MUTEX(name) \ |
| 28 | static struct __thread_private_tag_t __THREAD_NAME(name) = { PTHREAD_MUTEX_INITIALIZER, -1 } |
| 29 | #define _THREAD_PRIVATE_MUTEX_LOCK(name) \ |
| 30 | pthread_mutex_lock( &__THREAD_NAME(name)._private_lock ) |
| 31 | #define _THREAD_PRIVATE_MUTEX_UNLOCK(name) \ |
| 32 | pthread_mutex_unlock( &__THREAD_NAME(name)._private_lock ) |
| 33 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 34 | void _thread_atexit_lock(void); |
| 35 | void _thread_atexit_unlock(void); |
| 36 | |
Elliott Hughes | f2cea02 | 2014-03-13 14:54:53 -0700 | [diff] [blame^] | 37 | #define _ATEXIT_LOCK() _thread_atexit_lock() |
| 38 | #define _ATEXIT_UNLOCK() _thread_atexit_unlock() |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 39 | |
| 40 | #endif /* _THREAD_PRIVATE_H_ */ |