diff --git a/src/console.rs b/src/console.rs index a1f0fd8f..1ac2edb3 100644 --- a/src/console.rs +++ b/src/console.rs @@ -6,7 +6,10 @@ pub struct Console(()); impl fmt::Write for Console { fn write_str(&mut self, s: &str) -> fmt::Result { + #[cfg(target_os = "none")] crate::arch::write_to_console(s.as_bytes()); + #[cfg(target_os = "uefi")] + uefi_services::system_table().stdout().write_str(s)?; Ok(()) } } diff --git a/src/macros.rs b/src/macros.rs index 7ee46533..4b123083 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -5,16 +5,9 @@ /// [`std::print`]: https://doc.rust-lang.org/stable/std/macro.print.html #[macro_export] macro_rules! print { - ($($arg:tt)*) => { - #[cfg(target_os = "none")] - { - $crate::_print(::core::format_args!($($arg)*)); - } - #[cfg(target_os = "uefi")] - { - ::uefi_services::print!($($arg)*); - } - }; + ($($arg:tt)*) => {{ + $crate::_print(::core::format_args!($($arg)*)); + }}; } /// Prints to the standard output, with a newline. @@ -27,16 +20,9 @@ macro_rules! println { () => { $crate::print!("\n") }; - ($($arg:tt)*) => { - #[cfg(target_os = "none")] - { - $crate::_print(::core::format_args!("{}\n", format_args!($($arg)*))); - } - #[cfg(target_os = "uefi")] - { - ::uefi_services::println!($($arg)*); - } - }; + ($($arg:tt)*) => {{ + $crate::_print(::core::format_args!("{}\n", format_args!($($arg)*))); + }}; } /// Prints and returns the value of a given expression for quick and dirty diff --git a/src/main.rs b/src/main.rs index e464b188..0ab6cc66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,6 @@ mod macros; #[cfg(target_os = "none")] mod allocator; mod arch; -#[cfg(target_os = "none")] mod console; #[cfg(target_os = "none")] mod log; @@ -26,7 +25,6 @@ mod uefi; ))] extern crate alloc; -#[cfg(target_os = "none")] #[doc(hidden)] fn _print(args: core::fmt::Arguments<'_>) { use core::fmt::Write;