summaryrefslogtreecommitdiff
path: root/kern/mutex/mutex_adaptive_i.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-07-30 20:55:20 +0200
committerRichard Braun <rbraun@sceen.net>2018-07-30 20:55:20 +0200
commit5f202c9f744a5d9c5b751038edd2379b3d244227 (patch)
treec5bce5b9e1d9c4b01dfed4ff941ad9944814b93c /kern/mutex/mutex_adaptive_i.h
parentd3e43f5bfda0bdad7a829a7ed8c1272a395b196b (diff)
Rework assertive functions
Instead of combining assertions and checking into single functions, rework those into pure checking functions usable with assert(). Those functions were introduced because of warnings about unused functions/variables caused by an earlier implementation of assert().
Diffstat (limited to 'kern/mutex/mutex_adaptive_i.h')
-rw-r--r--kern/mutex/mutex_adaptive_i.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/kern/mutex/mutex_adaptive_i.h b/kern/mutex/mutex_adaptive_i.h
index e29fdb43..e171c9f1 100644
--- a/kern/mutex/mutex_adaptive_i.h
+++ b/kern/mutex/mutex_adaptive_i.h
@@ -25,6 +25,7 @@
#include <assert.h>
#include <errno.h>
+#include <stdbool.h>
#include <stdint.h>
#include <kern/atomic.h>
@@ -48,7 +49,14 @@ mutex_adaptive_init(struct mutex *mutex)
mutex->owner = 0;
}
-#define mutex_adaptive_assert_locked(mutex) assert((mutex)->owner != 0)
+static inline bool
+mutex_adaptive_locked(const struct mutex *mutex)
+{
+ uintptr_t owner;
+
+ owner = atomic_load(&mutex->owner, ATOMIC_RELAXED);
+ return (owner != 0);
+}
static inline int
mutex_adaptive_lock_fast(struct mutex *mutex)
@@ -89,7 +97,7 @@ void mutex_adaptive_unlock_slow(struct mutex *mutex);
*/
#define mutex_impl_init mutex_adaptive_init
-#define mutex_impl_assert_locked mutex_adaptive_assert_locked
+#define mutex_impl_locked mutex_adaptive_locked
static inline int
mutex_impl_trylock(struct mutex *mutex)