diff --git a/kernel/src/common/sys/types.h b/kernel/src/common/sys/types.h index 8698631c..e09a7b57 100644 --- a/kernel/src/common/sys/types.h +++ b/kernel/src/common/sys/types.h @@ -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; diff --git a/kernel/src/include/DragonOS/printk.rs b/kernel/src/include/DragonOS/printk.rs index a7aa30ab..81990bc3 100644 --- a/kernel/src/include/DragonOS/printk.rs +++ b/kernel/src/include/DragonOS/printk.rs @@ -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()) + } +} \ No newline at end of file diff --git a/user/libs/libc/sys/types.h b/user/libs/libc/sys/types.h index 5efae368..599deb64 100644 --- a/user/libs/libc/sys/types.h +++ b/user/libs/libc/sys/types.h @@ -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;