1#[cfg(not(feature = "std"))]
2pub use const_format::formatcp;
3#[cfg(not(feature = "std"))]
4pub use crate::no_std::{log_fn, trace_fn, panic};
5
6#[macro_export]
7#[cfg(not(feature = "std"))]
8macro_rules! log {
9 ($string:literal) => {
10 unsafe { log_fn(formatcp!("{}\n\0", $string).as_ptr()) }
11 };
12 ($format:literal, $($e:expr),+) => {
13 unsafe { log_fn(formatcp!("{}\n\0", $format).as_ptr(), $($e),+) }
14 };
15}
16
17#[macro_export]
18#[cfg(not(feature = "std"))]
19macro_rules! safe_log {
20 ($string:literal) => {
21 log_fn(formatcp!("{}\n\0", $string).as_ptr())
22 };
23 ($format:literal, $($e:expr),+) => {
24 log_fn(formatcp!("{}\n\0", $format).as_ptr(), $($e),+)
25 };
26}
27#[macro_export]
28#[cfg(feature = "std")]
29macro_rules! log {
30 ($string:literal) => {
31 println!($string)
32 };
33 ($format:literal, $($e:expr),+) => {
34 println!($format, $($e),+)
35 };
36}
37#[macro_export]
38#[cfg(feature = "std")]
39macro_rules! safe_log {
40 ($string:literal) => {
41 println!($string)
42 };
43}
44
45#[macro_export]
46#[cfg(not(feature = "std"))]
47macro_rules! trace {
48 () => {
49 unsafe { trace_fn(formatcp!("{}\0", file!()).as_ptr(), line!()) }
50 };
51}
52
53#[macro_export]
54#[cfg(feature = "std")]
55macro_rules! trace {
56 () => {
57 println!("{}:{}", file!(), line!());
58 };
59}
60
61#[macro_export]
62#[cfg(not(feature = "std"))]
63macro_rules! mc_panic {
64 ($string:literal) => {
65 unsafe { panic(formatcp!("{}\n\0", $string).as_ptr()); loop{} }
66 };
67 ($format:literal, $($e:expr),+) => {
68 unsafe { panic(formatcp!("{}\n\0", $format).as_ptr(), $($e),+); loop{} }
69 };
70}
71#[macro_export]
72#[cfg(feature = "std")]
73macro_rules! mc_panic {
74 ($string:literal) => {
75 panic!($string)
76 };
77 ($format:literal, $($e:expr),+) => {
78 panic!($format, $($e),+)
79 };
80}