cortex_m_semihosting/
macros.rs1#[macro_export]
3macro_rules! syscall {
4 ($nr:ident) => {
5 $crate::syscall1($crate::nr::$nr, 0)
6 };
7 ($nr:ident, $a1:expr) => {
8 $crate::syscall($crate::nr::$nr, &[$a1 as usize])
9 };
10 ($nr:ident, $a1:expr, $a2:expr) => {
11 $crate::syscall($crate::nr::$nr, &[$a1 as usize, $a2 as usize])
12 };
13 ($nr:ident, $a1:expr, $a2:expr, $a3:expr) => {
14 $crate::syscall($crate::nr::$nr, &[$a1 as usize, $a2 as usize, $a3 as usize])
15 };
16 ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr) => {
17 $crate::syscall(
18 $crate::nr::$nr,
19 &[$a1 as usize, $a2 as usize, $a3 as usize, $a4 as usize],
20 )
21 };
22}
23
24#[macro_export]
26macro_rules! syscall1 {
27 ($nr:ident, $a1:expr) => {
28 $crate::syscall1($crate::nr::$nr, $a1 as usize)
29 };
30}
31
32#[macro_export]
37macro_rules! hprint {
38 ($s:expr) => {
39 $crate::export::hstdout_str($s)
40 };
41 ($($tt:tt)*) => {
42 $crate::export::hstdout_fmt(format_args!($($tt)*))
43 };
44}
45
46#[macro_export]
51macro_rules! hprintln {
52 () => {
53 $crate::export::hstdout_str("\n")
54 };
55 ($s:expr) => {
56 $crate::export::hstdout_str(concat!($s, "\n"))
57 };
58 ($s:expr, $($tt:tt)*) => {
59 $crate::export::hstdout_fmt(format_args!(concat!($s, "\n"), $($tt)*))
60 };
61}
62
63#[macro_export]
68macro_rules! heprint {
69 ($s:expr) => {
70 $crate::export::hstderr_str($s)
71 };
72 ($($tt:tt)*) => {
73 $crate::export::hstderr_fmt(format_args!($($tt)*))
74 };
75}
76
77#[macro_export]
82macro_rules! heprintln {
83 () => {
84 $crate::export::hstderr_str("\n")
85 };
86 ($s:expr) => {
87 $crate::export::hstderr_str(concat!($s, "\n"))
88 };
89 ($s:expr, $($tt:tt)*) => {
90 $crate::export::hstderr_fmt(format_args!(concat!($s, "\n"), $($tt)*))
91 };
92}
93
94#[macro_export]
100macro_rules! dbg {
101 () => {
102 $crate::heprintln!("[{}:{}]", file!(), line!());
103 };
104 ($val:expr) => {
105 match $val {
108 tmp => {
109 $crate::heprintln!("[{}:{}] {} = {:#?}",
110 file!(), line!(), stringify!($val), &tmp);
111 tmp
112 }
113 }
114 };
115 ($val:expr,) => { $crate::dbg!($val) };
117 ($($val:expr),+ $(,)?) => {
118 ($($crate::dbg!($val)),+,)
119 };
120}