From 941d61398e60b2760c7e6b575120196468934e9d Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Mon, 25 Dec 2023 12:53:14 -0500 Subject: [PATCH] atomically read page_bitmaps page_bitmaps does not need to be volatile since it is going to be treated as atomic. In fact, as long as each variable is treated as atomic, we do not need volatile at all, as that means it is modified by outside means, aka hardware, etc. The atomic macros already ensure optimizations that could cause incorrect values to be used do not happen. Finally, the first loop is redundant as they are iterated over again in the loop below. --- src/shims/atomic_sfb.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shims/atomic_sfb.h b/src/shims/atomic_sfb.h index a87def054..b42a3a651 100644 --- a/src/shims/atomic_sfb.h +++ b/src/shims/atomic_sfb.h @@ -32,7 +32,7 @@ // Returns UINT_MAX if all the bits in p were already set. DISPATCH_ALWAYS_INLINE static inline unsigned int -os_atomic_set_first_bit(volatile unsigned long *p, unsigned int max) +os_atomic_set_first_bit(unsigned long *p, unsigned int max) { unsigned long val, bit; if (max > (sizeof(val) * 8)) { @@ -82,7 +82,7 @@ os_atomic_set_first_bit(volatile unsigned long *p, unsigned int max) DISPATCH_ALWAYS_INLINE static inline unsigned int -os_atomic_set_first_bit(volatile unsigned long *p, unsigned int max_index) +os_atomic_set_first_bit(unsigned long *p, unsigned int max) { unsigned int index; unsigned long b, b_masked; @@ -94,7 +94,7 @@ os_atomic_set_first_bit(volatile unsigned long *p, unsigned int max_index) os_atomic_rmw_loop_give_up(return UINT_MAX); } index--; - if (unlikely(index > max_index)) { + if (unlikely(index > max)) { os_atomic_rmw_loop_give_up(return UINT_MAX); } b_masked = b | (1UL << index);