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;
3333#[ cfg( not( test) ) ]
3434#[ cfg( not( testlib) ) ]
3535mod allocator;
36+ pub mod bits;
3637mod build_assert;
3738pub mod cred;
3839pub mod device;
You can’t perform that action at this time.
0 commit comments