Expand description
Convert values to ArgReg
and from RetReg
.
System call arguments and return values are all communicated with inline
asm and FFI as *mut Opaque
. To protect these raw pointers from escaping
or being accidentally misused as they travel through the code, we wrap them
in ArgReg
and RetReg
structs. This file provides From
implementations and explicit conversion functions for converting values
into and out of these wrapper structs.
Β§Safety
Some of this code is unsafe
in order to work with raw file descriptors,
and some is unsafe
to interpret the values in a RetReg
.
ModulesΒ§
- fs π
FunctionsΒ§
- by_mut π
- by_ref π
- c_int π
- Convert a
c_int
into anArgReg
. - c_uint π
- Convert a
c_uint
into anArgReg
. - dev_t π
- loff_t π
- loff_
t_ πfrom_ u64 - negative_
pid π - no_fd π
- Deliberately pass
-1
to a file-descriptor argument, for system calls likemmap
where this indicates the argument is omitted. - opt_mut π
- Convert an optional mutable reference into a
usize
for passing to a syscall. - opt_ref π
- Convert an optional immutable reference into a
usize
for passing to a syscall. - pass_
usize π - Pass an arbitrary
usize
value. - raw_fd π β
- Pass a raw file-descriptor argument. Most users should use
ArgReg::from
instead, to preserve I/O safety as long as possible. - ret π β
- Convert a
usize
returned from a syscall that effectively returns()
on success. - ret_
c_ πint - Convert a
usize
returned from a syscall that effectively returns ac_int
on success. - ret_
c_ π βint_ infallible - Convert a
c_int
returned from a syscall that effectively always returns ac_int
. - ret_
c_ πuint - Convert a
usize
returned from a syscall that effectively returns ac_uint
on success. - ret_
c_ π βuint_ infallible - Convert a
c_uint
returned from a syscall that effectively always returns ac_uint
. - ret_
discarded_ π βfd - Convert the return value of
dup2
anddup3
. - ret_
error π β - Convert a
usize
returned from a syscall that doesnβt return on success. - ret_
infallible π β - Convert a
usize
returned from a syscall that effectively always returns()
. - ret_
owned_ π βfd - Convert a
usize
returned from a syscall that effectively returns anOwnedFd
on success. - ret_u64 π
- Convert a
usize
returned from a syscall that effectively returns au64
on success. - ret_
usize π - Convert a
usize
returned from a syscall that effectively returns ausize
on success. - ret_
usize_ π βinfallible - Convert a
usize
returned from a syscall that effectively always returns ausize
. - ret_
void_ πstar - Convert a
usize
returned from a syscall that effectively returns a*mut c_void
on success. - size_of π
- Pass the
mem::size_of
of a type. - slice π
- slice_
just_ πaddr - slice_
just_ πaddr_ mut - slice_
mut π - socklen_
t π - zero π
- Pass a zero, or null, argument.