All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Add atomic bool support
@ 2025-12-30  4:50 FUJITA Tomonori
  2025-12-30  4:50 ` [PATCH v1 1/2] rust: sync: atomic: Add atomic bool support via i8 representation FUJITA Tomonori
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: FUJITA Tomonori @ 2025-12-30  4:50 UTC (permalink / raw)
  To: boqun.feng, ojeda
  Cc: a.hindborg, aliceryhl, bjorn3_gh, dakr, gary, lossin, tmgross,
	acourbot, rust-for-linux, linux-arch

This adds `bool` support to the Rust LKMM atomics.

Rust specifies that `bool` has size 1 and alignment 1 [1], so it can
be represented using an `i8` backing type.

Since `bool` only permits the bit patterns 0x00 and 0x01, the first
patch also documents an additional safety preconditions for unsafe
`Atomic::<T>::from_ptr`.

`from_ptr()` exists to operate on C-side storage so I don't think it
makes sense for bool. We could restrict from_ptr() via a marker trait.

[1] https://doc.rust-lang.org/reference/types/boolean.html


FUJITA Tomonori (2):
  rust: sync: atomic: Add atomic bool support via i8 representation
  rust: sync: atomic: Add atomic bool tests

 rust/kernel/sync/atomic.rs           |  1 +
 rust/kernel/sync/atomic/internal.rs  |  8 ++++++++
 rust/kernel/sync/atomic/predefine.rs | 27 +++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

base-commit: 13ade169e801a423bc1a5a5c3c6ac680a144a608
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-01-01  3:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-30  4:50 [PATCH v1 0/2] Add atomic bool support FUJITA Tomonori
2025-12-30  4:50 ` [PATCH v1 1/2] rust: sync: atomic: Add atomic bool support via i8 representation FUJITA Tomonori
2025-12-30 22:45   ` Boqun Feng
2025-12-31 12:21     ` FUJITA Tomonori
2025-12-30  4:50 ` [PATCH v1 2/2] rust: sync: atomic: Add atomic bool tests FUJITA Tomonori
2025-12-31 15:34 ` [PATCH v1 0/2] Add atomic bool support Gary Guo
2026-01-01  3:27   ` FUJITA Tomonori

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.