mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
Reapply "Fix stdatomic case in rbimpl_atomic_u64_fetch_add"
This reverts commit 8a68dc7bdd3d1c97677a6633a4f2b5e524c492ae.
This commit is contained in:
parent
f8ee06901c
commit
bbf4bde75e
Notes:
git
2025-12-18 19:57:38 +00:00
@ -1746,6 +1746,7 @@ AS_IF([test "$GCC" = yes], [
|
||||
[rb_cv_gcc_atomic_builtins=no])])
|
||||
AS_IF([test "$rb_cv_gcc_atomic_builtins" = yes], [
|
||||
AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS)
|
||||
AC_CHECK_LIB([atomic], [__atomic_fetch_add_8])
|
||||
AC_CACHE_CHECK([for 64bit __atomic builtins], [rb_cv_gcc_atomic_builtins_64], [
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdint.h>
|
||||
uint64_t atomic_var;]],
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
#define INTERNAL_ATOMIC_H
|
||||
|
||||
#include "ruby/atomic.h"
|
||||
#ifdef HAVE_STDATOMIC_H
|
||||
# include <stdatomic.h>
|
||||
#endif
|
||||
|
||||
#define RUBY_ATOMIC_VALUE_LOAD(x) rbimpl_atomic_value_load(&(x), RBIMPL_ATOMIC_SEQ_CST)
|
||||
|
||||
@ -76,9 +79,9 @@ rbimpl_atomic_u64_fetch_add(volatile rbimpl_atomic_uint64_t *ptr, uint64_t val)
|
||||
return InterlockedExchangeAdd64((volatile LONG64 *)ptr, val);
|
||||
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
||||
return atomic_add_64_nv(ptr, val) - val;
|
||||
#elif defined(HAVE_STDATOMIC_H)
|
||||
return atomic_fetch_add_explicit((_Atomic uint64_t *)ptr, val, memory_order_seq_cst);
|
||||
#else
|
||||
// TODO: stdatomic
|
||||
|
||||
// Fallback using mutex for platforms without 64-bit atomics
|
||||
static rb_native_mutex_t lock = RB_NATIVE_MUTEX_INITIALIZER;
|
||||
rb_native_mutex_lock(&lock);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user