We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b087b60 commit 1cf952dCopy full SHA for 1cf952d
rust/kernel/bits.rs
@@ -0,0 +1,12 @@
1
+// SPDX-License-Identifier: GPL-2.0
2
+
3
+//! Bit manipulation helpers
4
+//!
5
+//! C header: [`include/linux/bits.h`](srctree/include/linux/bits.h)
6
7
+/// Generate a mask where all bits >= `h` and <= `l` are set
8
+///
9
+/// This is a re-implementation in rust of `GENMASK`
10
+pub const fn genmask(h: u32, l: u32) -> u32 {
11
+ ((!0u32) - (1 << l) + 1) & ((!0u32) >> (32 - 1 - h))
12
+}
rust/kernel/lib.rs
@@ -35,6 +35,7 @@ compile_error!("Missing kernel configuration for conditional compilation");
35
extern crate self as kernel;
36
37
pub mod alloc;
38
+pub mod bits;
39
#[cfg(CONFIG_BLOCK)]
40
pub mod block;
41
mod build_assert;
0 commit comments