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 * IRIX implementation.
22 #define RX_ENABLE_LOCKS 1
26 #ifndef mutex_tryenter
27 #define mutex_tryenter(m) cpsema(m)
28 #endif /* mutex_tryenter */
29 typedef kmutex_t afs_kmutex_t
;
30 typedef kcondvar_t afs_kcondvar_t
;
36 #define MUTEX_DEFAULT 0
40 #define MUTEX_INIT(m, nm, type , a) mutex_init(m, type, nm)
42 #define MUTEX_INIT(a,b,c,d) mutex_init(a,b,c,d)
44 #define MUTEX_DESTROY(a) mutex_destroy(a)
45 #define MUTEX_ASSERT(a)
46 #define CV_INIT(cv, a,b,c) cv_init(cv, a, b, c)
47 #define CV_SIGNAL(_cv) cv_signal(_cv)
48 #define CV_BROADCAST(_cv) cv_broadcast(_cv)
49 #define CV_DESTROY(_cv) cv_destroy(_cv)
51 /* Add PLTWAIT for afsd's to wait so we don't rack up the load average. */
53 #define AFSD_PRI() ((kt_basepri(curthreadp) == PTIME_SHARE) ? PZERO : (PZERO|PLTWAIT))
55 #define AFSD_PRI() ((curprocp && curprocp->p_rss==0) ? (PZERO|PLTWAIT) : PZERO)
58 #define cv_wait(cv, mp) { \
59 sv_wait(cv, AFSD_PRI(), mp, 0); \
60 AFS_MUTEX_ENTER(mp); \
62 #endif /* AFS_SGI64_ENV */
64 #define MUTEX_ENTER(a) do { \
66 rxdb_grablock((a), osi_ThreadUnique(), \
67 rxdb_fileID, __LINE__); \
69 #define MUTEX_TRYENTER(a) (mutex_tryenter(a) ? \
70 (rxdb_grablock((a), osi_ThreadUnique(), \
71 rxdb_fileID, __LINE__), 1) \
73 #define MUTEX_EXIT(a) do { \
74 rxdb_droplock((a), osi_ThreadUnique(), \
75 rxdb_fileID, __LINE__); \
78 #define CV_WAIT(_cv, _lck) do { \
79 int haveGlock = ISAFS_GLOCK(); \
82 rxdb_droplock((_lck), \
84 rxdb_fileID, __LINE__); \
86 rxdb_grablock((_lck), \
88 rxdb_fileID, __LINE__); \
95 #define CV_TIMEDWAIT(_cv,_lck,_t) do { \
96 int haveGlock = ISAFS_GLOCK(); \
99 rxdb_droplock((_lck), \
100 osi_ThreadUnique(), \
101 rxdb_fileID, __LINE__); \
102 cv_timedwait(_cv, _lck, t); \
103 rxdb_grablock((_lck), \
104 osi_ThreadUnique(), \
105 rxdb_fileID, __LINE__); \
112 #else /* RX_LOCKS_DB */
113 #define MUTEX_ENTER(a) AFS_MUTEX_ENTER(a)
114 #define MUTEX_TRYENTER(a) mutex_tryenter(a)
115 #define MUTEX_EXIT(a) mutex_exit(a)
116 #define CV_WAIT(_cv, _lck) do { \
117 int haveGlock = ISAFS_GLOCK(); \
120 cv_wait(_cv, _lck); \
127 #define CV_TIMEDWAIT(cv,lck,t) do { \
128 int haveGlock = ISAFS_GLOCK(); \
131 cv_timedwait(_cv, _lck, t); \
138 #endif /* RX_LOCKS_DB */
142 #define MUTEX_INIT(m, nm, type , a)
143 #define MUTEX_DESTROY(a)
144 #define MUTEX_ASSERT(a)
145 #define MUTEX_ENTER(a)
146 #define MUTEX_TRYENTER(a) 1
147 #define MUTEX_EXIT(a)
149 #define CV_INIT(cv, a,b,c)
150 #define CV_SIGNAL(_cv)
151 #define CV_BROADCAST(_cv)
152 #define CV_DESTROY(_cv)
153 #define CV_WAIT(_cv, _lck)
154 #define CV_TIMEDWAIT(cv,lck,t)
160 #endif /* _RX_KMUTEX_H_ */