From 9d4e471cf974d99ab01fc243b5419c6711888540 Mon Sep 17 00:00:00 2001 From: kosaki Date: Sat, 11 Jun 2011 14:27:08 +0000 Subject: * vm_core.h (RUBY_VM_SET_TIMER_INTERRUPT, RUBY_VM_SET_INTERRUPT, RUBY_VM_SET_FINALIZER_INTERRUPT): use atomic ops for preventing interrupt_flag bit lost. * thread.c (rb_threadptr_execute_interrupts_rec): ditto. * vm_core.h (typedef struct rb_thread_struct): change type of interrupt_flag to rb_atomic_t. * atomic.h: move atomic ops definition from signal.c. * signal.c: remove atomic ops definition. * common.mk (gc, signal, thread, cont): add to dependency to atomic.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_core.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'vm_core.h') diff --git a/vm_core.h b/vm_core.h index f0bb86aedf..024b2ce68c 100644 --- a/vm_core.h +++ b/vm_core.h @@ -22,6 +22,7 @@ #include "vm_opts.h" #include "id.h" #include "method.h" +#include "atomic.h" #if defined(_WIN32) #include "thread_win32.h" @@ -430,7 +431,7 @@ typedef struct rb_thread_struct { VALUE thrown_errinfo; int exec_signal; - int interrupt_flag; + rb_atomic_t interrupt_flag; rb_thread_lock_t interrupt_lock; struct rb_unblock_callback unblock; VALUE locking_mutex; @@ -686,9 +687,9 @@ extern rb_vm_t *ruby_current_vm; #error "unsupported thread model" #endif -#define RUBY_VM_SET_INTERRUPT(th) ((th)->interrupt_flag |= 0x02) -#define RUBY_VM_SET_TIMER_INTERRUPT(th) ((th)->interrupt_flag |= 0x01) -#define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ((th)->interrupt_flag |= 0x04) +#define RUBY_VM_SET_TIMER_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, 0x01) +#define RUBY_VM_SET_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, 0x02) +#define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, 0x04) #define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & 0x02) int rb_signal_buff_size(void); -- cgit v1.2.3