Skip to content

Convert rbimpl_atomic_* to use explicit memory ordering #14036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jhawthorn
Copy link
Member

This replaces the existing rbimpl_atomic_* helpers to all take an explicit memory ordering. rbimpl_ are meant to be private changing at any time, so we shouldn't consider this a change to the public API.

I made a previous attempt in #13974. Compared to that this replaces the existing rbimpl_ macros instead of adding new _explicit versions. I think that turned out a lot simpler. Although there are many lines changed, it's a very consistent change.

This adds memory ordering only for gcc's __atomic (which llvm also supports) and the C11 stdatomic.h. For other cases we have arbitrary values for the memory order and they are ignored, which we expect to give the equivalent of SEQ_CST.

"store" is the terminology the C11 standard uses, which allows us to use
this as a fallback.

This only changes the private rbimpl_ version of the method,
RUBY_ATOMIC_SET et al. keep the same name.
This only adds the rbimpl_ version to include/ruby/atomic.h so that it
is not a new public interface.

We were already using RUBY_ATOMIC_VALUE_LOAD in a few locations. This
will allow us to use other memory orders internally when desired.
My previous pass missed these atomic operations using operators.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant