Skip to content

Commit

Permalink
refactor: Update print macros from kernel
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Aug 10, 2023
1 parent c03ecd0 commit 8749279
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
/// Print formatted text to our console.
/// Prints to the standard output.
///
/// From http://blog.phil-opp.com/rust-os/printing-to-screen.html, but tweaked
/// for HermitCore.
/// Adapted from [`std::print`].
///
/// [`std::print`]: https://doc.rust-lang.org/stable/std/macro.print.html
#[macro_export]
macro_rules! print {
($($arg:tt)*) => {{
$crate::_print(::core::format_args!($($arg)*));
}};
}

/// Print formatted text to our console, followed by a newline.
/// Prints to the standard output, with a newline.
///
/// Adapted from [`std::println`].
///
/// [`std::println`]: https://doc.rust-lang.org/stable/std/macro.println.html
#[macro_export]
macro_rules! println {
() => {
$crate::print!("\n")
};
($($arg:tt)*) => {{
print!("{}\n", ::core::format_args!($($arg)*))
$crate::_print(::core::format_args!("{}\n", format_args!($($arg)*)));
}};
}

Expand Down

0 comments on commit 8749279

Please sign in to comment.