Skip to content

Use stdatomic in sbrk.c. NFC#26509

Merged
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:simplify_sbrk
Mar 21, 2026
Merged

Use stdatomic in sbrk.c. NFC#26509
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:simplify_sbrk

Conversation

@sbc100
Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 commented Mar 20, 2026

No description provided.

@sbc100 sbc100 requested review from dschuff and juj March 20, 2026 21:07
@sbc100 sbc100 enabled auto-merge (squash) March 20, 2026 21:15
@sbc100 sbc100 requested a review from brendandahl March 20, 2026 22:09
@sbc100
Copy link
Copy Markdown
Collaborator Author

sbc100 commented Mar 20, 2026

@google-labs-jules review this please

Comment thread system/lib/libc/sbrk.c
}

uintptr_t *sbrk_ptr = (uintptr_t*)emscripten_get_sbrk_ptr();
_Atomic uintptr_t *sbrk_ptr = (_Atomic uintptr_t *)emscripten_get_sbrk_ptr();
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.

So this works in nonthreaded mode because of how we downgrade atomics in the backend? or are c11 atomics specified to be regular loads in nonthreaded mode?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, exactly.

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.

(which is it?)

Copy link
Copy Markdown
Collaborator Author

@sbc100 sbc100 Mar 21, 2026

Choose a reason for hiding this comment

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

The atomics are lowered away to non-atomics in the backend.

Comment thread system/lib/libc/sbrk.c
}

uintptr_t *sbrk_ptr = (uintptr_t*)emscripten_get_sbrk_ptr();
_Atomic uintptr_t *sbrk_ptr = (_Atomic uintptr_t *)emscripten_get_sbrk_ptr();
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.

(which is it?)

@sbc100 sbc100 merged commit 0bb48f6 into emscripten-core:main Mar 21, 2026
38 checks passed
@sbc100 sbc100 deleted the simplify_sbrk branch March 21, 2026 01:30
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