lx 0.4.0

A no_std crate to use Linux system calls
Documentation
use core::mem::MaybeUninit;

use super::abi::*;
use crate::{
    result_from_value,
    AsRawFd,
};

/// Receives a message from a socket.
///
/// # Safety
///
/// `addr` must be a NULL pointer or a pointer to a `struct sockaddr` like structure. If `addr` is
/// a NULL pointer, then `addr_len` must be a NULL pointer as well. Otherwise, it should be a
/// pointer to an `isize` containing the size of the structure that `addr` points to.
#[inline]
pub fn recvfrom_raw(
    fd: &impl AsRawFd,
    buf: &mut [MaybeUninit<u8>],
    flags: u32,
    addr: *mut u8,
    addr_len: *mut isize,
) -> crate::Result<usize> {
    let ret = unsafe {
        syscall_6(
            45,
            fd.as_raw_fd() as usize,
            buf.as_mut_ptr() as usize,
            buf.len(),
            flags as usize,
            addr as usize,
            addr_len as usize,
        )
    };
    result_from_value(ret)
}