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