Serge Bazanski | 8198136 | 2021-03-06 13:08:00 +0100 | [diff] [blame] | 1 | // Wrappers around hprint(ln) that get disabled during release builds. This prevents us from |
| 2 | // getting stuck in an hprint when a debugger is detached. |
| 3 | |
| 4 | #[cfg(debug_assertions)] |
| 5 | #[macro_export] |
| 6 | macro_rules! hprint { |
| 7 | ($s:expr) => { |
| 8 | cortex_m_semihosting::export::hstdout_str($s) |
| 9 | }; |
| 10 | ($($tt:tt)*) => { |
| 11 | cortex_m_semihosting::export::hstdout_fmt(format_args!($($tt)*)) |
| 12 | }; |
| 13 | } |
| 14 | #[cfg(debug_assertions)] |
| 15 | #[macro_export] |
| 16 | macro_rules! hprintln { |
| 17 | () => { |
| 18 | cortex_m_semihosting::export::hstdout_str("\n") |
| 19 | }; |
| 20 | ($s:expr) => { |
| 21 | cortex_m_semihosting::export::hstdout_str(concat!($s, "\n")) |
| 22 | }; |
| 23 | ($s:expr, $($tt:tt)*) => { |
| 24 | cortex_m_semihosting::export::hstdout_fmt(format_args!(concat!($s, "\n"), $($tt)*)) |
| 25 | }; |
| 26 | } |
| 27 | |
| 28 | #[cfg(not(debug_assertions))] |
| 29 | #[macro_export] |
| 30 | macro_rules! hprint { |
| 31 | () => { Result::<(), ()>::Ok(()) }; |
| 32 | ($s:expr, $($tt:tt)*) => { Result::<(), ()>::Ok(()) }; |
| 33 | } |
| 34 | #[cfg(not(debug_assertions))] |
| 35 | #[macro_export] |
| 36 | macro_rules! hprintln { |
| 37 | () => { Result::<(), ()>::Ok(()) }; |
| 38 | ($s:expr) => { Result::<(), ()>::Ok(()) }; |
| 39 | ($s:expr, $($tt:tt)*) => { Result::<(), ()>::Ok(()) }; |
| 40 | } |