2 * Copyright 2000, International Business Machines Corporation and others.
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
11 * rx_kmutex.h - mutex and condition variable macros for kernel environment.
13 * OpenBSD implementation by Jim Rees.
21 /* You can't have AFS_GLOBAL_SUNLOCK and not RX_ENABLE_LOCKS */
22 #define RX_ENABLE_LOCKS 1
23 #define AFS_GLOBAL_RXLOCK_KERNEL
25 /* This is incomplete and probably wouldn't work with NCPUS > 1 */
27 typedef int afs_kcondvar_t;
29 #define CV_INIT(cv, a, b, c)
30 #define CV_DESTROY(cv)
31 #define CV_WAIT(cv, lck) { \
32 int isGlockOwner = ISAFS_GLOCK(); \
33 if (isGlockOwner) AFS_GUNLOCK(); \
35 tsleep(cv, PSOCK, "afs_rx_cv_wait", 0); \
36 if (isGlockOwner) AFS_GLOCK(); \
39 #define CV_SIGNAL(cv) wakeup_one(cv)
40 #define CV_BROADCAST(cv) wakeup(cv)
46 #define MUTEX_DEFAULT 0
48 #define MUTEX_INIT(a,b,c,d) \
52 #define MUTEX_DESTROY(a) \
54 (a)->owner = (struct proc *)-1; \
56 #define MUTEX_ENTER(a) \
58 osi_Assert((a)->owner == 0); \
59 (a)->owner = curproc; \
61 #define MUTEX_TRYENTER(a) \
62 ( osi_Assert((a)->owner == 0), (a)->owner = curproc, 1)
63 #define MUTEX_EXIT(a) \
65 osi_Assert((a)->owner == curproc); \
68 #define MUTEX_ISMINE(a) (((afs_kmutex_t *)(a))->owner == curproc)
70 #endif /* _RX_KMUTEX_H_ */