Skip to content

Commit

Permalink
Added fallback definition of RUBY_ATOMIC_EXCHANGE
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jan 11, 2021
1 parent f017bdf commit 0c5900b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ext/etc/etc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0c5900b

Please sign in to comment.