Sha256: e2932e50ac1e56dcdd873c5de05aa139834be2cc04297ab1d02145b34a0c7bc8

Contents?: true

Size: 1.85 KB

Versions: 215

Compression:

Stored size: 1.85 KB

Contents

#ifndef RUBY_ATOMIC_H
#define RUBY_ATOMIC_H

#ifdef _WIN32
#if defined _MSC_VER && _MSC_VER > 1200
#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))
#if defined __GNUC__
# define ATOMIC_OR(var, val) __asm__("lock\n\t" "orl\t%1, %0" : "=m"(var) : "Ir"(val))
#elif defined _MSC_VER && _MSC_VER <= 1200
# 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))

#elif defined HAVE_GCC_ATOMIC_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_SET(var, val)  __sync_lock_test_and_set(&(var), (val))
# define ATOMIC_INC(var) __sync_fetch_and_add(&(var), 1)
# define ATOMIC_DEC(var) __sync_fetch_and_sub(&(var), 1)
# define ATOMIC_OR(var, val) __sync_or_and_fetch(&(var), (val))
# define ATOMIC_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val))

#else
typedef int rb_atomic_t;
extern rb_atomic_t ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val);

# define ATOMIC_SET(var, val) ((var) = (val))
# define ATOMIC_INC(var) (++(var))
# define ATOMIC_DEC(var) (--(var))
# define ATOMIC_OR(var, val) ((var) |= (val))
# define ATOMIC_EXCHANGE(var, val) ruby_atomic_exchange(&(var), (val))
#endif

#endif /* RUBY_ATOMIC_H */

Version data entries

215 entries across 95 versions & 13 rubygems

Version Path
binding_of_caller-0.8.0 ext/binding_of_caller/ruby_headers/193/atomic.h
binding_of_caller-0.7.3 ext/binding_of_caller/ruby_headers/193/atomic.h
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/debugger-ruby_core_source-1.3.8/lib/debugger/ruby_core_source/ruby-1.9.3-p286/atomic.h
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/debugger-ruby_core_source-1.3.8/lib/debugger/ruby_core_source/ruby-1.9.3-p125/atomic.h
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/debugger-ruby_core_source-1.3.8/lib/debugger/ruby_core_source/ruby-1.9.3-p327/atomic.h
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/debugger-ruby_core_source-1.3.8/lib/debugger/ruby_core_source/ruby-1.9.3-p0/atomic.h
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/debugger-ruby_core_source-1.3.8/lib/debugger/ruby_core_source/ruby-1.9.3-p194/atomic.h
looksee-3.1.1 ext/mri/1.9.3/atomic.h
coverband_ext-1.1.0 ext/coverband_ext/ruby_headers/193/atomic.h
coverband_ext-1.0.1 ext/coverband_ext/ruby_headers/193/atomic.h
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/binding_of_caller-0.7.2/ext/binding_of_caller/ruby_headers/193/atomic.h
looksee-3.1.0-universal-java-1.8 ext/mri/1.9.3/atomic.h
looksee-3.1.0 ext/mri/1.9.3/atomic.h
looksee-3.0.1-universal-java-1.8 ext/mri/1.9.3/atomic.h
looksee-3.0.1 ext/mri/1.9.3/atomic.h
debugger-ruby_core_source-1.3.8 ./lib/debugger/ruby_core_source/ruby-1.9.3-p327/atomic.h
debugger-ruby_core_source-1.3.8 ./lib/debugger/ruby_core_source/ruby-1.9.3-p125/atomic.h
debugger-ruby_core_source-1.3.8 ./lib/debugger/ruby_core_source/ruby-1.9.3-p194/atomic.h
debugger-ruby_core_source-1.3.8 ./lib/debugger/ruby_core_source/ruby-1.9.3-p286/atomic.h
debugger-ruby_core_source-1.3.8 ./lib/debugger/ruby_core_source/ruby-1.9.3-p0/atomic.h