Skip to content

document safety requirements for atomic intrinsics - #163140

Open
yilin0518 wants to merge 1 commit into
rust-lang:mainfrom
yilin0518:fix_atomic_ops
Open

yilin0518 wants to merge 1 commit into
rust-lang:mainfrom
yilin0518:fix_atomic_ops

Conversation

@yilin0518

@yilin0518 yilin0518 commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

This PR serves as a complement to PR #162854 by adding safety docs for the remaining atomic operations. These operations pass raw pointers as arguments and are marked unsafe, so I think it is necessary to explain why they are unsafe.

For atomic_cxchg, atomic_cxchgweak, atomic_xchg, these APIs have the same process whether T is an integer or a pointer type.

For atomic_xadd, atomic_xsub, atomic_and, atomic_or, atomic_xor, these APIs correspond to different operations in core/src/sync/atomic.rs for T is an integer or a pointer type.

For atomic_max, atomic_min, atomic_umax, atomic_umin, they only process when T is an integer (signed or unsigned) type.

For atomic_nand, there doesn't exist a method in AtomicPtr<T>, so I don't link the related method.

@rustbot

rustbot commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 22, 2026
@rustbot

rustbot commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from Darksonn, JohnTitor, Mark-Simulacrum, clarfonthey, jhpratt

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants