lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 30 Jan 2024 13:59:16 -0600
From: Carlos Bilbao <carlos.bilbao@....com>
To: Christina Quast <contact@...istina-quast.de>,
 Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
 Wedson Almeida Filho <wedsonaf@...il.com>, Boqun Feng
 <boqun.feng@...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@...sung.com>, Alice Ryhl <aliceryhl@...gle.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rust: prelude: add bit function

On 1/30/24 13:47, Christina Quast wrote:
> In order to create masks easily, the define BIT() is used in C code.
> This commit adds the same functionality to the rust kernel.
> 
> To use it, include the following into your rust file:
> use kernel::prelude::bit
> 
> Signed-off-by: Christina Quast <contact@...istina-quast.de>

Reviewed-by: Carlos Bilbao <carlos.bilbao@....com>

> ---
> This patch is needed for further patches porting the rockchip phy
> driver to rust.
> ---
>   rust/kernel/prelude.rs | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
> 
> diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs
> index ae21600970b3..16e483de2f27 100644
> --- a/rust/kernel/prelude.rs
> +++ b/rust/kernel/prelude.rs
> @@ -38,3 +38,19 @@
>   pub use super::init::{InPlaceInit, Init, PinInit};
>   
>   pub use super::current;
> +
> +/// Returns a `u32` number that has only the `n`th bit set.
> +///
> +/// # Arguments
> +///
> +/// * `n` - A `u32` that specifies the bit position (zero-based index)
> +///
> +/// # Example
> +///
> +/// ```
> +/// let b = bit(2);
> +/// assert_eq!(b, 4);
> +#[inline]
> +pub const fn bit(n: u32) -> u32 {
> +    1 << n
> +}
> 
> ---
> base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
> change-id: 20240130-rust-bit-99dd6d3a0536
> 
> Best regards,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ