Skip to content

Commit

Permalink
refac(vga::kinfo): move attempt!() macro to VGA crate from kernel
Browse files Browse the repository at this point in the history
So that it can be used elsewhere.
  • Loading branch information
hawkw committed May 29, 2017
1 parent 8f0dbdc commit 92a2c39
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
26 changes: 0 additions & 26 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,6 @@ pub mod logger;

use params::InitParams;

macro_rules! attempt {
($task:expr => $msg:expr, dots: $dots:expr) => {
{
print!("{}{}", $dots, $msg);
match $task {
Ok(result) => {
println!( "{:indent$}{res:}"
, ""
, indent = 70 - concat!($dots,$msg).len()
, res = "[ OKAY ]");
info!("{} [ OKAY ]", $msg);
result
}
, Err(why) => {
println!( "{:indent$}{res:}"
, ""
, indent = 70 - concat!($dots,$msg).len()
, res = "[ FAIL ]");
panic!("{:?}", why);
}
}
}

};
}

/// SOS version number
pub const VERSION_STRING: &'static str
= concat!("Stupid Operating System v", env!("CARGO_PKG_VERSION"));
Expand Down
27 changes: 27 additions & 0 deletions vga/src/kinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@
//
//! Macros for kernel-level logging
#[macro_export]
macro_rules! attempt {
($task:expr => $msg:expr, dots: $dots:expr) => {
{
print!("{}{}", $dots, $msg);
match $task {
Ok(result) => {
println!( "{:indent$}{res:}"
, ""
, indent = 70 - concat!($dots,$msg).len()
, res = "[ OKAY ]");
info!("{} [ OKAY ]", $msg);
result
}
, Err(why) => {
println!( "{:indent$}{res:}"
, ""
, indent = 70 - concat!($dots,$msg).len()
, res = "[ FAIL ]");
panic!("{:?}", why);
}
}
}

};
}

#[macro_export]
macro_rules! kinfo {
( dots: $dots:expr, target: $target:expr, $status:expr ) => {
Expand Down

0 comments on commit 92a2c39

Please sign in to comment.