diff options
Diffstat (limited to 'src/backend/port/atomics.c')
-rw-r--r-- | src/backend/port/atomics.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/backend/port/atomics.c b/src/backend/port/atomics.c index 263c68f4662..3350fb7df30 100644 --- a/src/backend/port/atomics.c +++ b/src/backend/port/atomics.c @@ -15,7 +15,7 @@ /* * We want the functions below to be inline; but if the compiler doesn't - * support that, fall back on providing them as regular functions. See + * support that, fall back on providing them as regular functions. See * STATIC_IF_INLINE in c.h. */ #define ATOMICS_INCLUDE_DEFINITIONS @@ -50,6 +50,7 @@ pg_atomic_init_flag_impl(volatile pg_atomic_flag *ptr) "size mismatch of atomic_flag vs slock_t"); #ifndef HAVE_SPINLOCKS + /* * NB: If we're using semaphore based TAS emulation, be careful to use a * separate set of semaphores. Otherwise we'd get in trouble if an atomic @@ -73,7 +74,7 @@ pg_atomic_clear_flag_impl(volatile pg_atomic_flag *ptr) S_UNLOCK((slock_t *) &ptr->sema); } -#endif /* PG_HAVE_ATOMIC_FLAG_SIMULATION */ +#endif /* PG_HAVE_ATOMIC_FLAG_SIMULATION */ #ifdef PG_HAVE_ATOMIC_U32_SIMULATION void @@ -98,7 +99,8 @@ bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval) { - bool ret; + bool ret; + /* * Do atomic op under a spinlock. It might look like we could just skip * the cmpxchg if the lock isn't available, but that'd just emulate a @@ -109,7 +111,7 @@ pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, */ SpinLockAcquire((slock_t *) &ptr->sema); - /* perform compare/exchange logic*/ + /* perform compare/exchange logic */ ret = ptr->value == *expected; *expected = ptr->value; if (ret) @@ -124,7 +126,8 @@ pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_) { - uint32 oldval; + uint32 oldval; + SpinLockAcquire((slock_t *) &ptr->sema); oldval = ptr->value; ptr->value += add_; @@ -132,4 +135,4 @@ pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_) return oldval; } -#endif /* PG_HAVE_ATOMIC_U32_SIMULATION */ +#endif /* PG_HAVE_ATOMIC_U32_SIMULATION */ |