[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6835eaa4.c80a0220.2baf57.d14b@mx.google.com>
Date: Tue, 27 May 2025 09:38:58 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Burak Emir <bqe@...gle.com>
Cc: Yury Norov <yury.norov@...il.com>, Kees Cook <kees@...nel.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Viresh Kumar <viresh.kumar@...aro.org>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
"Gustavo A . R . Silva" <gustavoars@...nel.org>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH v9 2/5] rust: add bindings for bitops.h
On Mon, May 26, 2025 at 03:01:31PM +0000, Burak Emir wrote:
> Makes atomic set_bit and clear_bit inline functions as well as the
> non-atomic variants __set_bit and __clear_bit available to Rust.
> Adds a new MAINTAINERS section BITOPS API BINDINGS [RUST].
>
> Suggested-by: Alice Ryhl <aliceryhl@...gle.com>
> Suggested-by: Yury Norov <yury.norov@...il.com>
> Signed-off-by: Burak Emir <bqe@...gle.com>
> Acked-by: Yury Norov [NVIDIA] <yury.norov@...il.com>
> ---
> MAINTAINERS | 5 +++++
> rust/helpers/bitops.c | 23 +++++++++++++++++++++++
> rust/helpers/helpers.c | 1 +
> 3 files changed, 29 insertions(+)
> create mode 100644 rust/helpers/bitops.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 86cae0ca5287..04d6727e944c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -4141,6 +4141,11 @@ F: include/linux/bitops.h
> F: lib/test_bitops.c
> F: tools/*/bitops*
>
> +BITOPS API BINDINGS [RUST]
> +M: Yury Norov <yury.norov@...il.com>
> +S: Maintained
> +F: rust/helpers/bitops.c
> +
> BLINKM RGB LED DRIVER
> M: Jan-Simon Moeller <jansimon.moeller@....de>
> S: Maintained
> diff --git a/rust/helpers/bitops.c b/rust/helpers/bitops.c
> new file mode 100644
> index 000000000000..1fe9e3b23a39
> --- /dev/null
> +++ b/rust/helpers/bitops.c
> @@ -0,0 +1,23 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <linux/bitops.h>
> +
> +void rust_helper___set_bit(unsigned int nr, unsigned long *addr)
Why "unsigned int" instead of "unsigned long"? The C API uses
"unsigned long" and in the Rust API, you uses "usize" for `nbits` and
`index`s, therefore using "unsigned int" only introduces unnecessary "as
u32" casting IMO, am I missing something here?
Regards,
Boqun
> +{
> + __set_bit(nr, addr);
> +}
> +
> +void rust_helper___clear_bit(unsigned int nr, unsigned long *addr)
> +{
> + __clear_bit(nr, addr);
> +}
> +
> +void rust_helper_set_bit(unsigned int nr, volatile unsigned long *addr)
> +{
> + set_bit(nr, addr);
> +}
> +
> +void rust_helper_clear_bit(unsigned int nr, volatile unsigned long *addr)
> +{
> + clear_bit(nr, addr);
> +}
> diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
> index 92721d165e35..4de8ac390241 100644
> --- a/rust/helpers/helpers.c
> +++ b/rust/helpers/helpers.c
> @@ -8,6 +8,7 @@
> */
>
> #include "bitmap.c"
> +#include "bitops.c"
> #include "blk.c"
> #include "bug.c"
> #include "build_assert.c"
> --
> 2.49.0.1151.ga128411c76-goog
>
Powered by blists - more mailing lists