blob: 1a13690eed7a056fb796e28bcadcbf57aff6bc99 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/* $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 Hughes468efc82018-07-10 14:39:49 -07005#pragma once
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08006
7#include <pthread.h>
8
Elliott Hughes0468feb2014-06-20 22:49:20 -07009__BEGIN_DECLS
10
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080011/*
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 Hughes468efc82018-07-10 14:39:49 -070018#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 Project1dc9e472009-03-03 19:28:35 -080022
Dmitriy Ivanov53c3c272014-07-11 12:59:16 -070023/* 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 Hughes0468feb2014-06-20 22:49:20 -070027__LIBC_HIDDEN__ void _thread_arc4_lock(void);
28__LIBC_HIDDEN__ void _thread_arc4_unlock(void);
29
Elliott Hughes2b67d7d2014-07-18 15:57:41 -070030#define _ARC4_LOCK() _thread_arc4_lock()
31#define _ARC4_UNLOCK() _thread_arc4_unlock()
Elliott Hughes0468feb2014-06-20 22:49:20 -070032
Josh Gaoc80ffec2016-06-24 16:18:21 -070033extern volatile sig_atomic_t _rs_forked;
34
Elliott Hughes0468feb2014-06-20 22:49:20 -070035__END_DECLS