Skip to content

Don't use _Atomic in C99 mode - #138

Closed
byroot wants to merge 1 commit into
ruby:masterfrom
byroot:ruby-atomics
Closed

Don't use _Atomic in C99 mode#138
byroot wants to merge 1 commit into
ruby:masterfrom
byroot:ruby-atomics

Conversation

@byroot

@byroot byroot commented Aug 14, 2026

Copy link
Copy Markdown
Member
/github/workspace/src/ext/digest/blake3/blake3_dispatch.c:108:5: error: '_Atomic' is a C11 extension [-Werror,-Wc11-extensions]
      108 |     ATOMIC_INT g_cpu_features = UNDEFINED;
          |     ^
/github/workspace/src/ext/digest/blake3/blake3_dispatch.c:34:20: note: expanded from macro 'ATOMIC_INT'
       34 | #define ATOMIC_INT _Atomic int
          |                    ^
1 error generated.

This atomic is used to cache the CPU features, it doesn't need very strong atomic semantic, just avoid reaping, which isn't a big concern.

```
/github/workspace/src/ext/digest/blake3/blake3_dispatch.c:108:5: error: '_Atomic' is a C11 extension [-Werror,-Wc11-extensions]
      108 |     ATOMIC_INT g_cpu_features = UNDEFINED;
          |     ^
/github/workspace/src/ext/digest/blake3/blake3_dispatch.c:34:20: note: expanded from macro 'ATOMIC_INT'
       34 | #define ATOMIC_INT _Atomic int
          |                    ^
1 error generated.
```
@byroot
byroot requested review from nobu and tenderlove August 14, 2026 12:16
@byroot
byroot requested a review from knu as a code owner August 14, 2026 12:16
@byroot byroot mentioned this pull request Aug 14, 2026
@byroot byroot closed this Aug 14, 2026
checking_for("C11 atomics") do
unless try_compile(<<~C)
static _Atomic int atomic_int = 0;
int main(void){ return 0 }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int main(void){ return 0 }
int main(void){ return 0; }

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