Skip to content

Commit bd36f6e

Browse files
committed
rust: sync: atomic: Provide stub for rusttest 32-bit hosts
For arm32, on a x86_64 builder, running the `rusttest` target yields: error[E0080]: evaluation of constant value failed --> rust/kernel/static_assert.rs:37:23 | 37 | const _: () = ::core::assert!($condition $(,$arg)?); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: size_of::<isize>() == size_of::<isize_atomic_repr>()', rust/kernel/sync/atomic/predefine.rs:68:1 | ::: rust/kernel/sync/atomic/predefine.rs:68:1 | 68 | static_assert!(size_of::<isize>() == size_of::<isize_atomic_repr>()); | -------------------------------------------------------------------- in this macro invocation | = note: this error originates in the macro `::core::assert` which comes from the expansion of the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info) The reason is that `rusttest` runs on the host, so for e.g. a x86_64 builder `isize` is 64 bits but it is not a `CONFIG_64BIT` build. Fix it by providing a stub for `rusttest` as usual. Fixes: 84c6d36 ("rust: sync: atomic: Add Atomic<{usize,isize}>") Cc: stable@vger.kernel.org Reviewed-by: Onur Özkan <work@onurozkan.dev> Acked-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20260123233432.22703-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent a44bfed commit bd36f6e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

rust/kernel/sync/atomic/predefine.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,23 @@ unsafe impl super::AtomicAdd<i64> for i64 {
3535
// as `isize` and `usize`, and `isize` and `usize` are always bi-directional transmutable to
3636
// `isize_atomic_repr`, which also always implements `AtomicImpl`.
3737
#[allow(non_camel_case_types)]
38+
#[cfg(not(testlib))]
3839
#[cfg(not(CONFIG_64BIT))]
3940
type isize_atomic_repr = i32;
4041
#[allow(non_camel_case_types)]
42+
#[cfg(not(testlib))]
4143
#[cfg(CONFIG_64BIT)]
4244
type isize_atomic_repr = i64;
4345

46+
#[allow(non_camel_case_types)]
47+
#[cfg(testlib)]
48+
#[cfg(target_pointer_width = "32")]
49+
type isize_atomic_repr = i32;
50+
#[allow(non_camel_case_types)]
51+
#[cfg(testlib)]
52+
#[cfg(target_pointer_width = "64")]
53+
type isize_atomic_repr = i64;
54+
4455
// Ensure size and alignment requirements are checked.
4556
static_assert!(size_of::<isize>() == size_of::<isize_atomic_repr>());
4657
static_assert!(align_of::<isize>() == align_of::<isize_atomic_repr>());

0 commit comments

Comments
 (0)