Re: [PATCH v6] rust: kernel: add support for bits/genmask macros
From: Miguel Ojeda
Date: Tue Jun 10 2025 - 14:09:12 EST
On Tue, Jun 10, 2025 at 4:16 PM Daniel Almeida
<daniel.almeida@xxxxxxxxxxxxx> wrote:
>
> +use crate::build_assert;
You can include the prelude instead.
> + (1 as $ty) .checked_shl(n)
Formatting.
> + pub fn $unbounded_name(n: u32) -> $ty {
We may want to have a comment inside here to remind ourselves to
forward the call to the standard library one when available (1.87.0).
> + /// Creates a compile-time contiguous bitmask for the given range by
> + /// validating the range at runtime.
I may be confused by what you are trying to do here, but how are these
`checked` and `unbounded` ones compile-time?
Also, you can probably simplify the macro `impl` calls by removing
parameters by using `paste!`, e.g.
let high = ::kernel::macros::paste!([<checked_bit_ $ty>])(range.end)?;
> base-commit: cf25bc61f8aecad9b0c45fe32697e35ea4b13378
This is a fairly old base now (the patch does not apply cleanly).
Thanks!
Cheers,
Miguel