summaryrefslogtreecommitdiff
path: root/kern/rtmutex.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/rtmutex.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/rtmutex.h')
-rw-r--r--kern/rtmutex.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/kern/rtmutex.h b/kern/rtmutex.h
index 64c09241..99b8ca74 100644
--- a/kern/rtmutex.h
+++ b/kern/rtmutex.h
@@ -26,8 +26,10 @@
#include <assert.h>
#include <errno.h>
+#include <stdbool.h>
#include <stdint.h>
+#include <kern/atomic.h>
#include <kern/init.h>
#include <kern/macros.h>
#include <kern/rtmutex_i.h>
@@ -35,7 +37,14 @@
struct rtmutex;
-#define rtmutex_assert_locked(rtmutex) assert((rtmutex)->owner != 0)
+static inline bool
+rtmutex_locked(const struct rtmutex *rtmutex)
+{
+ uintptr_t owner;
+
+ owner = atomic_load(&rtmutex->owner, ATOMIC_RELAXED);
+ return (owner != 0);
+}
/*
* Initialize a real-time mutex.