Module rustix::backend::conv

source Β·
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 an ArgReg.
  • c_uint πŸ”’
    Convert a c_uint into an ArgReg.
  • dev_t πŸ”’
  • loff_t πŸ”’
  • loff_t_from_u64 πŸ”’
  • negative_pid πŸ”’
  • no_fd πŸ”’
    Deliberately pass -1 to a file-descriptor argument, for system calls like mmap where this indicates the argument is omitted.
  • opt_mut πŸ”’
    Convert an optional mutable 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 a c_int on success.
  • ret_c_int_infallible πŸ”’ ⚠
    Convert a c_int returned from a syscall that effectively always returns a c_int.
  • ret_c_uint πŸ”’
    Convert a usize returned from a syscall that effectively returns a c_uint on success.
  • ret_c_uint_infallible πŸ”’ ⚠
    Convert a c_uint returned from a syscall that effectively always returns a c_uint.
  • ret_discarded_fd πŸ”’ ⚠
    Convert the return value of dup2 and dup3.
  • 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 an OwnedFd on success.
  • ret_u64 πŸ”’
    Convert a usize returned from a syscall that effectively returns a u64 on success.
  • ret_usize πŸ”’
    Convert a usize returned from a syscall that effectively returns a usize on success.
  • ret_usize_infallible πŸ”’ ⚠
    Convert a usize returned from a syscall that effectively always returns a usize.
  • 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_mut πŸ”’
  • socklen_t πŸ”’
  • zero πŸ”’
    Pass a zero, or null, argument.