Expose atomic operation macros with RUBY prefix

Now we need atomic operations, which are lighter than mutex, more
widely for extension libraries because of Ractor.
This commit is contained in:
Nobuyoshi Nakada 2020-12-23 14:09:28 +09:00
Родитель f755926ddd
Коммит 6ed6b85ece
6 изменённых файлов: 297 добавлений и 235 удалений

Просмотреть файл

@ -1878,6 +1878,7 @@ ast.$(OBJEXT): $(top_srcdir)/internal/warnings.h
ast.$(OBJEXT): {$(VPATH)}assert.h
ast.$(OBJEXT): {$(VPATH)}ast.c
ast.$(OBJEXT): {$(VPATH)}ast.rbinc
ast.$(OBJEXT): {$(VPATH)}atomic.h
ast.$(OBJEXT): {$(VPATH)}backward/2/assume.h
ast.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
ast.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -2246,6 +2247,7 @@ builtin.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
builtin.$(OBJEXT): $(top_srcdir)/internal/vm.h
builtin.$(OBJEXT): $(top_srcdir)/internal/warnings.h
builtin.$(OBJEXT): {$(VPATH)}assert.h
builtin.$(OBJEXT): {$(VPATH)}atomic.h
builtin.$(OBJEXT): {$(VPATH)}backward/2/assume.h
builtin.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
builtin.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -2437,6 +2439,7 @@ class.$(OBJEXT): $(top_srcdir)/internal/variable.h
class.$(OBJEXT): $(top_srcdir)/internal/vm.h
class.$(OBJEXT): $(top_srcdir)/internal/warnings.h
class.$(OBJEXT): {$(VPATH)}assert.h
class.$(OBJEXT): {$(VPATH)}atomic.h
class.$(OBJEXT): {$(VPATH)}backward/2/assume.h
class.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
class.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -2810,6 +2813,7 @@ compile.$(OBJEXT): $(top_srcdir)/internal/variable.h
compile.$(OBJEXT): $(top_srcdir)/internal/vm.h
compile.$(OBJEXT): $(top_srcdir)/internal/warnings.h
compile.$(OBJEXT): {$(VPATH)}assert.h
compile.$(OBJEXT): {$(VPATH)}atomic.h
compile.$(OBJEXT): {$(VPATH)}backward/2/assume.h
compile.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
compile.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -3201,6 +3205,7 @@ cont.$(OBJEXT): $(top_srcdir)/internal/vm.h
cont.$(OBJEXT): $(top_srcdir)/internal/warnings.h
cont.$(OBJEXT): {$(VPATH)}$(COROUTINE_H)
cont.$(OBJEXT): {$(VPATH)}assert.h
cont.$(OBJEXT): {$(VPATH)}atomic.h
cont.$(OBJEXT): {$(VPATH)}backward/2/assume.h
cont.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
cont.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -3392,6 +3397,7 @@ debug.$(OBJEXT): $(top_srcdir)/internal/util.h
debug.$(OBJEXT): $(top_srcdir)/internal/vm.h
debug.$(OBJEXT): $(top_srcdir)/internal/warnings.h
debug.$(OBJEXT): {$(VPATH)}assert.h
debug.$(OBJEXT): {$(VPATH)}atomic.h
debug.$(OBJEXT): {$(VPATH)}backward/2/assume.h
debug.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
debug.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -5021,6 +5027,7 @@ error.$(OBJEXT): $(top_srcdir)/internal/variable.h
error.$(OBJEXT): $(top_srcdir)/internal/vm.h
error.$(OBJEXT): $(top_srcdir)/internal/warnings.h
error.$(OBJEXT): {$(VPATH)}assert.h
error.$(OBJEXT): {$(VPATH)}atomic.h
error.$(OBJEXT): {$(VPATH)}backward/2/assume.h
error.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
error.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -5223,6 +5230,7 @@ eval.$(OBJEXT): $(top_srcdir)/internal/variable.h
eval.$(OBJEXT): $(top_srcdir)/internal/vm.h
eval.$(OBJEXT): $(top_srcdir)/internal/warnings.h
eval.$(OBJEXT): {$(VPATH)}assert.h
eval.$(OBJEXT): {$(VPATH)}atomic.h
eval.$(OBJEXT): {$(VPATH)}backward/2/assume.h
eval.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
eval.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -5645,6 +5653,7 @@ gc.$(OBJEXT): $(top_srcdir)/internal/variable.h
gc.$(OBJEXT): $(top_srcdir)/internal/vm.h
gc.$(OBJEXT): $(top_srcdir)/internal/warnings.h
gc.$(OBJEXT): {$(VPATH)}assert.h
gc.$(OBJEXT): {$(VPATH)}atomic.h
gc.$(OBJEXT): {$(VPATH)}backward/2/assume.h
gc.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
gc.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -5855,6 +5864,7 @@ golf_prelude.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
golf_prelude.$(OBJEXT): $(top_srcdir)/internal/vm.h
golf_prelude.$(OBJEXT): $(top_srcdir)/internal/warnings.h
golf_prelude.$(OBJEXT): {$(VPATH)}assert.h
golf_prelude.$(OBJEXT): {$(VPATH)}atomic.h
golf_prelude.$(OBJEXT): {$(VPATH)}backward/2/assume.h
golf_prelude.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
golf_prelude.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -6572,6 +6582,7 @@ io.$(OBJEXT): $(top_srcdir)/internal/variable.h
io.$(OBJEXT): $(top_srcdir)/internal/vm.h
io.$(OBJEXT): $(top_srcdir)/internal/warnings.h
io.$(OBJEXT): {$(VPATH)}assert.h
io.$(OBJEXT): {$(VPATH)}atomic.h
io.$(OBJEXT): {$(VPATH)}backward/2/assume.h
io.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
io.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -6778,6 +6789,7 @@ iseq.$(OBJEXT): $(top_srcdir)/internal/variable.h
iseq.$(OBJEXT): $(top_srcdir)/internal/vm.h
iseq.$(OBJEXT): $(top_srcdir)/internal/warnings.h
iseq.$(OBJEXT): {$(VPATH)}assert.h
iseq.$(OBJEXT): {$(VPATH)}atomic.h
iseq.$(OBJEXT): {$(VPATH)}backward/2/assume.h
iseq.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
iseq.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -6984,6 +6996,7 @@ load.$(OBJEXT): $(top_srcdir)/internal/variable.h
load.$(OBJEXT): $(top_srcdir)/internal/vm.h
load.$(OBJEXT): $(top_srcdir)/internal/warnings.h
load.$(OBJEXT): {$(VPATH)}assert.h
load.$(OBJEXT): {$(VPATH)}atomic.h
load.$(OBJEXT): {$(VPATH)}backward/2/assume.h
load.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
load.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -8189,6 +8202,7 @@ miniinit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
miniinit.$(OBJEXT): {$(VPATH)}array.rb
miniinit.$(OBJEXT): {$(VPATH)}assert.h
miniinit.$(OBJEXT): {$(VPATH)}ast.rb
miniinit.$(OBJEXT): {$(VPATH)}atomic.h
miniinit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
miniinit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
miniinit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -8381,6 +8395,7 @@ miniprelude.$(OBJEXT): $(hdrdir)/ruby.h
miniprelude.$(OBJEXT): $(hdrdir)/ruby/ruby.h
miniprelude.$(OBJEXT): {$(VPATH)}assert.h
miniprelude.$(OBJEXT): {$(VPATH)}ast.rb
miniprelude.$(OBJEXT): {$(VPATH)}atomic.h
miniprelude.$(OBJEXT): {$(VPATH)}config.h
miniprelude.$(OBJEXT): {$(VPATH)}defines.h
miniprelude.$(OBJEXT): {$(VPATH)}gc.rb
@ -8424,6 +8439,7 @@ mjit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
mjit.$(OBJEXT): $(top_srcdir)/internal/vm.h
mjit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
mjit.$(OBJEXT): {$(VPATH)}assert.h
mjit.$(OBJEXT): {$(VPATH)}atomic.h
mjit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
mjit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
mjit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -8637,6 +8653,7 @@ mjit_compile.$(OBJEXT): $(top_srcdir)/internal/variable.h
mjit_compile.$(OBJEXT): $(top_srcdir)/internal/vm.h
mjit_compile.$(OBJEXT): $(top_srcdir)/internal/warnings.h
mjit_compile.$(OBJEXT): {$(VPATH)}assert.h
mjit_compile.$(OBJEXT): {$(VPATH)}atomic.h
mjit_compile.$(OBJEXT): {$(VPATH)}backward/2/assume.h
mjit_compile.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
mjit_compile.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -8833,6 +8850,7 @@ node.$(OBJEXT): $(top_srcdir)/internal/variable.h
node.$(OBJEXT): $(top_srcdir)/internal/vm.h
node.$(OBJEXT): $(top_srcdir)/internal/warnings.h
node.$(OBJEXT): {$(VPATH)}assert.h
node.$(OBJEXT): {$(VPATH)}atomic.h
node.$(OBJEXT): {$(VPATH)}backward/2/assume.h
node.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
node.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -9771,6 +9789,7 @@ prelude.$(OBJEXT): $(CCAN_DIR)/str/str.h
prelude.$(OBJEXT): $(hdrdir)/ruby.h
prelude.$(OBJEXT): $(hdrdir)/ruby/ruby.h
prelude.$(OBJEXT): {$(VPATH)}assert.h
prelude.$(OBJEXT): {$(VPATH)}atomic.h
prelude.$(OBJEXT): {$(VPATH)}config.h
prelude.$(OBJEXT): {$(VPATH)}defines.h
prelude.$(OBJEXT): {$(VPATH)}gem_prelude.rb
@ -9812,6 +9831,7 @@ proc.$(OBJEXT): $(top_srcdir)/internal/symbol.h
proc.$(OBJEXT): $(top_srcdir)/internal/vm.h
proc.$(OBJEXT): $(top_srcdir)/internal/warnings.h
proc.$(OBJEXT): {$(VPATH)}assert.h
proc.$(OBJEXT): {$(VPATH)}atomic.h
proc.$(OBJEXT): {$(VPATH)}backward/2/assume.h
proc.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
proc.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -10013,6 +10033,7 @@ process.$(OBJEXT): $(top_srcdir)/internal/vm.h
process.$(OBJEXT): $(top_srcdir)/internal/warnings.h
process.$(OBJEXT): {$(VPATH)}$(COROUTINE_H)
process.$(OBJEXT): {$(VPATH)}assert.h
process.$(OBJEXT): {$(VPATH)}atomic.h
process.$(OBJEXT): {$(VPATH)}backward/2/assume.h
process.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
process.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -10217,6 +10238,7 @@ ractor.$(OBJEXT): $(top_srcdir)/internal/thread.h
ractor.$(OBJEXT): $(top_srcdir)/internal/vm.h
ractor.$(OBJEXT): $(top_srcdir)/internal/warnings.h
ractor.$(OBJEXT): {$(VPATH)}assert.h
ractor.$(OBJEXT): {$(VPATH)}atomic.h
ractor.$(OBJEXT): {$(VPATH)}backward/2/assume.h
ractor.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
ractor.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -10419,6 +10441,7 @@ random.$(OBJEXT): $(top_srcdir)/internal/variable.h
random.$(OBJEXT): $(top_srcdir)/internal/vm.h
random.$(OBJEXT): $(top_srcdir)/internal/warnings.h
random.$(OBJEXT): {$(VPATH)}assert.h
random.$(OBJEXT): {$(VPATH)}atomic.h
random.$(OBJEXT): {$(VPATH)}backward/2/assume.h
random.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
random.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -12144,6 +12167,7 @@ ruby.$(OBJEXT): $(top_srcdir)/internal/variable.h
ruby.$(OBJEXT): $(top_srcdir)/internal/vm.h
ruby.$(OBJEXT): $(top_srcdir)/internal/warnings.h
ruby.$(OBJEXT): {$(VPATH)}assert.h
ruby.$(OBJEXT): {$(VPATH)}atomic.h
ruby.$(OBJEXT): {$(VPATH)}backward/2/assume.h
ruby.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
ruby.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -12337,6 +12361,7 @@ scheduler.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
scheduler.$(OBJEXT): $(top_srcdir)/internal/vm.h
scheduler.$(OBJEXT): $(top_srcdir)/internal/warnings.h
scheduler.$(OBJEXT): {$(VPATH)}assert.h
scheduler.$(OBJEXT): {$(VPATH)}atomic.h
scheduler.$(OBJEXT): {$(VPATH)}backward/2/assume.h
scheduler.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
scheduler.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -12688,6 +12713,7 @@ signal.$(OBJEXT): $(top_srcdir)/internal/thread.h
signal.$(OBJEXT): $(top_srcdir)/internal/vm.h
signal.$(OBJEXT): $(top_srcdir)/internal/warnings.h
signal.$(OBJEXT): {$(VPATH)}assert.h
signal.$(OBJEXT): {$(VPATH)}atomic.h
signal.$(OBJEXT): {$(VPATH)}backward/2/assume.h
signal.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
signal.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -13635,6 +13661,7 @@ struct.$(OBJEXT): $(top_srcdir)/internal/symbol.h
struct.$(OBJEXT): $(top_srcdir)/internal/vm.h
struct.$(OBJEXT): $(top_srcdir)/internal/warnings.h
struct.$(OBJEXT): {$(VPATH)}assert.h
struct.$(OBJEXT): {$(VPATH)}atomic.h
struct.$(OBJEXT): {$(VPATH)}backward/2/assume.h
struct.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
struct.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -14024,6 +14051,7 @@ thread.$(OBJEXT): $(top_srcdir)/internal/vm.h
thread.$(OBJEXT): $(top_srcdir)/internal/warnings.h
thread.$(OBJEXT): {$(VPATH)}$(COROUTINE_H)
thread.$(OBJEXT): {$(VPATH)}assert.h
thread.$(OBJEXT): {$(VPATH)}atomic.h
thread.$(OBJEXT): {$(VPATH)}backward/2/assume.h
thread.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
thread.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -14590,6 +14618,7 @@ transient_heap.$(OBJEXT): $(top_srcdir)/internal/variable.h
transient_heap.$(OBJEXT): $(top_srcdir)/internal/vm.h
transient_heap.$(OBJEXT): $(top_srcdir)/internal/warnings.h
transient_heap.$(OBJEXT): {$(VPATH)}assert.h
transient_heap.$(OBJEXT): {$(VPATH)}atomic.h
transient_heap.$(OBJEXT): {$(VPATH)}backward/2/assume.h
transient_heap.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
transient_heap.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -14955,6 +14984,7 @@ variable.$(OBJEXT): $(top_srcdir)/internal/variable.h
variable.$(OBJEXT): $(top_srcdir)/internal/vm.h
variable.$(OBJEXT): $(top_srcdir)/internal/warnings.h
variable.$(OBJEXT): {$(VPATH)}assert.h
variable.$(OBJEXT): {$(VPATH)}atomic.h
variable.$(OBJEXT): {$(VPATH)}backward/2/assume.h
variable.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
variable.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -15152,6 +15182,7 @@ version.$(OBJEXT): $(top_srcdir)/internal/warnings.h
version.$(OBJEXT): $(top_srcdir)/revision.h
version.$(OBJEXT): $(top_srcdir)/version.h
version.$(OBJEXT): {$(VPATH)}assert.h
version.$(OBJEXT): {$(VPATH)}atomic.h
version.$(OBJEXT): {$(VPATH)}backward/2/assume.h
version.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
version.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -15356,6 +15387,7 @@ vm.$(OBJEXT): $(top_srcdir)/internal/variable.h
vm.$(OBJEXT): $(top_srcdir)/internal/vm.h
vm.$(OBJEXT): $(top_srcdir)/internal/warnings.h
vm.$(OBJEXT): {$(VPATH)}assert.h
vm.$(OBJEXT): {$(VPATH)}atomic.h
vm.$(OBJEXT): {$(VPATH)}backward/2/assume.h
vm.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
vm.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -15572,6 +15604,7 @@ vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/vm.h
vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/warnings.h
vm_backtrace.$(OBJEXT): {$(VPATH)}assert.h
vm_backtrace.$(OBJEXT): {$(VPATH)}atomic.h
vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/assume.h
vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -15761,6 +15794,7 @@ vm_dump.$(OBJEXT): $(top_srcdir)/internal/vm.h
vm_dump.$(OBJEXT): $(top_srcdir)/internal/warnings.h
vm_dump.$(OBJEXT): {$(VPATH)}addr2line.h
vm_dump.$(OBJEXT): {$(VPATH)}assert.h
vm_dump.$(OBJEXT): {$(VPATH)}atomic.h
vm_dump.$(OBJEXT): {$(VPATH)}backward/2/assume.h
vm_dump.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
vm_dump.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -15951,6 +15985,7 @@ vm_sync.$(OBJEXT): $(top_srcdir)/internal/vm.h
vm_sync.$(OBJEXT): $(top_srcdir)/internal/warnings.h
vm_sync.$(OBJEXT): {$(VPATH)}addr2line.h
vm_sync.$(OBJEXT): {$(VPATH)}assert.h
vm_sync.$(OBJEXT): {$(VPATH)}atomic.h
vm_sync.$(OBJEXT): {$(VPATH)}backward/2/assume.h
vm_sync.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
vm_sync.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@ -16150,6 +16185,7 @@ vm_trace.$(OBJEXT): $(top_srcdir)/internal/symbol.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/vm.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/warnings.h
vm_trace.$(OBJEXT): {$(VPATH)}assert.h
vm_trace.$(OBJEXT): {$(VPATH)}atomic.h
vm_trace.$(OBJEXT): {$(VPATH)}backward/2/assume.h
vm_trace.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
vm_trace.$(OBJEXT): {$(VPATH)}backward/2/bool.h

Просмотреть файл

@ -3,6 +3,7 @@ coverage.o: $(RUBY_EXTCONF_H)
coverage.o: $(arch_hdrdir)/ruby/config.h
coverage.o: $(hdrdir)/ruby.h
coverage.o: $(hdrdir)/ruby/assert.h
coverage.o: $(hdrdir)/ruby/atomic.h
coverage.o: $(hdrdir)/ruby/backward.h
coverage.o: $(hdrdir)/ruby/backward/2/assume.h
coverage.o: $(hdrdir)/ruby/backward/2/attributes.h

Просмотреть файл

@ -355,6 +355,7 @@ objspace_dump.o: $(RUBY_EXTCONF_H)
objspace_dump.o: $(arch_hdrdir)/ruby/config.h
objspace_dump.o: $(hdrdir)/ruby.h
objspace_dump.o: $(hdrdir)/ruby/assert.h
objspace_dump.o: $(hdrdir)/ruby/atomic.h
objspace_dump.o: $(hdrdir)/ruby/backward.h
objspace_dump.o: $(hdrdir)/ruby/backward/2/assume.h
objspace_dump.o: $(hdrdir)/ruby/backward/2/attributes.h

Просмотреть файл

@ -10,6 +10,7 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#define HAVE_RUBY_ATOMIC_H 1
#define HAVE_RUBY_DEBUG_H 1
#define HAVE_RUBY_DEFINES_H 1
#define HAVE_RUBY_ENCODING_H 1

236
include/ruby/atomic.h Normal file
Просмотреть файл

@ -0,0 +1,236 @@
#ifndef RUBY_ATOMIC_H
#define RUBY_ATOMIC_H
/*
* - RUBY_ATOMIC_CAS, RUBY_ATOMIC_EXCHANGE, RUBY_ATOMIC_FETCH_*:
* return the old * value.
* - RUBY_ATOMIC_ADD, RUBY_ATOMIC_SUB, RUBY_ATOMIC_INC, RUBY_ATOMIC_DEC, RUBY_ATOMIC_OR, RUBY_ATOMIC_SET:
* may be void.
*/
#if 0
#elif defined HAVE_GCC_ATOMIC_BUILTINS
typedef unsigned int rb_atomic_t;
# define RUBY_ATOMIC_FETCH_ADD(var, val) __atomic_fetch_add(&(var), (val), __ATOMIC_SEQ_CST)
# define RUBY_ATOMIC_FETCH_SUB(var, val) __atomic_fetch_sub(&(var), (val), __ATOMIC_SEQ_CST)
# define RUBY_ATOMIC_OR(var, val) __atomic_fetch_or(&(var), (val), __ATOMIC_SEQ_CST)
# define RUBY_ATOMIC_EXCHANGE(var, val) __atomic_exchange_n(&(var), (val), __ATOMIC_SEQ_CST)
# define RUBY_ATOMIC_CAS(var, oldval, newval) RB_GNUC_EXTENSION_BLOCK( \
__typeof__(var) oldvaldup = (oldval); /* oldval should not be modified */ \
__atomic_compare_exchange_n(&(var), &oldvaldup, (newval), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \
oldvaldup )
# define RUBY_ATOMIC_GENERIC_MACRO 1
#elif defined HAVE_GCC_SYNC_BUILTINS
/* @shyouhei hack to support atomic operations in case of gcc. Gcc
* has its own pseudo-insns to support them. See info, or
* http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html */
typedef unsigned int rb_atomic_t; /* Anything OK */
# define RUBY_ATOMIC_FETCH_ADD(var, val) __sync_fetch_and_add(&(var), (val))
# define RUBY_ATOMIC_FETCH_SUB(var, val) __sync_fetch_and_sub(&(var), (val))
# define RUBY_ATOMIC_OR(var, val) __sync_fetch_and_or(&(var), (val))
# define RUBY_ATOMIC_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val))
# define RUBY_ATOMIC_CAS(var, oldval, newval) __sync_val_compare_and_swap(&(var), (oldval), (newval))
# define RUBY_ATOMIC_GENERIC_MACRO 1
#elif defined _WIN32
#if MSC_VERSION_SINCE(1300)
#pragma intrinsic(_InterlockedOr)
#endif
typedef LONG rb_atomic_t;
# define RUBY_ATOMIC_SET(var, val) InterlockedExchange(&(var), (val))
# define RUBY_ATOMIC_INC(var) InterlockedIncrement(&(var))
# define RUBY_ATOMIC_DEC(var) InterlockedDecrement(&(var))
# define RUBY_ATOMIC_FETCH_ADD(var, val) InterlockedExchangeAdd(&(var), (val))
# define RUBY_ATOMIC_FETCH_SUB(var, val) InterlockedExchangeAdd(&(var), -(LONG)(val))
#if defined __GNUC__
# define RUBY_ATOMIC_OR(var, val) __asm__("lock\n\t" "orl\t%1, %0" : "=m"(var) : "Ir"(val))
#elif MSC_VERSION_BEFORE(1300)
# define RUBY_ATOMIC_OR(var, val) rb_w32_atomic_or(&(var), (val))
static inline void
rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val)
{
#ifdef _M_IX86
__asm mov eax, var;
__asm mov ecx, val;
__asm lock or [eax], ecx;
#else
#error unsupported architecture
#endif
}
#else
# define RUBY_ATOMIC_OR(var, val) _InterlockedOr(&(var), (val))
#endif
# define RUBY_ATOMIC_EXCHANGE(var, val) InterlockedExchange(&(var), (val))
# define RUBY_ATOMIC_CAS(var, oldval, newval) InterlockedCompareExchange(&(var), (newval), (oldval))
# if MSC_VERSION_BEFORE(1300)
static inline rb_atomic_t
rb_w32_atomic_cas(volatile rb_atomic_t *var, rb_atomic_t oldval, rb_atomic_t newval)
{
return (rb_atomic_t)InterlockedCompareExchange((PVOID *)var, (PVOID)newval, (PVOID)oldval);
}
# undef RUBY_ATOMIC_CAS
# define RUBY_ATOMIC_CAS(var, oldval, newval) rb_w32_atomic_cas(&(var), (oldval), (newval))
# endif
# ifdef _M_AMD64
# define RUBY_ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd64((LONG_LONG *)&(var), (val))
# define RUBY_ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd64((LONG_LONG *)&(var), -(LONG)(val))
# define RUBY_ATOMIC_SIZE_INC(var) InterlockedIncrement64(&(var))
# define RUBY_ATOMIC_SIZE_DEC(var) InterlockedDecrement64(&(var))
# define RUBY_ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange64(&(var), (val))
# define RUBY_ATOMIC_SIZE_CAS(var, oldval, newval) InterlockedCompareExchange64(&(var), (newval), (oldval))
# else
# define RUBY_ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd((LONG *)&(var), (val))
# define RUBY_ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd((LONG *)&(var), -(LONG)(val))
# define RUBY_ATOMIC_SIZE_INC(var) InterlockedIncrement((LONG *)&(var))
# define RUBY_ATOMIC_SIZE_DEC(var) InterlockedDecrement((LONG *)&(var))
# define RUBY_ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange((LONG *)&(var), (val))
# endif
# ifdef InterlockedExchangePointer
# define RUBY_ATOMIC_PTR_EXCHANGE(var, val) InterlockedExchangePointer((PVOID volatile *)&(var), (PVOID)(val))
# endif /* See below for definitions of other situations */
#elif defined(__sun) && defined(HAVE_ATOMIC_H)
#include <atomic.h>
typedef unsigned int rb_atomic_t;
# define RUBY_ATOMIC_INC(var) atomic_inc_uint(&(var))
# define RUBY_ATOMIC_DEC(var) atomic_dec_uint(&(var))
# define RUBY_ATOMIC_FETCH_ADD(var, val) rb_atomic_fetch_add(&(var), (val))
# define RUBY_ATOMIC_FETCH_SUB(var, val) rb_atomic_fetch_sub(&(var), (val))
# define RUBY_ATOMIC_ADD(var, val) atomic_add_uint(&(var), (val))
# define RUBY_ATOMIC_SUB(var, val) atomic_sub_uint(&(var), (val))
# define RUBY_ATOMIC_OR(var, val) atomic_or_uint(&(var), (val))
# define RUBY_ATOMIC_EXCHANGE(var, val) atomic_swap_uint(&(var), (val))
# define RUBY_ATOMIC_CAS(var, oldval, newval) atomic_cas_uint(&(var), (oldval), (newval))
static inline rb_atomic_t
rb_atomic_fetch_add(volatile rb_atomic_t *var, rb_atomic_t val)
{
return atomic_add_int_nv(var, val) - val;
}
static inline rb_atomic_t
rb_atomic_fetch_sub(volatile rb_atomic_t *var, rb_atomic_t val)
{
return atomic_add_int_nv(var, (rb_atomic_t)(-(int)val)) + val;
}
# if defined(_LP64) || defined(_I32LPx)
# define RUBY_ATOMIC_SIZE_ADD(var, val) atomic_add_long(&(var), (val))
# define RUBY_ATOMIC_SIZE_SUB(var, val) atomic_add_long(&(var), -(val))
# define RUBY_ATOMIC_SIZE_INC(var) atomic_inc_ulong(&(var))
# define RUBY_ATOMIC_SIZE_DEC(var) atomic_dec_ulong(&(var))
# define RUBY_ATOMIC_SIZE_EXCHANGE(var, val) atomic_swap_ulong(&(var), (val))
# define RUBY_ATOMIC_SIZE_CAS(var, oldval, val) atomic_cas_ulong(&(var), (oldval), (val))
# else
# define RUBY_ATOMIC_SIZE_ADD(var, val) atomic_add_int(&(var), (val))
# define RUBY_ATOMIC_SIZE_SUB(var, val) atomic_add_int(&(var), -(val))
# define RUBY_ATOMIC_SIZE_INC(var) atomic_inc_uint(&(var))
# define RUBY_ATOMIC_SIZE_DEC(var) atomic_dec_uint(&(var))
# define RUBY_ATOMIC_SIZE_EXCHANGE(var, val) atomic_swap_uint(&(var), (val))
# endif
#else
# error No atomic operation found
#endif
#ifndef RUBY_ATOMIC_SET
# define RUBY_ATOMIC_SET(var, val) (void)RUBY_ATOMIC_EXCHANGE(var, val)
#endif
#ifndef RUBY_ATOMIC_ADD
# define RUBY_ATOMIC_ADD(var, val) (void)RUBY_ATOMIC_FETCH_ADD(var, val)
#endif
#ifndef RUBY_ATOMIC_SUB
# define RUBY_ATOMIC_SUB(var, val) (void)RUBY_ATOMIC_FETCH_SUB(var, val)
#endif
#ifndef RUBY_ATOMIC_INC
# define RUBY_ATOMIC_INC(var) RUBY_ATOMIC_ADD(var, 1)
#endif
#ifndef RUBY_ATOMIC_DEC
# define RUBY_ATOMIC_DEC(var) RUBY_ATOMIC_SUB(var, 1)
#endif
#ifndef RUBY_ATOMIC_SIZE_INC
# define RUBY_ATOMIC_SIZE_INC(var) RUBY_ATOMIC_INC(var)
#endif
#ifndef RUBY_ATOMIC_SIZE_DEC
# define RUBY_ATOMIC_SIZE_DEC(var) RUBY_ATOMIC_DEC(var)
#endif
#ifndef RUBY_ATOMIC_SIZE_EXCHANGE
# define RUBY_ATOMIC_SIZE_EXCHANGE(var, val) RUBY_ATOMIC_EXCHANGE(var, val)
#endif
#ifndef RUBY_ATOMIC_SIZE_CAS
# define RUBY_ATOMIC_SIZE_CAS(var, oldval, val) RUBY_ATOMIC_CAS(var, oldval, val)
#endif
#ifndef RUBY_ATOMIC_SIZE_ADD
# define RUBY_ATOMIC_SIZE_ADD(var, val) RUBY_ATOMIC_ADD(var, val)
#endif
#ifndef RUBY_ATOMIC_SIZE_SUB
# define RUBY_ATOMIC_SIZE_SUB(var, val) RUBY_ATOMIC_SUB(var, val)
#endif
#if RUBY_ATOMIC_GENERIC_MACRO
# ifndef RUBY_ATOMIC_PTR_EXCHANGE
# define RUBY_ATOMIC_PTR_EXCHANGE(var, val) RUBY_ATOMIC_EXCHANGE(var, val)
# endif
# ifndef RUBY_ATOMIC_PTR_CAS
# define RUBY_ATOMIC_PTR_CAS(var, oldval, newval) RUBY_ATOMIC_CAS(var, oldval, newval)
# endif
# ifndef RUBY_ATOMIC_VALUE_EXCHANGE
# define RUBY_ATOMIC_VALUE_EXCHANGE(var, val) RUBY_ATOMIC_EXCHANGE(var, val)
# endif
# ifndef RUBY_ATOMIC_VALUE_CAS
# define RUBY_ATOMIC_VALUE_CAS(var, oldval, val) RUBY_ATOMIC_CAS(var, oldval, val)
# endif
#endif
#ifndef RUBY_ATOMIC_PTR_EXCHANGE
# if SIZEOF_VOIDP == SIZEOF_SIZE_T
# define RUBY_ATOMIC_PTR_EXCHANGE(var, val) (void *)RUBY_ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val))
# else
# error No atomic exchange for void*
# endif
#endif
#ifndef RUBY_ATOMIC_PTR_CAS
# if SIZEOF_VOIDP == SIZEOF_SIZE_T
# define RUBY_ATOMIC_PTR_CAS(var, oldval, val) (void *)RUBY_ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))
# else
# error No atomic compare-and-set for void*
# endif
#endif
#ifndef RUBY_ATOMIC_VALUE_EXCHANGE
# if SIZEOF_VALUE == SIZEOF_SIZE_T
# define RUBY_ATOMIC_VALUE_EXCHANGE(var, val) RUBY_ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val))
# else
# error No atomic exchange for VALUE
# endif
#endif
#ifndef RUBY_ATOMIC_VALUE_CAS
# if SIZEOF_VALUE == SIZEOF_SIZE_T
# define RUBY_ATOMIC_VALUE_CAS(var, oldval, val) RUBY_ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))
# else
# error No atomic compare-and-set for VALUE
# endif
#endif
#endif /* RUBY_ATOMIC_H */

Просмотреть файл

@ -1,236 +1,23 @@
#ifndef RUBY_ATOMIC_H
#define RUBY_ATOMIC_H
#include "ruby/atomic.h"
/*
* - ATOMIC_CAS, ATOMIC_EXCHANGE, ATOMIC_FETCH_*:
* return the old * value.
* - ATOMIC_ADD, ATOMIC_SUB, ATOMIC_INC, ATOMIC_DEC, ATOMIC_OR, ATOMIC_SET:
* may be void.
*/
#if 0
#elif defined HAVE_GCC_ATOMIC_BUILTINS
typedef unsigned int rb_atomic_t;
# define ATOMIC_FETCH_ADD(var, val) __atomic_fetch_add(&(var), (val), __ATOMIC_SEQ_CST)
# define ATOMIC_FETCH_SUB(var, val) __atomic_fetch_sub(&(var), (val), __ATOMIC_SEQ_CST)
# define ATOMIC_OR(var, val) __atomic_fetch_or(&(var), (val), __ATOMIC_SEQ_CST)
# define ATOMIC_EXCHANGE(var, val) __atomic_exchange_n(&(var), (val), __ATOMIC_SEQ_CST)
# define ATOMIC_CAS(var, oldval, newval) RB_GNUC_EXTENSION_BLOCK( \
__typeof__(var) oldvaldup = (oldval); /* oldval should not be modified */ \
__atomic_compare_exchange_n(&(var), &oldvaldup, (newval), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \
oldvaldup )
# define RUBY_ATOMIC_GENERIC_MACRO 1
#elif defined HAVE_GCC_SYNC_BUILTINS
/* @shyouhei hack to support atomic operations in case of gcc. Gcc
* has its own pseudo-insns to support them. See info, or
* http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html */
typedef unsigned int rb_atomic_t; /* Anything OK */
# define ATOMIC_FETCH_ADD(var, val) __sync_fetch_and_add(&(var), (val))
# define ATOMIC_FETCH_SUB(var, val) __sync_fetch_and_sub(&(var), (val))
# define ATOMIC_OR(var, val) __sync_fetch_and_or(&(var), (val))
# define ATOMIC_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val))
# define ATOMIC_CAS(var, oldval, newval) __sync_val_compare_and_swap(&(var), (oldval), (newval))
# define RUBY_ATOMIC_GENERIC_MACRO 1
#elif defined _WIN32
#if MSC_VERSION_SINCE(1300)
#pragma intrinsic(_InterlockedOr)
#endif
typedef LONG rb_atomic_t;
# define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val))
# define ATOMIC_INC(var) InterlockedIncrement(&(var))
# define ATOMIC_DEC(var) InterlockedDecrement(&(var))
# define ATOMIC_FETCH_ADD(var, val) InterlockedExchangeAdd(&(var), (val))
# define ATOMIC_FETCH_SUB(var, val) InterlockedExchangeAdd(&(var), -(LONG)(val))
#if defined __GNUC__
# define ATOMIC_OR(var, val) __asm__("lock\n\t" "orl\t%1, %0" : "=m"(var) : "Ir"(val))
#elif MSC_VERSION_BEFORE(1300)
# define ATOMIC_OR(var, val) rb_w32_atomic_or(&(var), (val))
static inline void
rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val)
{
#ifdef _M_IX86
__asm mov eax, var;
__asm mov ecx, val;
__asm lock or [eax], ecx;
#else
#error unsupported architecture
#endif
}
#else
# define ATOMIC_OR(var, val) _InterlockedOr(&(var), (val))
#endif
# define ATOMIC_EXCHANGE(var, val) InterlockedExchange(&(var), (val))
# define ATOMIC_CAS(var, oldval, newval) InterlockedCompareExchange(&(var), (newval), (oldval))
# if MSC_VERSION_BEFORE(1300)
static inline rb_atomic_t
rb_w32_atomic_cas(volatile rb_atomic_t *var, rb_atomic_t oldval, rb_atomic_t newval)
{
return (rb_atomic_t)InterlockedCompareExchange((PVOID *)var, (PVOID)newval, (PVOID)oldval);
}
# undef ATOMIC_CAS
# define ATOMIC_CAS(var, oldval, newval) rb_w32_atomic_cas(&(var), (oldval), (newval))
# endif
# ifdef _M_AMD64
# define ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd64((LONG_LONG *)&(var), (val))
# define ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd64((LONG_LONG *)&(var), -(LONG)(val))
# define ATOMIC_SIZE_INC(var) InterlockedIncrement64(&(var))
# define ATOMIC_SIZE_DEC(var) InterlockedDecrement64(&(var))
# define ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange64(&(var), (val))
# define ATOMIC_SIZE_CAS(var, oldval, newval) InterlockedCompareExchange64(&(var), (newval), (oldval))
# else
# define ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd((LONG *)&(var), (val))
# define ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd((LONG *)&(var), -(LONG)(val))
# define ATOMIC_SIZE_INC(var) InterlockedIncrement((LONG *)&(var))
# define ATOMIC_SIZE_DEC(var) InterlockedDecrement((LONG *)&(var))
# define ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange((LONG *)&(var), (val))
# endif
# ifdef InterlockedExchangePointer
# define ATOMIC_PTR_EXCHANGE(var, val) InterlockedExchangePointer((PVOID volatile *)&(var), (PVOID)(val))
# endif /* See below for definitions of other situations */
#elif defined(__sun) && defined(HAVE_ATOMIC_H)
#include <atomic.h>
typedef unsigned int rb_atomic_t;
# define ATOMIC_INC(var) atomic_inc_uint(&(var))
# define ATOMIC_DEC(var) atomic_dec_uint(&(var))
# define ATOMIC_FETCH_ADD(var, val) rb_atomic_fetch_add(&(var), (val))
# define ATOMIC_FETCH_SUB(var, val) rb_atomic_fetch_sub(&(var), (val))
# define ATOMIC_ADD(var, val) atomic_add_uint(&(var), (val))
# define ATOMIC_SUB(var, val) atomic_sub_uint(&(var), (val))
# define ATOMIC_OR(var, val) atomic_or_uint(&(var), (val))
# define ATOMIC_EXCHANGE(var, val) atomic_swap_uint(&(var), (val))
# define ATOMIC_CAS(var, oldval, newval) atomic_cas_uint(&(var), (oldval), (newval))
static inline rb_atomic_t
rb_atomic_fetch_add(volatile rb_atomic_t *var, rb_atomic_t val)
{
return atomic_add_int_nv(var, val) - val;
}
static inline rb_atomic_t
rb_atomic_fetch_sub(volatile rb_atomic_t *var, rb_atomic_t val)
{
return atomic_add_int_nv(var, (rb_atomic_t)(-(int)val)) + val;
}
# if defined(_LP64) || defined(_I32LPx)
# define ATOMIC_SIZE_ADD(var, val) atomic_add_long(&(var), (val))
# define ATOMIC_SIZE_SUB(var, val) atomic_add_long(&(var), -(val))
# define ATOMIC_SIZE_INC(var) atomic_inc_ulong(&(var))
# define ATOMIC_SIZE_DEC(var) atomic_dec_ulong(&(var))
# define ATOMIC_SIZE_EXCHANGE(var, val) atomic_swap_ulong(&(var), (val))
# define ATOMIC_SIZE_CAS(var, oldval, val) atomic_cas_ulong(&(var), (oldval), (val))
# else
# define ATOMIC_SIZE_ADD(var, val) atomic_add_int(&(var), (val))
# define ATOMIC_SIZE_SUB(var, val) atomic_add_int(&(var), -(val))
# define ATOMIC_SIZE_INC(var) atomic_inc_uint(&(var))
# define ATOMIC_SIZE_DEC(var) atomic_dec_uint(&(var))
# define ATOMIC_SIZE_EXCHANGE(var, val) atomic_swap_uint(&(var), (val))
# endif
#else
# error No atomic operation found
#endif
#ifndef ATOMIC_SET
# define ATOMIC_SET(var, val) (void)ATOMIC_EXCHANGE(var, val)
#endif
#ifndef ATOMIC_ADD
# define ATOMIC_ADD(var, val) (void)ATOMIC_FETCH_ADD(var, val)
#endif
#ifndef ATOMIC_SUB
# define ATOMIC_SUB(var, val) (void)ATOMIC_FETCH_SUB(var, val)
#endif
#ifndef ATOMIC_INC
# define ATOMIC_INC(var) ATOMIC_ADD(var, 1)
#endif
#ifndef ATOMIC_DEC
# define ATOMIC_DEC(var) ATOMIC_SUB(var, 1)
#endif
#ifndef ATOMIC_SIZE_INC
# define ATOMIC_SIZE_INC(var) ATOMIC_INC(var)
#endif
#ifndef ATOMIC_SIZE_DEC
# define ATOMIC_SIZE_DEC(var) ATOMIC_DEC(var)
#endif
#ifndef ATOMIC_SIZE_EXCHANGE
# define ATOMIC_SIZE_EXCHANGE(var, val) ATOMIC_EXCHANGE(var, val)
#endif
#ifndef ATOMIC_SIZE_CAS
# define ATOMIC_SIZE_CAS(var, oldval, val) ATOMIC_CAS(var, oldval, val)
#endif
#ifndef ATOMIC_SIZE_ADD
# define ATOMIC_SIZE_ADD(var, val) ATOMIC_ADD(var, val)
#endif
#ifndef ATOMIC_SIZE_SUB
# define ATOMIC_SIZE_SUB(var, val) ATOMIC_SUB(var, val)
#endif
#if RUBY_ATOMIC_GENERIC_MACRO
# ifndef ATOMIC_PTR_EXCHANGE
# define ATOMIC_PTR_EXCHANGE(var, val) ATOMIC_EXCHANGE(var, val)
# endif
# ifndef ATOMIC_PTR_CAS
# define ATOMIC_PTR_CAS(var, oldval, newval) ATOMIC_CAS(var, oldval, newval)
# endif
# ifndef ATOMIC_VALUE_EXCHANGE
# define ATOMIC_VALUE_EXCHANGE(var, val) ATOMIC_EXCHANGE(var, val)
# endif
# ifndef ATOMIC_VALUE_CAS
# define ATOMIC_VALUE_CAS(var, oldval, val) ATOMIC_CAS(var, oldval, val)
# endif
#endif
#ifndef ATOMIC_PTR_EXCHANGE
# if SIZEOF_VOIDP == SIZEOF_SIZE_T
# define ATOMIC_PTR_EXCHANGE(var, val) (void *)ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val))
# else
# error No atomic exchange for void*
# endif
#endif
#ifndef ATOMIC_PTR_CAS
# if SIZEOF_VOIDP == SIZEOF_SIZE_T
# define ATOMIC_PTR_CAS(var, oldval, val) (void *)ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))
# else
# error No atomic compare-and-set for void*
# endif
#endif
#ifndef ATOMIC_VALUE_EXCHANGE
# if SIZEOF_VALUE == SIZEOF_SIZE_T
# define ATOMIC_VALUE_EXCHANGE(var, val) ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val))
# else
# error No atomic exchange for VALUE
# endif
#endif
#ifndef ATOMIC_VALUE_CAS
# if SIZEOF_VALUE == SIZEOF_SIZE_T
# define ATOMIC_VALUE_CAS(var, oldval, val) ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))
# else
# error No atomic compare-and-set for VALUE
# endif
#endif
#endif /* RUBY_ATOMIC_H */
/* shim macros only */
#define ATOMIC_ADD(var, val) RUBY_ATOMIC_ADD(var, val)
#define ATOMIC_CAS(var, oldval, newval) RUBY_ATOMIC_CAS(var, oldval, newval)
#define ATOMIC_DEC(var) RUBY_ATOMIC_DEC(var)
#define ATOMIC_EXCHANGE(var, val) RUBY_ATOMIC_EXCHANGE(var, val)
#define ATOMIC_FETCH_ADD(var, val) RUBY_ATOMIC_FETCH_ADD(var, val)
#define ATOMIC_FETCH_SUB(var, val) RUBY_ATOMIC_FETCH_SUB(var, val)
#define ATOMIC_INC(var) RUBY_ATOMIC_INC(var)
#define ATOMIC_OR(var, val) RUBY_ATOMIC_OR(var, val)
#define ATOMIC_PTR_CAS(var, oldval, newval) RUBY_ATOMIC_PTR_CAS(var, oldval, newval)
#define ATOMIC_PTR_EXCHANGE(var, val) RUBY_ATOMIC_PTR_EXCHANGE(var, val)
#define ATOMIC_SET(var, val) RUBY_ATOMIC_SET(var, val)
#define ATOMIC_SIZE_ADD(var, val) RUBY_ATOMIC_SIZE_ADD(var, val)
#define ATOMIC_SIZE_CAS(var, oldval, newval) RUBY_ATOMIC_SIZE_CAS(var, oldval, newval)
#define ATOMIC_SIZE_DEC(var) RUBY_ATOMIC_SIZE_DEC(var)
#define ATOMIC_SIZE_EXCHANGE(var, val) RUBY_ATOMIC_SIZE_EXCHANGE(var, val)
#define ATOMIC_SIZE_INC(var) RUBY_ATOMIC_SIZE_INC(var)
#define ATOMIC_SIZE_SUB(var, val) RUBY_ATOMIC_SIZE_SUB(var, val)
#define ATOMIC_SUB(var, val) RUBY_ATOMIC_SUB(var, val)
#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)