Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: helpers: Add i8/i16 atomic try_cmpxchg helpers

Add i8/i16 atomic try_cmpxchg helpers that call try_cmpxchg() macro
implementing atomic try_cmpxchg using architecture-specific
instructions.

[boqun: Add comments explaining CONFIG_ARCH_SUPPORTS_ATOMIC_RMW and use
try_cmpxchg() instead of raw_try_cmpxchg()]

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251227115951.1424458-2-fujita.tomonori@gmail.com

authored by

FUJITA Tomonori and committed by
Boqun Feng
164e4b56 910cbddc

+17
+17
rust/helpers/atomic_ext.c
··· 90 90 { 91 91 return xchg_relaxed(ptr, new); 92 92 } 93 + 94 + /* 95 + * try_cmpxchg helpers depend on ARCH_SUPPORTS_ATOMIC_RMW and on the 96 + * architecture provding try_cmpxchg() support for i8 and i16. 97 + * 98 + * The architectures that currently support Rust (x86_64, armv7, 99 + * arm64, riscv, and loongarch) satisfy these requirements. 100 + */ 101 + __rust_helper bool rust_helper_atomic_i8_try_cmpxchg(s8 *ptr, s8 *old, s8 new) 102 + { 103 + return try_cmpxchg(ptr, old, new); 104 + } 105 + 106 + __rust_helper bool rust_helper_atomic_i16_try_cmpxchg(s16 *ptr, s16 *old, s16 new) 107 + { 108 + return try_cmpxchg(ptr, old, new); 109 + }