1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

ruby_atomic.h: fix old value type of ATOMIC_CAS

* ruby_atomic.h (ATOMIC_CAS): old value to be swapped should be
  same as the destination.  immediate value may need type
  promotion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-12-05 00:56:52 +00:00
parent c5d2ef80a4
commit e65f38b97d
2 changed files with 6 additions and 2 deletions

View file

@ -10,7 +10,7 @@ typedef unsigned int rb_atomic_t;
# define ATOMIC_OR(var, val) __atomic_fetch_or(&(var), (val), __ATOMIC_SEQ_CST)
# define ATOMIC_EXCHANGE(var, val) __atomic_exchange_n(&(var), (val), __ATOMIC_SEQ_CST)
# define ATOMIC_CAS(var, oldval, newval) \
({ __typeof__(oldval) oldvaldup = (oldval); /* oldval should not be modified */ \
({ __typeof__(var) oldvaldup = (oldval); /* oldval should not be modified */ \
__atomic_compare_exchange_n(&(var), &oldvaldup, (newval), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \
oldvaldup; })