diff options
author | Richard Braun <rbraun@sceen.net> | 2017-09-01 23:58:41 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-09-02 15:25:37 +0200 |
commit | d18d0e85596f90e0bd597b33d58209d0b3973c95 (patch) | |
tree | 6c3472f59cf64244ab86d2fc13b220b1c8f61165 /kern/spinlock.h | |
parent | 897ad6a062ea2a32a2759613608faf3271211832 (diff) |
Make assert have no side effects
This makes sure symbols referenced by assert uses may not be generated
if unused. The recently introduced __unused macro is used to suppress
compiler warnings resulting from this change.
Diffstat (limited to 'kern/spinlock.h')
-rw-r--r-- | kern/spinlock.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kern/spinlock.h b/kern/spinlock.h index d4105da0..50ac5401 100644 --- a/kern/spinlock.h +++ b/kern/spinlock.h @@ -26,6 +26,8 @@ #ifndef _KERN_SPINLOCK_H #define _KERN_SPINLOCK_H +#include <stdbool.h> + #include <kern/init.h> #include <kern/macros.h> #include <kern/spinlock_i.h> @@ -35,13 +37,17 @@ struct spinlock; -#define spinlock_assert_locked(lock) assert((lock)->value != SPINLOCK_UNLOCKED) - /* * Initialize a spin lock. */ void spinlock_init(struct spinlock *lock); +static inline bool +spinlock_locked(const struct spinlock *lock) +{ + return lock->value != SPINLOCK_UNLOCKED; +} + /* * Attempt to lock the given spin lock. * |