summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2025-06-11 22:56:24 +0900
committerNobuyoshi Nakada <[email protected]>2025-06-13 11:14:05 +0900
commit7cfdcde069037b2a353c7662eb8819ef96ba6dad (patch)
treea0015680d7661752f04e8c864331b72bc9f4eae9
parent7fa3e1a1db6e7c998865cc114f9145ab841f8601 (diff)
Expect aligned pointer for the atomic operations
-rw-r--r--ruby_atomic.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/ruby_atomic.h b/ruby_atomic.h
index f5f32191af..04c5d6d9f8 100644
--- a/ruby_atomic.h
+++ b/ruby_atomic.h
@@ -36,8 +36,10 @@ rbimpl_atomic_load_relaxed(volatile rb_atomic_t *ptr)
}
#define ATOMIC_LOAD_RELAXED(var) rbimpl_atomic_load_relaxed(&(var))
+typedef RBIMPL_ALIGNAS(8) uint64_t rbimpl_atomic_uint64_t;
+
static inline uint64_t
-rbimpl_atomic_u64_load_relaxed(const volatile uint64_t *value)
+rbimpl_atomic_u64_load_relaxed(const volatile rbimpl_atomic_uint64_t *value)
{
#if defined(HAVE_GCC_ATOMIC_BUILTINS_64)
return __atomic_load_n(value, __ATOMIC_RELAXED);
@@ -54,7 +56,7 @@ rbimpl_atomic_u64_load_relaxed(const volatile uint64_t *value)
#define ATOMIC_U64_LOAD_RELAXED(var) rbimpl_atomic_u64_load_relaxed(&(var))
static inline void
-rbimpl_atomic_u64_set_relaxed(volatile uint64_t *address, uint64_t value)
+rbimpl_atomic_u64_set_relaxed(volatile rbimpl_atomic_uint64_t *address, uint64_t value)
{
#if defined(HAVE_GCC_ATOMIC_BUILTINS_64)
__atomic_store_n(address, value, __ATOMIC_RELAXED);