2 * Copyright (c) 1997,98 The NetBSD Foundation, Inc.
5 * This code is derived from software contributed to The NetBSD Foundation
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
32 * This file was derived from a copy in FreeBSD CVS on August 26, 2010.
33 * FreeBSD/NetBSD have slightly different definitions for some/most of
34 * these functions and types, so they should just use the ones found
35 * in their system copy of reentrant.h.
36 * These definitions are only guaranteed to be valid on Linux.
39 #if defined(__linux__)
43 #define mutex_t pthread_mutex_t
44 #define cond_t pthread_cond_t
45 #define rwlock_t pthread_rwlock_t
46 #define once_t pthread_once_t
48 #define thread_key_t pthread_key_t
50 #define KEY_INITIALIZER ((thread_key_t)-1)
51 #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
52 #define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER
53 #define ONCE_INITIALIZER PTHREAD_ONCE_INIT
55 #define mutex_init(m, a) pthread_mutex_init(m, a)
56 #define mutex_lock(m) pthread_mutex_lock(m)
57 #define mutex_unlock(m) pthread_mutex_unlock(m)
59 #define cond_init(c, a, p) pthread_cond_init(c, a)
60 #define cond_signal(m) pthread_cond_signal(m)
61 #define cond_broadcast(m) pthread_cond_broadcast(m)
62 #define cond_wait(c, m) pthread_cond_wait(c, m)
64 #define rwlock_init(l, a) pthread_rwlock_init(l, a)
65 #define rwlock_rdlock(l) pthread_rwlock_rdlock(l)
66 #define rwlock_wrlock(l) pthread_rwlock_wrlock(l)
67 #define rwlock_unlock(l) pthread_rwlock_unlock(l)
69 #define thr_keycreate(k, d) pthread_key_create(k, d)
70 #define thr_setspecific(k, p) pthread_setspecific(k, p)
71 #define thr_getspecific(k) pthread_getspecific(k)
72 #define thr_sigsetmask(f, n, o) pthread_sigmask(f, n, o)
74 #define thr_once(o, i) pthread_once(o, i)
75 #define thr_self() pthread_self()
76 #define thr_exit(x) pthread_exit(x)