Allow volatile pointer relaxed atomic operations

This commit is contained in:
Nobuyoshi Nakada 2025-06-05 17:32:24 +09:00
parent 9e84a278a3
commit 9f112afcde
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2025-06-05 09:43:32 +00:00

View File

@ -26,7 +26,7 @@
#define ATOMIC_VALUE_EXCHANGE(var, val) RUBY_ATOMIC_VALUE_EXCHANGE(var, val)
static inline rb_atomic_t
rbimpl_atomic_load_relaxed(rb_atomic_t *ptr)
rbimpl_atomic_load_relaxed(volatile rb_atomic_t *ptr)
{
#if defined(HAVE_GCC_ATOMIC_BUILTINS)
return __atomic_load_n(ptr, __ATOMIC_RELAXED);
@ -37,7 +37,7 @@ rbimpl_atomic_load_relaxed(rb_atomic_t *ptr)
#define ATOMIC_LOAD_RELAXED(var) rbimpl_atomic_load_relaxed(&(var))
static inline uint64_t
rbimpl_atomic_u64_load_relaxed(const uint64_t *value)
rbimpl_atomic_u64_load_relaxed(const volatile uint64_t *value)
{
#if defined(HAVE_GCC_ATOMIC_BUILTINS_64)
return __atomic_load_n(value, __ATOMIC_RELAXED);
@ -54,7 +54,7 @@ rbimpl_atomic_u64_load_relaxed(const uint64_t *value)
#define ATOMIC_U64_LOAD_RELAXED(var) rbimpl_atomic_u64_load_relaxed(&(var))
static inline void
rbimpl_atomic_u64_set_relaxed(uint64_t *address, uint64_t value)
rbimpl_atomic_u64_set_relaxed(volatile uint64_t *address, uint64_t value)
{
#if defined(HAVE_GCC_ATOMIC_BUILTINS_64)
__atomic_store_n(address, value, __ATOMIC_RELAXED);