diff options
author | Richard Braun <rbraun@sceen.net> | 2017-06-13 21:23:50 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-06-13 21:23:50 +0200 |
commit | 72ed0dc2f153e7cf1d6e96f86a773bbe490e9e1c (patch) | |
tree | 8161eda7bec209778b30fdfdb19f154df4cab2a7 /kern/bitmap.h | |
parent | 61df7f19dfe3b56abf6c4d00589414c60716ac2b (diff) |
Various atomic access fixes
Diffstat (limited to 'kern/bitmap.h')
-rw-r--r-- | kern/bitmap.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/kern/bitmap.h b/kern/bitmap.h index a604d17c..c206944a 100644 --- a/kern/bitmap.h +++ b/kern/bitmap.h @@ -78,7 +78,7 @@ bitmap_set_atomic(unsigned long *bm, int bit) bitmap_lookup(bm, bit); } - atomic_or_acq_rel(bm, bitmap_mask(bit)); + atomic_or(bm, bitmap_mask(bit), ATOMIC_RELEASE); } static inline void @@ -98,7 +98,7 @@ bitmap_clear_atomic(unsigned long *bm, int bit) bitmap_lookup(bm, bit); } - atomic_and_acq_rel(bm, ~bitmap_mask(bit)); + atomic_and(bm, ~bitmap_mask(bit), ATOMIC_RELEASE); } static inline int @@ -111,6 +111,16 @@ bitmap_test(const unsigned long *bm, int bit) return ((*bm & bitmap_mask(bit)) != 0); } +static inline int +bitmap_test_atomic(const unsigned long *bm, int bit) +{ + if (bit >= LONG_BIT) { + bitmap_lookup(bm, bit); + } + + return ((atomic_load(bm, ATOMIC_ACQUIRE) & bitmap_mask(bit)) != 0); +} + static inline void bitmap_and(unsigned long *a, const unsigned long *b, int nr_bits) { |