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
24 #ifndef AFS_GLOBAL_SUNLOCK
25 #define AFS_ASSERT_RXGLOCK()
28 /* This is incomplete and probably wouldn't work with NCPUS > 1 */
30 typedef int afs_kcondvar_t;
32 #define CV_INIT(cv, a, b, c)
33 #define CV_DESTROY(cv)
34 #define CV_WAIT(cv, lck) { \
35 int isGlockOwner = ISAFS_GLOCK(); \
36 if (isGlockOwner) AFS_GUNLOCK(); \
38 tsleep(cv, PSOCK, "afs_rx_cv_wait", 0); \
39 if (isGlockOwner) AFS_GLOCK(); \
42 #define CV_SIGNAL(cv) wakeup_one(cv)
43 #define CV_BROADCAST(cv) wakeup(cv)
49 #define MUTEX_DEFAULT 0
51 #define MUTEX_INIT(a,b,c,d) \
55 #define MUTEX_DESTROY(a) \
57 (a)->owner = (struct proc *)-1; \
59 #define MUTEX_ENTER(a) \
61 osi_Assert((a)->owner == 0); \
62 (a)->owner = curproc; \
64 #define MUTEX_TRYENTER(a) \
65 ( osi_Assert((a)->owner == 0), (a)->owner = curproc, 1)
66 #define MUTEX_EXIT(a) \
68 osi_Assert((a)->owner == curproc); \
71 #define MUTEX_ISMINE(a) (((afs_kmutex_t *)(a))->owner == curproc)
73 #endif /* _RX_KMUTEX_H_ */