Macro syscalls::syscall

source ·
macro_rules! syscall {
    ($nr:expr) => { ... };
    ($nr:expr, $a1:expr) => { ... };
    ($nr:expr, $a1:expr, $a2:expr) => { ... };
    ($nr:expr, $a1:expr, $a2:expr, $a3:expr) => { ... };
    ($nr:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr) => { ... };
    ($nr:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr) => { ... };
    ($nr:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr) => { ... };
}
Expand description

Performs a syscall and returns a Result<usize, Errno>.

Accepts a syscall number and a variable number of arguments (0 to 6).

§Returns

  • Ok on success, or
  • Err(errno) if the syscall failed.

§Example

use syscalls::{Sysno, syscall};

match unsafe { syscall!(Sysno::clone) } {
    Ok(0) => {
        // Child process
    }
    Ok(pid) => {
        // Parent process
    }
    Err(err) => {
        eprintln!("clone() failed: {}", err);
    }
}