diff options
author | Boqun Feng <boqun.feng@gmail.com> | 2025-09-04 21:41:33 -0700 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2025-09-15 09:38:34 +0200 |
commit | d132054360baf0d127a463bbf853e43dd6eb0dd9 (patch) | |
tree | 4c867d8649c900f9aca4b5ffe530799ff12cedc0 /rust/helpers/refcount.c | |
parent | b606a532c01380ac282fd0a0858e3e8ea01ad904 (diff) |
rust: sync: atomic: Add the framework of arithmetic operations
One important set of atomic operations is the arithmetic operations,
i.e. add(), sub(), fetch_add(), add_return(), etc. However it may not
make senses for all the types that `AtomicType` to have arithmetic
operations, for example a `Foo(u32)` may not have a reasonable add() or
sub(), plus subword types (`u8` and `u16`) currently don't have
atomic arithmetic operations even on C side and might not have them in
the future in Rust (because they are usually suboptimal on a few
architecures). Therefore the plan is to add a few subtraits of
`AtomicType` describing which types have and can do atomic arithemtic
operations.
One trait `AtomicAdd` is added, and only add() and fetch_add() are
added. The rest will be added in the future.
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-7-boqun.feng@gmail.com/
Diffstat (limited to 'rust/helpers/refcount.c')
0 files changed, 0 insertions, 0 deletions