diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 36 |
1 files changed, 30 insertions, 6 deletions
@@ -9,12 +9,6 @@ #[macro_use] mod bitflags; -macro_rules! bit { - ( $x:expr ) => { - 1 << $x - }; -} - #[macro_use] extern crate raw_cpuid; @@ -28,6 +22,36 @@ mod std { pub use core::option; } +macro_rules! bit { + ( $x:expr ) => { + 1 << $x + }; +} + +macro_rules! check_flag { + ($doc:meta, $fun:ident, $flag:ident) => ( + #[$doc] + pub fn $fun(&self) -> bool { + self.contains($flag) + } + ) +} + +macro_rules! is_bit_set { + ($field:expr, $bit:expr) => ( + $field & (1 << $bit) > 0 + ) +} + +macro_rules! check_bit_fn { + ($doc:meta, $fun:ident, $field:ident, $bit:expr) => ( + #[$doc] + pub fn $fun(&self) -> bool { + is_bit_set!(self.$field, $bit) + } + ) +} + pub mod io; pub mod controlregs; pub mod msr; |