From 9f448fbe0e252e8541987ed83e3242b41cf93b61 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 12 Apr 2017 19:36:32 +0200 Subject: [PATCH] Avoid deadlock on nested `print!` invokation --- src/vga_buffer.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/vga_buffer.rs b/src/vga_buffer.rs index 0b95624..f36b9cd 100644 --- a/src/vga_buffer.rs +++ b/src/vga_buffer.rs @@ -126,9 +126,7 @@ impl fmt::Write for Writer { macro_rules! print { ($($arg:tt)*) => ({ - use core::fmt::Write; - let mut writer = $crate::vga_buffer::WRITER.lock(); - writer.write_fmt(format_args!($($arg)*)).unwrap(); + $crate::vga_buffer::print(format_args!($($arg)*)); }); } @@ -137,6 +135,11 @@ macro_rules! println { ($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*)); } +pub fn print(args: fmt::Arguments) { + use core::fmt::Write; + WRITER.lock().write_fmt(args).unwrap(); +} + pub fn clear_screen() { for _ in 0..BUFFER_HEIGHT { println!("");