增加内核日志功能 #3

Merged
pointer-to-bios merged 17 commits from pointer-to-bios/metaverse-dev:main into main 2024-02-05 22:10:26 +08:00
3 changed files with 1 additions and 42 deletions
Showing only changes of commit da4c7807b3 - Show all commits

View File

@ -1,8 +1,6 @@
use core::{cmp::Ordering, ops::Sub, time::Duration};
use alloc::string::ToString;
use crate::format;
use alloc::{format, string::ToString};
extern "C" {
fn system_time_get() -> usize;

View File

@ -1,38 +0,0 @@
use alloc::string::{String, ToString};
#[macro_export]
macro_rules! format {
( $s : expr, $( $e : expr ),* ) => {{
use crate::libk::string::format::Format;
let mut res = $s.to_string();
$(
res.format($e);
)*
res
}};
() => {};
}
pub trait Format<T: ToString> {
fn format(&mut self, f: T);
}
impl<T: ToString> Format<T> for String {
fn format(&mut self, f: T) {
let mut res = String::new();
let mut formatting = false;
for c in self.chars().into_iter() {
if c == '{' {
formatting = true;
res += &f.to_string();
} else if c == '}' {
formatting = false;
}
if !formatting {
res.push(c);
}
}
self.clear();
self.push_str(&res);
}
}

View File

@ -1 +0,0 @@
pub mod format;