rust-lang / rust-lang/rust

Tracking Issue for atomic volatile operations (`atomic_volatile`)

Open
#158,947 0 comments 1 reaction 0 assignees View on GitHub

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

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.)

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.