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.

at 227c3d546e963874198aafc0cae8c3e8c24ae4ee 87 lines 2.7 kB view raw
1// SPDX-License-Identifier: GPL-2.0 2 3#include <asm/barrier.h> 4#include <asm/rwonce.h> 5#include <linux/atomic.h> 6 7#define GEN_READ_HELPER(tname, type) \ 8__rust_helper type rust_helper_atomic_##tname##_read(type *ptr) \ 9{ \ 10 return READ_ONCE(*ptr); \ 11} 12 13#define GEN_SET_HELPER(tname, type) \ 14__rust_helper void rust_helper_atomic_##tname##_set(type *ptr, type val) \ 15{ \ 16 WRITE_ONCE(*ptr, val); \ 17} 18 19#define GEN_READ_ACQUIRE_HELPER(tname, type) \ 20__rust_helper type rust_helper_atomic_##tname##_read_acquire(type *ptr) \ 21{ \ 22 return smp_load_acquire(ptr); \ 23} 24 25#define GEN_SET_RELEASE_HELPER(tname, type) \ 26__rust_helper void rust_helper_atomic_##tname##_set_release(type *ptr, type val)\ 27{ \ 28 smp_store_release(ptr, val); \ 29} 30 31#define GEN_READ_SET_HELPERS(tname, type) \ 32 GEN_READ_HELPER(tname, type) \ 33 GEN_SET_HELPER(tname, type) \ 34 GEN_READ_ACQUIRE_HELPER(tname, type) \ 35 GEN_SET_RELEASE_HELPER(tname, type) \ 36 37GEN_READ_SET_HELPERS(i8, s8) 38GEN_READ_SET_HELPERS(i16, s16) 39GEN_READ_SET_HELPERS(ptr, const void *) 40 41/* 42 * xchg helpers depend on ARCH_SUPPORTS_ATOMIC_RMW and on the 43 * architecture provding xchg() support for i8 and i16. 44 * 45 * The architectures that currently support Rust (x86_64, armv7, 46 * arm64, riscv, and loongarch) satisfy these requirements. 47 */ 48#define GEN_XCHG_HELPER(tname, type, suffix) \ 49__rust_helper type \ 50rust_helper_atomic_##tname##_xchg##suffix(type *ptr, type new) \ 51{ \ 52 return xchg##suffix(ptr, new); \ 53} 54 55#define GEN_XCHG_HELPERS(tname, type) \ 56 GEN_XCHG_HELPER(tname, type, ) \ 57 GEN_XCHG_HELPER(tname, type, _acquire) \ 58 GEN_XCHG_HELPER(tname, type, _release) \ 59 GEN_XCHG_HELPER(tname, type, _relaxed) \ 60 61GEN_XCHG_HELPERS(i8, s8) 62GEN_XCHG_HELPERS(i16, s16) 63GEN_XCHG_HELPERS(ptr, const void *) 64 65/* 66 * try_cmpxchg helpers depend on ARCH_SUPPORTS_ATOMIC_RMW and on the 67 * architecture provding try_cmpxchg() support for i8 and i16. 68 * 69 * The architectures that currently support Rust (x86_64, armv7, 70 * arm64, riscv, and loongarch) satisfy these requirements. 71 */ 72#define GEN_TRY_CMPXCHG_HELPER(tname, type, suffix) \ 73__rust_helper bool \ 74rust_helper_atomic_##tname##_try_cmpxchg##suffix(type *ptr, type *old, type new)\ 75{ \ 76 return try_cmpxchg##suffix(ptr, old, new); \ 77} 78 79#define GEN_TRY_CMPXCHG_HELPERS(tname, type) \ 80 GEN_TRY_CMPXCHG_HELPER(tname, type, ) \ 81 GEN_TRY_CMPXCHG_HELPER(tname, type, _acquire) \ 82 GEN_TRY_CMPXCHG_HELPER(tname, type, _release) \ 83 GEN_TRY_CMPXCHG_HELPER(tname, type, _relaxed) \ 84 85GEN_TRY_CMPXCHG_HELPERS(i8, s8) 86GEN_TRY_CMPXCHG_HELPERS(i16, s16) 87GEN_TRY_CMPXCHG_HELPERS(ptr, const void *)