ruby-changes:64825
From: Nobuyoshi <ko1@a...>
Date: Mon, 11 Jan 2021 11:41:14 +0900 (JST)
Subject: [ruby-changes:64825] d2aaf865e3 (master): [ruby/etc] Added fallback definition of RUBY_ATOMIC_EXCHANGE
https://git.ruby-lang.org/ruby.git/commit/?id=d2aaf865e3 From d2aaf865e3e5ecfcd10c879ce4263dc3a8f7fccf Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 11 Jan 2021 11:31:52 +0900 Subject: [ruby/etc] Added fallback definition of RUBY_ATOMIC_EXCHANGE https://github.com/ruby/etc/commit/0c5900bd21 diff --git a/ext/etc/etc.c b/ext/etc/etc.c index 44273ff..50f566d 100644 --- a/ext/etc/etc.c +++ b/ext/etc/etc.c @@ -68,6 +68,15 @@ void rb_deprecate_constant(VALUE mod, const char *name); https://github.com/ruby/ruby/blob/trunk/ext/etc/etc.c#L68 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: -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/