summaryrefslogtreecommitdiff
path: root/ruby_atomic.h
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-29 06:46:33 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-29 06:46:33 (GMT)
commit1058f206727c23693a2f41b9da5f0cbb76da63f0 (patch)
treede6e18893261939eda6ca4db6e1316dbe75863ec /ruby_atomic.h
parent52d8f9f3efb30905ccef0f061dbca6a4e4d30deb (diff)
ruby_atomic.h: ATOMIC_SIZE_CAS
* ruby_atomic.h (ATOMIC_SIZE_CAS): new macro, compare and swap size_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_atomic.h')
-rw-r--r--ruby_atomic.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/ruby_atomic.h b/ruby_atomic.h
index 1079fb1..9a9a148 100644
--- a/ruby_atomic.h
+++ b/ruby_atomic.h
@@ -65,6 +65,7 @@ rb_w32_atomic_cas(volatile rb_atomic_t *var, rb_atomic_t oldval, rb_atomic_t new
# 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, val) InterlockedCompareExchange64(&(var), (oldval), (val))
# else
# define ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd((LONG *)&(var), (val))
# define ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd((LONG *)&(var), -(LONG)(val))
@@ -90,6 +91,7 @@ typedef unsigned int rb_atomic_t;
# 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), (val))
# else
# define ATOMIC_SIZE_ADD(var, val) atomic_add_int(&(var), (val))
# define ATOMIC_SIZE_SUB(var, val) atomic_add_int(&(var), -(val))
@@ -127,4 +129,8 @@ atomic_size_exchange(size_t *ptr, size_t val)
}
#endif
+#ifndef ATOMIC_SIZE_CAS
+# define ATOMIC_SIZE_CAS(var, oldval, val) ATOMIC_CAS(var, oldval, val)
+#endif
+
#endif /* RUBY_ATOMIC_H */