mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 02:46:47 +00:00
new: rust下的kdebug kinfo kwarn kBUG kerror宏 (#86)
* new: rust下的kdebug kinfo kwarn kBUG kerror宏
This commit is contained in:
parent
c6174797dc
commit
0bfe94f46b
@ -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;
|
||||
|
@ -5,19 +5,19 @@ pub const COLOR_WHITE: u32 = 0x00ffffff;
|
||||
/// 黑色
|
||||
pub const COLOR_BLACK: u32 = 0x00000000;
|
||||
/// 红色
|
||||
pub const COLOR_RED:u32 = 0x00ff0000;
|
||||
pub const COLOR_RED: u32 = 0x00ff0000;
|
||||
/// 橙色
|
||||
pub const COLOR_ORANGE:u32 = 0x00ff8000;
|
||||
pub const COLOR_ORANGE: u32 = 0x00ff8000;
|
||||
/// 黄色
|
||||
pub const COLOR_YELLOW:u32 = 0x00ffff00;
|
||||
pub const COLOR_YELLOW: u32 = 0x00ffff00;
|
||||
/// 绿色
|
||||
pub const COLOR_GREEN:u32 = 0x0000ff00;
|
||||
pub const COLOR_GREEN: u32 = 0x0000ff00;
|
||||
/// 蓝色
|
||||
pub const COLOR_BLUE:u32 = 0x000000ff;
|
||||
pub const COLOR_BLUE: u32 = 0x000000ff;
|
||||
/// 靛色
|
||||
pub const COLOR_INDIGO:u32 = 0x0000ffff;
|
||||
pub const COLOR_INDIGO: u32 = 0x0000ffff;
|
||||
/// 紫色
|
||||
pub const COLOR_PURPLE:u32 = 0x008000ff;
|
||||
pub const COLOR_PURPLE: u32 = 0x008000ff;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! print {
|
||||
@ -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())
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user