summaryrefslogtreecommitdiff
path: root/ruby_atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'ruby_atomic.h')
-rw-r--r--ruby_atomic.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/ruby_atomic.h b/ruby_atomic.h
index 04c5d6d9f8..cbcfe682ce 100644
--- a/ruby_atomic.h
+++ b/ruby_atomic.h
@@ -2,6 +2,11 @@
#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)
/* shim macros only */
#define ATOMIC_ADD(var, val) RUBY_ATOMIC_ADD(var, val)
@@ -25,16 +30,7 @@
#define ATOMIC_VALUE_CAS(var, oldval, val) RUBY_ATOMIC_VALUE_CAS(var, oldval, val)
#define ATOMIC_VALUE_EXCHANGE(var, val) RUBY_ATOMIC_VALUE_EXCHANGE(var, val)
-static inline rb_atomic_t
-rbimpl_atomic_load_relaxed(volatile rb_atomic_t *ptr)
-{
-#if defined(HAVE_GCC_ATOMIC_BUILTINS)
- return __atomic_load_n(ptr, __ATOMIC_RELAXED);
-#else
- return *ptr;
-#endif
-}
-#define ATOMIC_LOAD_RELAXED(var) rbimpl_atomic_load_relaxed(&(var))
+#define ATOMIC_LOAD_RELAXED(var) rbimpl_atomic_load(&(var), RBIMPL_ATOMIC_RELAXED)
typedef RBIMPL_ALIGNAS(8) uint64_t rbimpl_atomic_uint64_t;
@@ -50,6 +46,8 @@ rbimpl_atomic_u64_load_relaxed(const volatile rbimpl_atomic_uint64_t *value)
uint64_t val = *value;
return atomic_cas_64(value, val, val);
#else
+ // TODO: stdatomic
+
return *value;
#endif
}
@@ -65,6 +63,8 @@ rbimpl_atomic_u64_set_relaxed(volatile rbimpl_atomic_uint64_t *address, uint64_t
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
atomic_swap_64(address, value);
#else
+ // TODO: stdatomic
+
*address = value;
#endif
}