[][src]Macro scall::syscall_raw

macro_rules! syscall_raw {
    ($nr:ident) => { ... };
    ($nr:ident, $a1:expr) => { ... };
    ($nr:ident, $a1:expr, $a2:expr) => { ... };
    ($nr:ident, $a1:expr, $a2:expr, $a3:expr) => { ... };
    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr) => { ... };
    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr) => { ... };
    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr) => { ... };
    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr, $a7:expr) => { ... };
    ($nr:ident, $($args:expr,)*) => { ... };
}

Make a syscall, and return the direct result (platform-specific).

On Linux, this returns a usize representing the return value of the syscall (if an error occurred, the error code is encoded into the result). On macOS and FreeBSD, it returns a (usize, bool) tuple indicating 1) the return value and 2) whether an error occurred. (RawResult is an alias for this type, and it can be "decoded" with decode_raw_result().)

Note: syscall! should be preferred for most purposes. However, this macro may be useful in 2 cases:

  1. The syscall will never fail (like sync()) or you don't care about the result (like possibly close()).

    Since syscall! returns an Result<usize, i32> and Result is annotated with #[must_use], using syscall_raw! will simplify things slightly -- i.e. syscall_raw!(SYNC) instead of drop(syscall!(SYNC)) to avoid the compiler complaining.

  2. You need to make a series of syscalls quickly, then check the return values.

    In this case, you can call syscall_raw!, store the RawResults from each, and then decode and check them with decode_raw_result().