Skip to content

atomic.h: Add C11 implmentation of atomic operations #13799

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

Merged
merged 2 commits into from
Jul 17, 2025

Conversation

fuhsnn
Copy link
Contributor

@fuhsnn fuhsnn commented Jul 6, 2025

Introduce an implementation of atomic operations with C11 _Atomic qualifier and <stdatomic.h> functions. This allows C compilers relying on C11 model as the sole atomic interface to compile Ruby. The existing configure definition HAVE_STDATOMIC_H is used as the feature switch.

To be as non-intrusive as possible, new #elif blocks are consistently positioned right before #error, all currently supported systems are expected to be unaffected by the change, that is, no additional #include or library dependency or raising of -std version.

Several #else branches that were only used for 32-bit Windows and Oracle platforms are changed to explicit #elif Win || Oracle to maintain a consistent order of implementation branches.

@nobu
Copy link
Member

nobu commented Jul 7, 2025

the currently supported systems: GNU/Windows/Oracle

Do you mean Solaris by Oracle here?
I was confused because Oracle provides also Oracle Linux.

@fuhsnn
Copy link
Contributor Author

fuhsnn commented Jul 7, 2025

Do you mean Solaris by Oracle here?

I used Oracle to describe whatever compiler that evals (defined(__sun) && defined(HAVE_ATOMIC_H)) to 1, honestly I don't know which exact systems.

Edit:
Oracle Developer Studio 12.6 manual:

Note that __sun is only defined on Oracle Solaris platforms

cpredef/predef claims Solaris, SunOS and illumos

Should I change it to Solaris?

@nobu
Copy link
Member

nobu commented Jul 7, 2025

Do you mean Solaris by Oracle here?

I used Oracle to describe whatever compiler that evals (defined(__sun) && defined(HAVE_ATOMIC_H)) to 1, honestly I don't know which exact systems.

Edit: Oracle Developer Studio 12.6 manual:

Note that __sun is only defined on Oracle Solaris platforms

cpredef/predef claims Solaris, SunOS and illumos

Should I change it to Solaris?

At least illumos is based on OpenSolaris and not owned by Oracle.
And, as I wrote before, it will be confusing with "Oracle Linux" to call Solaris as "Oracle" simply.

@fuhsnn
Copy link
Contributor Author

fuhsnn commented Jul 7, 2025

If Solaris is not preferable, How about:

These branches are only active for `defined(_WIN32)` and
`(defined(__sun) && defined(HAVE_ATOMIC_H))` platforms,
codify the fact by changing `#else` to `#elif`'s that explicitly
include those targets, and `#error`-out otherwise.
The implementation is only active if `HAVE_STDATOMIC_H` is defined,
and only after the compiler fails to match all currently supported
systems.

@nobu
Copy link
Member

nobu commented Jul 8, 2025

If Solaris is not preferable, How about:

I haven't said that Solaris is not preferable, at all, and the word Solaris is not in your commit log.
I'm saying that it is ambiguous whether it means Oracle Linux or Oracle Solaris by just Oracle.
Rather I think you should use Solaris instead.

@fuhsnn
Copy link
Contributor Author

fuhsnn commented Jul 9, 2025

I haven't said that Solaris is not preferable

Sorry for the confusion, reworded and rebased.

@fuhsnn fuhsnn force-pushed the c11-atomic branch 2 times, most recently from 727c4f0 to ea5a308 Compare July 12, 2025 00:49
@fuhsnn
Copy link
Contributor Author

fuhsnn commented Jul 12, 2025

Is it acceptable for the macOS result CI jobs to fail? Several recent commits on master also had this one failing:
1582bd9
12d44db
0b23a8d
1317377

fuhsnn added 2 commits July 17, 2025 13:41
These branches are only active for 32-bit Windows and Solaris platforms,
codify the fact by changing `#else` to `#elif`'s that explicitly include
those targets and `#error`-out otherwise.
The implementation is only active if `HAVE_STDATOMIC_H` is defined,
and only after the compiler fails to match all currently supported
systems.
@nobu nobu merged commit 98aa2a6 into ruby:master Jul 17, 2025
84 checks passed
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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy