oscall 0.1.0

Low-level cross-platform interface to operating system services: files, memory mapping, networking and more, with no libc on Linux
Documentation
//! aarch64: `svc 0`, number in `x8`, arguments in `x0`..`x5`.

use core::arch::asm;

macro_rules! define {
    ($name:ident $(, $arg:ident in $reg:tt)*) => {
        /// # Safety
        ///
        /// The system call and its arguments must be valid: see `syscall!`.
        #[inline]
        pub(crate) unsafe fn $name(nr: usize $(, $arg: usize)*) -> usize {
            let ret;
            // SAFETY: the caller upholds the system call's own contract.
            unsafe {
                asm!(
                    "svc 0",
                    in("x8") nr,
                    $(in($reg) $arg,)*
                    lateout("x0") ret,
                    options(nostack, preserves_flags),
                );
            }
            ret
        }
    };
}

define!(syscall0);
define!(syscall1, a in "x0");
define!(syscall2, a in "x0", b in "x1");
define!(syscall3, a in "x0", b in "x1", c in "x2");
define!(syscall4, a in "x0", b in "x1", c in "x2", d in "x3");
define!(syscall5, a in "x0", b in "x1", c in "x2", d in "x3", e in "x4");
define!(syscall6, a in "x0", b in "x1", c in "x2", d in "x3", e in "x4", f in "x5");