#[macro_export]
macro_rules! print {
($($arg:tt)*) => {{
$crate::_print(::core::format_args!($($arg)*));
}};
}
#[macro_export]
macro_rules! println {
() => {
$crate::print!("\n")
};
($($arg:tt)*) => {{
$crate::_print(::core::format_args!("{}\n", format_args!($($arg)*)));
}};
}
#[macro_export]
macro_rules! dbg {
() => {
$crate::println!("[{}:{}]", ::core::file!(), ::core::line!())
};
($val:expr $(,)?) => {
match $val {
tmp => {
$crate::println!("[{}:{}] {} = {:#?}",
::core::file!(), ::core::line!(), ::core::stringify!($val), &tmp);
tmp
}
}
};
($($val:expr),+ $(,)?) => {
($($crate::dbg!($val)),+,)
};
}
#[allow(unused_macro_rules)]
#[cfg(not(feature = "newlib"))]
macro_rules! kernel_function {
($f:ident()) => {
$crate::arch::switch::kernel_function0($f)
};
($f:ident($arg1:expr)) => {
$crate::arch::switch::kernel_function1($f, $arg1)
};
($f:ident($arg1:expr, $arg2:expr)) => {
$crate::arch::switch::kernel_function2($f, $arg1, $arg2)
};
($f:ident($arg1:expr, $arg2:expr, $arg3:expr)) => {
$crate::arch::switch::kernel_function3($f, $arg1, $arg2, $arg3)
};
($f:ident($arg1:expr, $arg2:expr, $arg3:expr, $arg4:expr)) => {
$crate::arch::switch::kernel_function4($f, $arg1, $arg2, $arg3, $arg4)
};
($f:ident($arg1:expr, $arg2:expr, $arg3:expr, $arg4:expr, $arg5:expr)) => {
$crate::arch::switch::kernel_function5($f, $arg1, $arg2, $arg3, $arg4, $arg5)
};
($f:ident($arg1:expr, $arg2:expr, $arg3:expr, $arg4:expr, $arg5:expr, $arg6:expr)) => {
$crate::arch::switch::kernel_function6($f, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6)
};
}
#[cfg(all(target_arch = "x86_64", feature = "newlib"))]
macro_rules! kernel_function {
($f:ident($($x:tt)*)) => {{
$f($($x)*)
}};
}
#[allow(unused_macros)]
macro_rules! hermit_var {
($name:expr) => {{
use alloc::borrow::Cow;
match crate::env::var($name) {
Some(val) => Some(Cow::from(val)),
None => option_env!($name).map(Cow::Borrowed),
}
}};
}
#[allow(unused_macros)]
macro_rules! hermit_var_or {
($name:expr, $default:expr) => {{
hermit_var!($name).as_deref().unwrap_or($default)
}};
}