Tracking Issue for atomic volatile operations (`atomic_volatile`)
Open
Nobody has claimed this yet.
C-tracking-issue
S-tracking-unimplemented
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Feature gate: #![feature(atomic_volatile)]
This is a tracking issue for atomic volatile operations
- ACP: https://github.com/rust-lang/libs-team/issues/801
- t-opsem approval for the general principle: https://github.com/rust-lang/unsafe-code-guidelines/issues/615
Public API
// Not actually a generic impl, but you get the idea.
impl Atomic<T> {
/// Convenient method to create a raw pointer to `Atomic<T>` suitable for volatile accesses.
pub fn from_ptr_raw(ptr: *mut T) -> *const Self;
/// Performs a volatile atomic load of the given `order`.
pub unsafe fn load_volatile(self: *const Self, order: Ordering) -> T;
/// Performs a volatile atomic store of the given `order`.
pub unsafe fn store_volatile(self: *const Self, val: T, order: Ordering);
}
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- ACP: https://github.com/rust-lang/libs-team/issues/801
- Since then, I renamed
volatile_loadtoload_volatileto be consistent with the existingread_volatilethat also makesvolatilea suffix rather than a prefix (and same for stores)
- Since then, I renamed
- Implementation
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- Currently the API uses
arbitrary_self_types_pointers. Are we okay with that or would it be bad to expose that on stable? - On LLVM 22 and older, we don't correctly handle atomic volatile loads that trap. Adding the same black_box we add for non-atomic volatile loads is tricky because of how the code is structured in the backend. Maybe we should just wait until the minimum LLVM version is 23 before stabilizing this...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the atomic_volatile feature-gate API in this issue, then read ACP 801 and implementation PRs #160058 and #161301. Review the two unresolved questions about arbitrary_self_types_pointers and LLVM 22-or-older trap handling. Done requires the final comment period and a stabilization PR.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design, compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100