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_read_acquire/atomic_set_release helpers

Add helper functions to expose smp_load_acquire() and
smp_store_release() for i8 and i16 types.

The smp_load_acquire() and smp_store_release() macros require type
information (sizeof) to generate appropriate architecture-specific
memory ordering instructions. Therefore, separate helper functions are
needed for each type size.

These helpers expose different symbol names than their C counterparts
so they are split into atomic_ext.c instead of atomic.c. The symbol
names; atomic_[i8|i16]_read_acquire and atomic_[i8|i16]_set_release
makes the interface Rust/C clear, consistent with i32/i64.

These helpers will be used by the upcoming Atomic<i8> and Atomic<i16>
implementation to provide proper Acquire/Release semantics across all
architectures.

[boqun: Rename the functions from {load,store} to {read,set} to avoid
future adjustment]

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251211113826.1299077-2-fujita.tomonori@gmail.com

authored by

FUJITA Tomonori and committed by
Boqun Feng
2cc3d5d6 09248ed8

+24
+23
rust/helpers/atomic_ext.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <asm/barrier.h> 4 + 5 + __rust_helper s8 rust_helper_atomic_i8_read_acquire(s8 *ptr) 6 + { 7 + return smp_load_acquire(ptr); 8 + } 9 + 10 + __rust_helper s16 rust_helper_atomic_i16_read_acquire(s16 *ptr) 11 + { 12 + return smp_load_acquire(ptr); 13 + } 14 + 15 + __rust_helper void rust_helper_atomic_i8_set_release(s8 *ptr, s8 val) 16 + { 17 + smp_store_release(ptr, val); 18 + } 19 + 20 + __rust_helper void rust_helper_atomic_i16_set_release(s16 *ptr, s16 val) 21 + { 22 + smp_store_release(ptr, val); 23 + }
+1
rust/helpers/helpers.c
··· 8 8 */ 9 9 10 10 #include "atomic.c" 11 + #include "atomic_ext.c" 11 12 #include "auxiliary.c" 12 13 #include "barrier.c" 13 14 #include "binder.c"