-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add singlethreaded (compiler-only) fences. #888
Conversation
This seems pretty useful, +1. |
Agreed. |
alternatives: using |
Why does the llvm reference say 'this is useful for interacting with signal handlers'? Reading the docs for atomic_signal_fence does not enlighten. |
My understanding is that signals preempt the thread or process receiving them, meaning they will execute on the same physical thread. Because there's no hardware context switch, memory reordering is not a concern since operations always appear to happen in program order within a single thread's context. If code interacts with signal handlers via memory, compiler reordering of memory operations may change the order of operations as seen by the signal handler (which the compiler is not aware of), potentially violating program-maintained invariants. Neglected to mention it elsewhere; this RFC comes from Rust PR #22358, which includes an implementation. |
Accepted. Tracking bug rust-lang/rust#24118. Sorry for the long delays. |
Add safe wrapper for atomic_compilerfence intrinsics This PR adds a proposed safe wrapper for the `atomic_singlethreadfence_*` intrinsics introduced by [RFC #888](rust-lang/rfcs#888). See #41091 for further discussion.
Rendered.