]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: sync: atomic: Add atomic {cmp,}xchg operations
authorBoqun Feng <boqun.feng@gmail.com>
Fri, 5 Sep 2025 04:41:32 +0000 (21:41 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 15 Sep 2025 07:38:33 +0000 (09:38 +0200)
commitb606a532c01380ac282fd0a0858e3e8ea01ad904
tree0a1244c81305c5007cd44982a8af8af52267cb2f
parent29c32c405e53605dfd24054a4460516f7f6e3938
rust: sync: atomic: Add atomic {cmp,}xchg operations

xchg() and cmpxchg() are basic operations on atomic. Provide these based
on C APIs.

Note that cmpxchg() use the similar function signature as
compare_exchange() in Rust std: returning a `Result`, `Ok(old)` means
the operation succeeds and `Err(old)` means the operation fails.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Reviewed-by: Elle Rhumsaa <elle@weathered-steel.dev>
Link: https://lore.kernel.org/all/20250719030827.61357-6-boqun.feng@gmail.com/
rust/kernel/sync/atomic.rs