[−][src]Macro scall::syscall_raw
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:
-
The syscall will never fail (like
sync()
) or you don't care about the result (like possiblyclose()
).Since
syscall!
returns anResult<usize, i32>
andResult
is annotated with#[must_use]
, usingsyscall_raw!
will simplify things slightly -- i.e.syscall_raw!(SYNC)
instead ofdrop(syscall!(SYNC))
to avoid the compiler complaining. -
You need to make a series of syscalls quickly, then check the return values.
In this case, you can call
syscall_raw!
, store theRawResult
s from each, and then decode and check them withdecode_raw_result()
.