mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/etc] Added fallback definition of RUBY_ATOMIC_EXCHANGE
https://github.com/ruby/etc/commit/0c5900bd21
This commit is contained in:
parent
f6e2c41db3
commit
d2aaf865e3
1 changed files with 9 additions and 0 deletions
|
@ -68,6 +68,15 @@ void rb_deprecate_constant(VALUE mod, const char *name);
|
|||
typedef int rb_atomic_t;
|
||||
# define RUBY_ATOMIC_CAS(var, oldval, newval) \
|
||||
((var) == (oldval) ? ((var) = (newval), (oldval)) : (var))
|
||||
# define RUBY_ATOMIC_EXCHANGE(var, newval) \
|
||||
atomic_exchange(&var, newval)
|
||||
static inline rb_atomic_t
|
||||
atomic_exchange(volatile rb_atomic_t *var, rb_atomic_t newval)
|
||||
{
|
||||
rb_atomic_t oldval = *var;
|
||||
*var = newval;
|
||||
return oldval;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* call-seq:
|
||||
|
|
Loading…
Reference in a new issue