#![doc = include_str!("../README.md")]
#![no_std]
#![feature(thread_local)] #![feature(c_variadic)] #![cfg_attr(feature = "use-compiler-builtins", feature(rustc_private))]
#![feature(strict_provenance)]
#![feature(exposed_provenance)]
#![feature(sync_unsafe_cell)]
#![feature(linkage)]
#![feature(naked_functions)]
#![deny(fuzzy_provenance_casts, lossy_provenance_casts)]
#![allow(unexpected_cfgs)]
#[cfg(all(feature = "coexist-with-libc", feature = "take-charge"))]
compile_error!("Enable only one of \"coexist-with-libc\" and \"take-charge\".");
#[cfg(all(not(feature = "coexist-with-libc"), not(feature = "take-charge")))]
compile_error!("Enable one \"coexist-with-libc\" and \"take-charge\".");
extern crate alloc;
#[cfg(feature = "use-compiler-builtins")]
extern crate compiler_builtins;
pub use libc::*;
#[macro_use]
mod use_libc;
#[cfg(not(target_os = "wasi"))]
mod at_fork;
mod error_str;
mod sync_ptr;
#[cfg(feature = "take-charge")]
use core::ptr::addr_of;
use errno::{set_errno, Errno};
mod brk;
mod ctype;
mod env;
mod fs;
mod io;
mod shm;
#[cfg(feature = "take-charge")]
mod malloc;
mod math;
mod mem;
#[cfg(not(target_os = "wasi"))]
mod mm;
mod net;
#[cfg(not(target_os = "wasi"))]
mod process;
mod rand;
mod rand48;
#[cfg(not(target_os = "wasi"))]
#[cfg(feature = "take-charge")]
mod signal;
mod termios_;
#[cfg(feature = "thread")]
#[cfg(feature = "take-charge")]
mod thread;
mod arpa_inet;
mod atoi;
mod base64;
mod errno_;
mod error;
mod exec;
#[cfg(feature = "take-charge")]
mod exit;
mod glibc_versioning;
mod int;
mod jmp;
mod locale;
mod mkostemps;
mod nss;
mod path;
mod pause;
mod posix_spawn;
mod process_;
mod pty;
mod rand_;
mod regex;
mod sort;
#[cfg(feature = "take-charge")]
mod stdio;
mod strtod;
mod strtol;
mod syscall;
mod system;
mod time;
#[cfg(feature = "deprecated-and-unimplemented")]
mod deprecated;
#[cfg(feature = "todo")]
mod todo;
#[cfg(feature = "take-charge")]
#[no_mangle]
static __dso_handle: UnsafeSendSyncVoidStar =
UnsafeSendSyncVoidStar(addr_of!(__dso_handle) as *const _);
#[repr(transparent)]
#[cfg(feature = "take-charge")]
struct UnsafeSendSyncVoidStar(*const core::ffi::c_void);
#[cfg(feature = "take-charge")]
unsafe impl Send for UnsafeSendSyncVoidStar {}
#[cfg(feature = "take-charge")]
unsafe impl Sync for UnsafeSendSyncVoidStar {}
#[cfg(feature = "take-charge")]
#[cfg(feature = "call-main")]
#[no_mangle]
unsafe fn origin_main(argc: usize, argv: *mut *mut u8, envp: *mut *mut u8) -> i32 {
extern "C" {
fn main(argc: i32, argv: *const *const u8, envp: *const *const u8) -> i32;
}
main(argc as _, argv as _, envp as _)
}
fn convert_res<T>(result: Result<T, rustix::io::Errno>) -> Option<T> {
result
.map_err(|err| set_errno(Errno(err.raw_os_error())))
.ok()
}
#[cfg(feature = "thread")]
pub(crate) struct GetThreadId;
#[cfg(feature = "thread")]
unsafe impl rustix_futex_sync::lock_api::GetThreadId for GetThreadId {
const INIT: Self = Self;
#[inline]
fn nonzero_thread_id(&self) -> core::num::NonZeroUsize {
origin::thread::current().to_raw_non_null().addr()
}
}