lx 0.4.0

A no_std crate to use Linux system calls
Documentation
//! A `no_std` interface to the userspace Linux ABI designed to have no overhead, but still be safe
//! when possible by leveraging Rust's type system.
//!
//! # Result overhead
//!
//! Although types like `Result<(), i32>` are sometimes used in place of the smaller `i32` which
//! can both represent errors and values on success, it doesn't add memory overhead or register
//! pressure in practice because functions are inlined.
//!
//! To verify this, try to look at the assembler generated by this code when optimizations are
//! enabled:
//!
//! ```no_run
//! extern "C" {
//!     fn fallible() -> i32;
//!
//!     fn test_succeeded();
//!     fn test_failed(err: i32);
//! }
//!
//! fn fallible_safe() -> Result<(), i32> {
//!     let ret = unsafe { fallible() };
//!     if ret < 0 {
//!         return Err(ret);
//!     }
//!     Ok(())
//! }
//!
//! pub fn test() {
//!     if let Err(e) = fallible_safe() {
//!         unsafe { test_failed(e) };
//!         return;
//!     }
//!     unsafe { test_succeeded() };
//! }
//! ```
#![no_std]
#![feature(allocator_api)]
#![feature(extern_types)]
#![feature(never_type)]

mod auto_unmount;
mod cstr_array;
mod error;
mod fd;
pub mod ioctl;
mod mmap_alloc;
mod net;
mod print_macros;
mod spawn;
mod start;
mod syscalls;

pub use auto_unmount::*;
pub use cstr_array::CStrArray;
pub use error::*;
pub use fd::*;
pub use mmap_alloc::*;
pub use net::*;
pub use print_macros::*;
pub use spawn::*;
pub use start::*;
pub use syscalls::*;

pub const FD_CLOEXEC: i32 = 1;

pub const SIGTERM: i32 = 15;
pub const SIGCHLD: i32 = 17;

pub const SOL_SOCKET: i32 = 1;

pub const SCM_RIGHTS: i32 = 1;

pub const MSG_DONTWAIT: u32 = 0x40;

pub const SIG_BLOCK: i32 = 0;

pub const PAGE_SIZE: usize = 0x1000;

#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct iovec {
    pub iov_base: *mut u8,
    pub iov_len: usize,
}

#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct timespec {
    pub tv_sec: i64,
    pub tv_nsec: i64,
}

#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct timeval {
    pub tv_sec: i64,
    pub tv_usec: i64,
}

#[allow(non_camel_case_types)]
pub type sigset_t = usize;

#[allow(non_camel_case_types)]
pub type uid_t = u32;

#[allow(non_camel_case_types)]
pub type gid_t = u32;

#[allow(non_camel_case_types)]
pub type pid_t = i32;