2009-03-04 04:28:35 +01:00
|
|
|
/* $OpenBSD: thread_private.h,v 1.18 2006/02/22 07:16:31 otto Exp $ */
|
|
|
|
|
|
|
|
/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
|
|
|
|
|
2018-07-10 23:39:49 +02:00
|
|
|
#pragma once
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
2014-06-21 07:49:20 +02:00
|
|
|
__BEGIN_DECLS
|
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
/*
|
|
|
|
* This file defines the thread library interface to libc. Thread
|
|
|
|
* libraries must implement the functions described here for proper
|
|
|
|
* inter-operation with libc. libc contains weak versions of the
|
|
|
|
* described functions for operation in a non-threaded environment.
|
|
|
|
*/
|
|
|
|
|
2018-07-10 23:39:49 +02:00
|
|
|
#define __MUTEX_NAME(name) __CONCAT(__libc_mutex_,name)
|
|
|
|
#define _THREAD_PRIVATE_MUTEX(name) static pthread_mutex_t __MUTEX_NAME(name) = PTHREAD_MUTEX_INITIALIZER
|
|
|
|
#define _THREAD_PRIVATE_MUTEX_LOCK(name) pthread_mutex_lock(&__MUTEX_NAME(name))
|
|
|
|
#define _THREAD_PRIVATE_MUTEX_UNLOCK(name) pthread_mutex_unlock(&__MUTEX_NAME(name))
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-07-11 21:59:16 +02:00
|
|
|
/* Note that these aren't compatible with the usual OpenBSD ones which lazy-initialize! */
|
|
|
|
#define _MUTEX_LOCK(l) pthread_mutex_lock((pthread_mutex_t*) l)
|
|
|
|
#define _MUTEX_UNLOCK(l) pthread_mutex_unlock((pthread_mutex_t*) l)
|
|
|
|
|
2014-06-21 07:49:20 +02:00
|
|
|
__LIBC_HIDDEN__ void _thread_arc4_lock(void);
|
|
|
|
__LIBC_HIDDEN__ void _thread_arc4_unlock(void);
|
|
|
|
|
2014-07-19 00:57:41 +02:00
|
|
|
#define _ARC4_LOCK() _thread_arc4_lock()
|
|
|
|
#define _ARC4_UNLOCK() _thread_arc4_unlock()
|
|
|
|
#define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f))
|
2014-06-21 07:49:20 +02:00
|
|
|
|
2016-06-25 01:18:21 +02:00
|
|
|
extern volatile sig_atomic_t _rs_forked;
|
|
|
|
|
2014-06-21 07:49:20 +02:00
|
|
|
__END_DECLS
|