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 | |
Elliott Hughes | 468efc8 | 2018-07-10 14:39:49 -0700 | [diff] [blame] | 5 | #pragma once |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 6 | |
| 7 | #include <pthread.h> |
| 8 | |
Elliott Hughes | 0468feb | 2014-06-20 22:49:20 -0700 | [diff] [blame] | 9 | __BEGIN_DECLS |
| 10 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 11 | /* |
| 12 | * This file defines the thread library interface to libc. Thread |
| 13 | * libraries must implement the functions described here for proper |
| 14 | * inter-operation with libc. libc contains weak versions of the |
| 15 | * described functions for operation in a non-threaded environment. |
| 16 | */ |
| 17 | |
Elliott Hughes | 468efc8 | 2018-07-10 14:39:49 -0700 | [diff] [blame] | 18 | #define __MUTEX_NAME(name) __CONCAT(__libc_mutex_,name) |
| 19 | #define _THREAD_PRIVATE_MUTEX(name) static pthread_mutex_t __MUTEX_NAME(name) = PTHREAD_MUTEX_INITIALIZER |
| 20 | #define _THREAD_PRIVATE_MUTEX_LOCK(name) pthread_mutex_lock(&__MUTEX_NAME(name)) |
| 21 | #define _THREAD_PRIVATE_MUTEX_UNLOCK(name) pthread_mutex_unlock(&__MUTEX_NAME(name)) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 22 | |
Dmitriy Ivanov | 53c3c27 | 2014-07-11 12:59:16 -0700 | [diff] [blame] | 23 | /* Note that these aren't compatible with the usual OpenBSD ones which lazy-initialize! */ |
| 24 | #define _MUTEX_LOCK(l) pthread_mutex_lock((pthread_mutex_t*) l) |
| 25 | #define _MUTEX_UNLOCK(l) pthread_mutex_unlock((pthread_mutex_t*) l) |
| 26 | |
Elliott Hughes | 0468feb | 2014-06-20 22:49:20 -0700 | [diff] [blame] | 27 | __LIBC_HIDDEN__ void _thread_arc4_lock(void); |
| 28 | __LIBC_HIDDEN__ void _thread_arc4_unlock(void); |
| 29 | |
Elliott Hughes | 2b67d7d | 2014-07-18 15:57:41 -0700 | [diff] [blame] | 30 | #define _ARC4_LOCK() _thread_arc4_lock() |
| 31 | #define _ARC4_UNLOCK() _thread_arc4_unlock() |
Elliott Hughes | 0468feb | 2014-06-20 22:49:20 -0700 | [diff] [blame] | 32 | |
Josh Gao | c80ffec | 2016-06-24 16:18:21 -0700 | [diff] [blame] | 33 | extern volatile sig_atomic_t _rs_forked; |
| 34 | |
Elliott Hughes | 0468feb | 2014-06-20 22:49:20 -0700 | [diff] [blame] | 35 | __END_DECLS |