ad092a211d8893541608aaa9f031efb6b87601bc
[openafs.git] / src / rx / UKERNEL / rx_kmutex.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * rx_kmutex.h - mutex and condition variable macros for kernel environment.
12  *
13  * User-space implementation.
14  */
15
16 #ifndef _RX_KMUTEX_H_
17 #define _RX_KMUTEX_H_
18
19 #define AFS_GLOBAL_RXLOCK_KERNEL
20 #define RX_ENABLE_LOCKS         1
21
22 #define afs_kmutex_t            usr_mutex_t
23 #define afs_krwlock_t           usr_mutex_t
24 #define afs_kcondvar_t          usr_cond_t
25 #define RWLOCK_INIT(a, b, c, d) usr_mutex_init(a)
26 #define RWLOCK_DESTROY(l)       usr_mutex_destroy(l)
27 #define RWLOCK_UPLOCK(l) 
28 #define RWLOCK_WRLOCK(l)        usr_mutex_lock(l)
29 #define RWLOCK_RDLOCK(l)        usr_mutex_lock(l)
30 #define RWLOCK_TRYWRLOCK(l)     usr_mutex_trylock(l)
31 #define RWLOCK_TRYRDLOCK(l)     usr_mutex_trylock(l)
32 #define RWLOCK_UNLOCK(l)        usr_mutex_unlock(l)
33 #define MUTEX_INIT(A,B,C,D)     usr_mutex_init(A)
34 #define MUTEX_ENTER(A)          usr_mutex_lock(A)
35 #define MUTEX_TRYENTER(A)       usr_mutex_trylock(A)
36 #define MUTEX_ISMINE(A)         (1)
37 #define MUTEX_EXIT(A)           usr_mutex_unlock(A)
38 #define MUTEX_DESTROY(A)        usr_mutex_destroy(A)
39 #define CV_INIT(A,B,C,D)        usr_cond_init(A)
40 #define CV_TIMEDWAIT(A,B,C)     usr_cond_timedwait(A,B,C)
41 #define CV_SIGNAL(A)            usr_cond_signal(A)
42 #define CV_BROADCAST(A)         usr_cond_broadcast(A)
43 #define CV_DESTROY(A)           usr_cond_destroy(A)
44 #define CV_WAIT(_cv, _lck)      { \
45                                     int isGlockOwner = ISAFS_GLOCK(); \
46                                     if (isGlockOwner) { \
47                                         AFS_GUNLOCK(); \
48                                     } \
49                                     usr_cond_wait(_cv, _lck); \
50                                     if (isGlockOwner) { \
51                                         MUTEX_EXIT(_lck); \
52                                         AFS_GLOCK(); \
53                                         MUTEX_ENTER(_lck); \
54                                     } \
55                                 }
56
57 #ifndef UKERNEL
58 extern void osirx_AssertMine(afs_kmutex_t * lockaddr, char *msg);
59 #endif
60
61 #define SPLVAR
62 #define NETPRI
63 #define USERPRI
64
65 #endif /* _RX_KMUTEX_H_ */