[Midnightbsd-cvs] src: sx.h: Add a new macro, sx_xlocked(), that returns true if the
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Apr 20 12:55:46 EDT 2008
Log Message:
-----------
Add a new macro, sx_xlocked(), that returns true if the current thread holds an exclusive lock on the specified sx lock.
Tags:
----
RELENG_0_1
Modified Files:
--------------
src/sys/sys:
sx.h (r1.1.1.1 -> r1.1.1.1.2.1)
-------------- next part --------------
Index: sx.h
===================================================================
RCS file: /home/cvs/src/sys/sys/sx.h,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.1
diff -L sys/sys/sx.h -L sys/sys/sx.h -u -r1.1.1.1 -r1.1.1.1.2.1
--- sys/sys/sx.h
+++ sys/sys/sx.h
@@ -76,6 +76,7 @@
SYSUNINIT(name##_sx_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
sx_destroy, (sxa))
+#define sx_xlocked(sx) ((sx)->sx_cnt < 0 && (sx)->sx_xholder == curthread)
#define sx_slock(sx) _sx_slock((sx), LOCK_FILE, LOCK_LINE)
#define sx_xlock(sx) _sx_xlock((sx), LOCK_FILE, LOCK_LINE)
#define sx_try_slock(sx) _sx_try_slock((sx), LOCK_FILE, LOCK_LINE)
@@ -84,13 +85,12 @@
#define sx_xunlock(sx) _sx_xunlock((sx), LOCK_FILE, LOCK_LINE)
#define sx_try_upgrade(sx) _sx_try_upgrade((sx), LOCK_FILE, LOCK_LINE)
#define sx_downgrade(sx) _sx_downgrade((sx), LOCK_FILE, LOCK_LINE)
-#define sx_unlock(sx) \
- do { \
- if ((sx)->sx_cnt < 0) \
- sx_xunlock(sx); \
- else \
- sx_sunlock(sx); \
- } while (0)
+#define sx_unlock(sx) do { \
+ if (sx_xlocked(sx)) \
+ sx_xunlock(sx); \
+ else \
+ sx_sunlock(sx); \
+} while (0)
#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
#define SX_LOCKED LA_LOCKED
More information about the Midnightbsd-cvs
mailing list