lx 0.4.0

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

use super::abi::*;
use crate::{
    Error,
    OwnedFd,
};

#[inline]
pub fn socketpair(family: i32, type_: i32, protocol: i32) -> crate::Result<(OwnedFd, OwnedFd)> {
    let mut sockets: [MaybeUninit<i32>; 2] = [MaybeUninit::uninit(); 2];
    let ret = unsafe {
        syscall_4(
            53,
            family as usize,
            type_ as usize,
            protocol as usize,
            sockets.as_mut_ptr() as usize,
        ) as i32
    };
    if let Ok(err) = Error::try_from(ret) {
        return Err(err);
    }
    let first = OwnedFd::new(unsafe { sockets[0].assume_init() });
    let second = OwnedFd::new(unsafe { sockets[1].assume_init() });
    Ok((first, second))
}