Skip to content

Commit 5f5da2c

Browse files
committed
Fix stdatomic case in rbimpl_atomic_u64_fetch_add
This was failing on crossruby, likely because HAVE_GCC_ATOMIC_BUILTINS was true, but HAVE_GCC_ATOMIC_BUILTINS_64 was false. We probably should have feature detection of 64-bit stdatomics like we do for GCC, but for now let's keep rbimpl_atomic_u64_fetch_add in sync with load/set.
1 parent b9a213f commit 5f5da2c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ruby_atomic.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ rbimpl_atomic_u64_load_relaxed(const volatile rbimpl_atomic_uint64_t *value)
4343
uint64_t val = *value;
4444
return atomic_cas_64(value, val, val);
4545
#else
46+
// TODO: stdatomic
47+
4648
return *value;
4749
#endif
4850
}
@@ -58,6 +60,8 @@ rbimpl_atomic_u64_set_relaxed(volatile rbimpl_atomic_uint64_t *address, uint64_t
5860
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
5961
atomic_swap_64(address, value);
6062
#else
63+
// TODO: stdatomic
64+
6165
*address = value;
6266
#endif
6367
}
@@ -72,9 +76,9 @@ rbimpl_atomic_u64_fetch_add(volatile rbimpl_atomic_uint64_t *ptr, uint64_t val)
7276
return InterlockedExchangeAdd64((volatile LONG64 *)ptr, val);
7377
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
7478
return atomic_add_64_nv(ptr, val) - val;
75-
#elif defined(HAVE_STDATOMIC_H)
76-
return atomic_fetch_add_explicit((_Atomic uint64_t *)ptr, val, memory_order_seq_cst);
7779
#else
80+
// TODO: stdatomic
81+
7882
// Fallback using mutex for platforms without 64-bit atomics
7983
static rb_native_mutex_t lock = RB_NATIVE_MUTEX_INITIALIZER;
8084
rb_native_mutex_lock(&lock);

0 commit comments

Comments
 (0)