File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ extern crate self as kernel;
33
33
#[ cfg( not( test) ) ]
34
34
#[ cfg( not( testlib) ) ]
35
35
mod allocator;
36
+ pub mod bits;
36
37
mod build_assert;
37
38
pub mod cred;
38
39
pub mod device;
You can’t perform that action at this time.
0 commit comments