Lines Matching defs:sx

46  * In general, the sx locks and rwlocks use very similar algorithms.
48 * blocked when a lock is unavailable. For this, sx locks use sleep
94 #define sx_init(sx, desc) sx_init_flags((sx), (desc), 0)
95 void sx_init_flags(struct sx *sx, const char *description, int opts);
96 void sx_destroy(struct sx *sx);
97 int sx_try_slock_(struct sx *sx, const char *file, int line);
98 int sx_try_xlock_(struct sx *sx, const char *file, int line);
99 int sx_try_upgrade_(struct sx *sx, const char *file, int line);
100 void sx_downgrade_(struct sx *sx, const char *file, int line);
101 int _sx_slock(struct sx *sx, int opts, const char *file, int line);
102 int _sx_xlock(struct sx *sx, int opts, const char *file, int line);
103 void _sx_sunlock(struct sx *sx, const char *file, int line);
104 void _sx_xunlock(struct sx *sx, const char *file, int line);
105 int _sx_xlock_hard(struct sx *sx, uintptr_t tid, int opts,
107 int _sx_slock_hard(struct sx *sx, int opts, const char *file, int line);
108 void _sx_xunlock_hard(struct sx *sx, uintptr_t tid, const char *file, int
110 void _sx_sunlock_hard(struct sx *sx, const char *file, int line);
112 void _sx_assert(const struct sx *sx, int what, const char *file, int line);
119 struct sx *sa_sx;
145 __sx_xlock(struct sx *sx, struct thread *td, int opts, const char *file,
151 if (!atomic_cmpset_acq_ptr(&sx->sx_lock, SX_LOCK_UNLOCKED, tid))
152 error = _sx_xlock_hard(sx, tid, opts, file, line);
155 sx, 0, 0, file, line);
162 __sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line)
166 if (!atomic_cmpset_rel_ptr(&sx->sx_lock, tid, SX_LOCK_UNLOCKED))
167 _sx_xunlock_hard(sx, tid, file, line);
172 __sx_slock(struct sx *sx, int opts, const char *file, int line)
174 uintptr_t x = sx->sx_lock;
178 !atomic_cmpset_acq_ptr(&sx->sx_lock, x, x + SX_ONE_SHARER))
179 error = _sx_slock_hard(sx, opts, file, line);
181 LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_SLOCK_ACQUIRE, sx, 0,
195 __sx_sunlock(struct sx *sx, const char *file, int line)
197 uintptr_t x = sx->sx_lock;
200 !atomic_cmpset_rel_ptr(&sx->sx_lock, x, x - SX_ONE_SHARER))
201 _sx_sunlock_hard(sx, file, line);
208 #error "LOCK_DEBUG not defined, include <sys/lock.h> before <sys/sx.h>"
211 #define sx_xlock_(sx, file, line) \
212 (void)_sx_xlock((sx), 0, (file), (line))
213 #define sx_xlock_sig_(sx, file, line) \
214 _sx_xlock((sx), SX_INTERRUPTIBLE, (file), (line))
215 #define sx_xunlock_(sx, file, line) \
216 _sx_xunlock((sx), (file), (line))
217 #define sx_slock_(sx, file, line) \
218 (void)_sx_slock((sx), 0, (file), (line))
219 #define sx_slock_sig_(sx, file, line) \
220 _sx_slock((sx), SX_INTERRUPTIBLE, (file) , (line))
221 #define sx_sunlock_(sx, file, line) \
222 _sx_sunlock((sx), (file), (line))
224 #define sx_xlock_(sx, file, line) \
225 (void)__sx_xlock((sx), curthread, 0, (file), (line))
226 #define sx_xlock_sig_(sx, file, line) \
227 __sx_xlock((sx), curthread, SX_INTERRUPTIBLE, (file), (line))
228 #define sx_xunlock_(sx, file, line) \
229 __sx_xunlock((sx), curthread, (file), (line))
230 #define sx_slock_(sx, file, line) \
231 (void)__sx_slock((sx), 0, (file), (line))
232 #define sx_slock_sig_(sx, file, line) \
233 __sx_slock((sx), SX_INTERRUPTIBLE, (file), (line))
234 #define sx_sunlock_(sx, file, line) \
235 __sx_sunlock((sx), (file), (line))
237 #define sx_try_slock(sx) sx_try_slock_((sx), LOCK_FILE, LOCK_LINE)
238 #define sx_try_xlock(sx) sx_try_xlock_((sx), LOCK_FILE, LOCK_LINE)
239 #define sx_try_upgrade(sx) sx_try_upgrade_((sx), LOCK_FILE, LOCK_LINE)
240 #define sx_downgrade(sx) sx_downgrade_((sx), LOCK_FILE, LOCK_LINE)
242 #define sx_assert_(sx, what, file, line) \
243 _sx_assert((sx), (what), (file), (line))
245 #define sx_assert_(sx, what, file, line) (void)0
248 #define sx_xlock(sx) sx_xlock_((sx), LOCK_FILE, LOCK_LINE)
249 #define sx_xlock_sig(sx) sx_xlock_sig_((sx), LOCK_FILE, LOCK_LINE)
250 #define sx_xunlock(sx) sx_xunlock_((sx), LOCK_FILE, LOCK_LINE)
251 #define sx_slock(sx) sx_slock_((sx), LOCK_FILE, LOCK_LINE)
252 #define sx_slock_sig(sx) sx_slock_sig_((sx), LOCK_FILE, LOCK_LINE)
253 #define sx_sunlock(sx) sx_sunlock_((sx), LOCK_FILE, LOCK_LINE)
254 #define sx_assert(sx, what) sx_assert_((sx), (what), __FILE__, __LINE__)
260 #define sx_xholder(sx) \
261 ((sx)->sx_lock & SX_LOCK_SHARED ? NULL : \
262 (struct thread *)SX_OWNER((sx)->sx_lock))
264 #define sx_xlocked(sx) \
265 (((sx)->sx_lock & ~(SX_LOCK_FLAGMASK & ~SX_LOCK_SHARED)) == \
268 #define sx_unlock_(sx, file, line) do { \
269 if (sx_xlocked(sx)) \
270 sx_xunlock_(sx, file, line); \
272 sx_sunlock_(sx, file, line); \
275 #define sx_unlock(sx) sx_unlock_((sx), LOCK_FILE, LOCK_LINE)
277 #define sx_sleep(chan, sx, pri, wmesg, timo) \
278 _sleep((chan), &(sx)->lock_object, (pri), (wmesg), \