Home | History | Annotate | Download | only in private
      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 (at) snafu.org> */
      4 
      5 #pragma once
      6 
      7 #include <pthread.h>
      8 
      9 __BEGIN_DECLS
     10 
     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 
     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))
     22 
     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 
     27 __LIBC_HIDDEN__ void    _thread_arc4_lock(void);
     28 __LIBC_HIDDEN__ void    _thread_arc4_unlock(void);
     29 
     30 #define _ARC4_LOCK() _thread_arc4_lock()
     31 #define _ARC4_UNLOCK() _thread_arc4_unlock()
     32 #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f))
     33 
     34 extern volatile sig_atomic_t _rs_forked;
     35 
     36 __END_DECLS
     37