diff options
author | Richard Braun <rbraun@sceen.net> | 2018-07-30 20:55:20 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2018-07-30 20:55:20 +0200 |
commit | 5f202c9f744a5d9c5b751038edd2379b3d244227 (patch) | |
tree | c5bce5b9e1d9c4b01dfed4ff941ad9944814b93c /kern/rtmutex_i.h | |
parent | d3e43f5bfda0bdad7a829a7ed8c1272a395b196b (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_i.h')
-rw-r--r-- | kern/rtmutex_i.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/kern/rtmutex_i.h b/kern/rtmutex_i.h index 373c180f..83d48a77 100644 --- a/kern/rtmutex_i.h +++ b/kern/rtmutex_i.h @@ -47,8 +47,11 @@ #define RTMUTEX_OWNER_MASK (~((uintptr_t)(RTMUTEX_FORCE_WAIT \ | RTMUTEX_CONTENDED))) -#define rtmutex_assert_owner_aligned(owner) \ - assert(((owner) & ~RTMUTEX_OWNER_MASK) == 0) +static inline bool +rtmutex_owner_aligned(uintptr_t owner) +{ + return (((owner) & ~RTMUTEX_OWNER_MASK) == 0); +} static inline uintptr_t rtmutex_lock_fast(struct rtmutex *rtmutex) @@ -56,7 +59,7 @@ rtmutex_lock_fast(struct rtmutex *rtmutex) uintptr_t owner; owner = (uintptr_t)thread_self(); - rtmutex_assert_owner_aligned(owner); + assert(rtmutex_owner_aligned(owner)); return atomic_cas(&rtmutex->owner, 0, owner, ATOMIC_ACQUIRE); } @@ -66,7 +69,7 @@ rtmutex_unlock_fast(struct rtmutex *rtmutex) uintptr_t owner, prev_owner; owner = (uintptr_t)thread_self(); - rtmutex_assert_owner_aligned(owner); + assert(rtmutex_owner_aligned(owner)); prev_owner = atomic_cas(&rtmutex->owner, owner, 0, ATOMIC_RELEASE); assert((prev_owner & RTMUTEX_OWNER_MASK) == owner); return prev_owner; |