summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libthr/thread')
-rw-r--r--lib/libthr/thread/thr_private.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index 6725a43..653ae31 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -522,15 +522,22 @@ do { \
_thr_umtx_lock(lck, (thrd)->tid); \
} while (0)
-#define THR_LOCK_RELEASE(thrd, lck) \
+#ifdef _PTHREADS_INVARIANTS
+#define THR_ASSERT_LOCKLEVEL(thrd) \
do { \
- if ((thrd)->locklevel > 0) { \
- _thr_umtx_unlock((lck), (thrd)->tid); \
- (thrd)->locklevel--; \
- _thr_ast(thrd); \
- } else { \
+ if (__predict_false((thrd)->locklevel <= 0)) \
_thr_assert_lock_level(); \
- } \
+} while (0)
+#else
+#define THR_ASSERT_LOCKLEVEL(thrd)
+#endif
+
+#define THR_LOCK_RELEASE(thrd, lck) \
+do { \
+ THR_ASSERT_LOCKLEVEL(thrd); \
+ _thr_umtx_unlock((lck), (thrd)->tid); \
+ (thrd)->locklevel--; \
+ _thr_ast(thrd); \
} while (0)
#define THR_LOCK(curthrd) THR_LOCK_ACQUIRE(curthrd, &(curthrd)->lock)
OpenPOWER on IntegriCloud