new: rust下的kdebug kinfo kwarn kBUG kerror宏 (#86)

* new: rust下的kdebug kinfo kwarn kBUG kerror宏
This commit is contained in:
login 2022-11-18 16:32:15 +08:00 committed by GitHub
parent c6174797dc
commit 0bfe94f46b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 11 deletions

View File

@ -12,8 +12,7 @@ typedef uint32_t uid_t;
typedef uint32_t gid_t;
typedef long long ssize_t;
typedef int __pid_t;
#define pid_t int64_t
typedef int64_t pid_t;
typedef __SIZE_TYPE__ size_t;
typedef char *caddr_t;

View File

@ -43,3 +43,44 @@ macro_rules! printk_color {
$crate::libs::printk::PrintkWriter.__write_string_color($FRcolor, $BKcolor, alloc::fmt::format(format_args!($($arg)*)).as_str())
};
}
#[macro_export]
macro_rules! kdebug {
($($arg:tt)*) => {
$crate::libs::printk::PrintkWriter.__write_string((alloc::fmt::format(format_args!("[ DEBUG ] ({}:{})\t", file!(), line!()))+
alloc::fmt::format(format_args!($($arg)*)).as_str() + "\n").as_str())
}
}
#[macro_export]
macro_rules! kinfo {
($($arg:tt)*) => {
$crate::libs::printk::PrintkWriter.__write_string((alloc::string::String::from("[ INFO ] ")+ alloc::fmt::format(format_args!($($arg)*)).as_str() + "\n").as_str())
}
}
#[macro_export]
macro_rules! kwarn {
($($arg:tt)*) => {
$crate::libs::printk::PrintkWriter.__write_string_color($crate::include::DragonOS::printk::COLOR_YELLOW, $crate::include::DragonOS::printk::COLOR_BLACK, "[ WARN ] ");
$crate::libs::printk::PrintkWriter.__write_string((alloc::fmt::format(format_args!($($arg)*)) + "\n").as_str())
}
}
#[macro_export]
macro_rules! kerror {
($($arg:tt)*) => {
$crate::libs::printk::PrintkWriter.__write_string_color($crate::include::DragonOS::printk::COLOR_RED, $crate::include::DragonOS::printk::COLOR_BLACK, "[ ERROR ] ");
$crate::libs::printk::PrintkWriter.__write_string((alloc::fmt::format(format_args!("({}:{})\t", file!(), line!())) +
alloc::fmt::format(format_args!($($arg)*)).as_str() + "\n").as_str())
}
}
#[macro_export]
macro_rules! kBUG {
($($arg:tt)*) => {
$crate::libs::printk::PrintkWriter.__write_string_color($crate::include::DragonOS::printk::COLOR_RED, $crate::include::DragonOS::printk::COLOR_BLACK, "[ BUG ] ");
$crate::libs::printk::PrintkWriter.__write_string((alloc::fmt::format(format_args!("({}:{})\t", file!(), line!())) +
alloc::fmt::format(format_args!($($arg)*)).as_str() + "\n").as_str())
}
}

View File

@ -12,8 +12,7 @@ typedef uint32_t uid_t;
typedef uint32_t gid_t;
typedef long long ssize_t;
typedef int __pid_t;
#define pid_t __pid_t
typedef int64_t pid_t;
typedef __SIZE_TYPE__ size_t;
typedef char *caddr_t;