/// 64-bit RISC-V implementations of the syscall macro
#[macro_export]
macro_rules! syscall {
    ($num:expr $(,)?) => {{
        let mut a0 = usize::from($num);
        core::arch::asm!("ecall", inlateout("a0") a0);
        a0
    }};
    ($num:expr, $a1:expr $(,)?) => {{
        let mut a0 = usize::from($num);
        core::arch::asm!("ecall", inlateout("a0") a0, in("a1") $a1);
        a0
    }};
    ($num:expr, $a1:expr, $a2:expr $(,)?) => {{
        let mut a0 = usize::from($num);
        core::arch::asm!("ecall", inlateout("a0") a0, in("a1") $a1, in("a2") $a2);
        a0
    }};
    ($num:expr, $a1:expr, $a2:expr, $a3:expr $(,)?) => {{
        let mut a0 = usize::from($num);
        core::arch::asm!("ecall", inlateout("a0") a0, in("a1") $a1, in("a2") $a2, in("a3") $a3);
        a0
    }};
    ($num:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr $(,)?) => {{
        let mut a0 = usize::from($num);
        core::arch::asm!(
            "ecall",
            inlateout("a0") a0,
            in("a1") $a1, in("a2") $a2, in("a3") $a3, in("a4") $a4
        );
        a0
    }};
    ($num:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr $(,)?) => {{
        let mut a0 = usize::from($num);
        core::arch::asm!(
            "ecall",
            inlateout("a0") a0,
            in("a1") $a1, in("a2") $a2, in("a3") $a3, in("a4") $a4, in("a5") $a5
        );
        a0
    }};
    ($num:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr $(,)?) => {{
        let mut a0 = usize::from($num);
        core::arch::asm!(
            "ecall",
            inlateout("a0") a0,
            in("a1") $a1, in("a2") $a2, in("a3") $a3, in("a4") $a4, in("a5") $a5, in("a6") $a6
        );
        a0
    }};
}
