diff options
Diffstat (limited to 'signal.c')
-rw-r--r-- | signal.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -25,6 +25,17 @@ typedef LONG rb_atomic_t; # define ATOMIC_INC(var) InterlockedIncrement(&(var)) # define ATOMIC_DEC(var) InterlockedDecrement(&(var)) +#elsif __GNUC__ >= 4 +/* @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 char rb_atomic_t; /* Anything OK */ +# define ATOMIC_TEST(var) __sync_lock_test_and_set(&(var), 0) +# 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) + #else typedef int rb_atomic_t; |