We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 80f308b commit 22d143eCopy full SHA for 22d143e
2 files changed
rust/kernel/bits.rs
@@ -0,0 +1,16 @@
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
+//use crate::static_assert;
8
9
+/// Generate a mask where all bits >= `h` and <= `l` are set
10
+///
11
+/// This is a re-implementation in rust of `GENMASK`
12
+pub const fn genmask(h: u32, l: u32) -> u32 {
13
+ //static_assert!(h >= l);
14
+ //static_assert!(h < 32);
15
+ ((!0u32) - (1 << l) + 1) & ((!0u32) >> (32 - 1 - h))
16
+}
rust/kernel/lib.rs
@@ -33,6 +33,7 @@ extern crate self as kernel;
33
#[cfg(not(test))]
34
#[cfg(not(testlib))]
35
mod allocator;
36
+pub mod bits;
37
mod build_assert;
38
pub mod cred;
39
pub mod device;
0 commit comments