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
macro_rules! instruction {
($fnname:ident, $asm:expr) => (
#[inline]
pub fn $fnname() {
match () {
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
() => unsafe {
asm!($asm :::: "volatile");
},
#[cfg(not(any(target_arch = "riscv32", target_arch = "riscv64")))]
() => {}
}
}
)
}
instruction!(ecall, "ecall");
instruction!(ebreak, "ebreak");
instruction!(uret, "uret");
instruction!(sret, "sret");
instruction!(mret, "mret");
instruction!(wfi, "wfi");