diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-26 10:57:39 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-26 10:57:39 +0000 |
commit | 6190bb4d8ad7a07ddb1da8fc687b20612743a34a (patch) | |
tree | 72600b2de79b50643fde443dd7eb1a6b9a331344 /ruby_atomic.h | |
parent | 8c6ad2b0ae9a0d5c2205f4648e5fa0c86fa6077f (diff) | |
download | ruby-6190bb4d8ad7a07ddb1da8fc687b20612743a34a.tar.gz |
* ruby_atomic.h (ATOMIC_CAS): new macro for compare-and-exchange.
* vm_core.h (struct rb_thread_struct): add interrupt_mask member.
* thread.c (thread_create_core, Init_Thread): initialize
th->thread_mask.
* vm_core.h (RUBY_VM_INTERRUPTED_ANY): new macro for avoiding
bare th->interrupt_flag.
* vm_core.h (RUBY_VM_INTERRUPTED, RUBY_VM_INTERRUPTED): check
th->interrupt_mask.
* thread.c (set_unblock_function, rb_thread_schedule): replace
th->interrupt_flag with RUBY_VM_INTERRUPTED_ANY()
* signal.c (signal_exec): set up thread->interrupt_mask for
preventing recursive trap handler.
* vm_core.h (RUBY_VM_CHECK_INTS, RUBY_VM_CHECK_INTS_BLOCKING): ditto.
* thread.c (rb_threadptr_execute_interrupts):
don't process interrupt if it is masked.
[Bug #6009] [ruby-core:42524]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_atomic.h')
-rw-r--r-- | ruby_atomic.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ruby_atomic.h b/ruby_atomic.h index f4dd5db38a..dd23964f76 100644 --- a/ruby_atomic.h +++ b/ruby_atomic.h @@ -13,6 +13,7 @@ typedef unsigned int rb_atomic_t; /* Anything OK */ # 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)) +# define ATOMIC_CAS(var, oldval, newval) __sync_val_compare_and_swap(&(var), (oldval), (newval)) # define ATOMIC_SIZE_ADD(var, val) __sync_fetch_and_add(&(var), (val)) # define ATOMIC_SIZE_SUB(var, val) __sync_fetch_and_sub(&(var), (val)) @@ -48,7 +49,7 @@ rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val) # 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)) # ifdef _M_AMD64 # define ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd64(&(var), (val)) # define ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd64(&(var), -(val)) |