diff --git a/src/c_str.rs b/src/c_str.rs index 56f1b084f7..91c891eb53 100644 --- a/src/c_str.rs +++ b/src/c_str.rs @@ -1,3 +1,5 @@ +//! Nul-terminated byte strings. + use core::{marker::PhantomData, ptr::NonNull, str::Utf8Error}; use alloc::{ diff --git a/src/c_vec.rs b/src/c_vec.rs index a6edbf27ee..bb2800df2e 100644 --- a/src/c_vec.rs +++ b/src/c_vec.rs @@ -1,3 +1,5 @@ +//! Equivalent of Rust's `Vec`, but using relibc's own allocator. + use crate::{ io::{self, Write}, platform::{self, types::*, WriteByte}, diff --git a/src/header/mod.rs b/src/header/mod.rs index 338c6683ac..3bb28d8e36 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -1,3 +1,5 @@ +//! POSIX header implementations. + pub mod _aio; pub mod _fenv; pub mod arpa_inet; diff --git a/src/ld_so/mod.rs b/src/ld_so/mod.rs index b32c393e68..2806f09f3f 100644 --- a/src/ld_so/mod.rs +++ b/src/ld_so/mod.rs @@ -1,3 +1,5 @@ +//! Dynamic loading and linking. + use core::{mem, ptr}; use goblin::elf::program_header::{self, program_header32, program_header64, ProgramHeader}; diff --git a/src/lib.rs b/src/lib.rs index 4ae044e0dc..d2697004d4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,11 @@ +//! POSIX C library, implemented in Rust. +//! +//! This crate exists to provide a standard libc as its public API. This is +//! largely provided by automatically generated bindings to the functions and +//! data structures in the [`header`] module. +//! +//! Currently, Linux and Redox syscall backends are supported. + #![no_std] #![allow(warnings)] #![allow(non_camel_case_types)] diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index 4667f761de..541c9430ad 100644 --- a/src/platform/linux/mod.rs +++ b/src/platform/linux/mod.rs @@ -65,6 +65,7 @@ pub fn e_raw(sys: usize) -> Result { } } +/// Linux syscall implementation of the platform abstraction layer. pub struct Sys; impl Sys { diff --git a/src/platform/mod.rs b/src/platform/mod.rs index e8bab124be..7d3ebc50c2 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -1,3 +1,5 @@ +//! Platform abstractions and environment. + use crate::{ error::ResultExt, io::{self, Read, Write}, @@ -38,9 +40,11 @@ pub use redox_rt::auxv_defs; use self::types::*; pub mod types; +/// The global `errno` variable used internally in relibc. #[thread_local] pub static ERRNO: Cell = Cell::new(0); +/// The `argv` argument available to a program's `main` function. #[allow(non_upper_case_globals)] pub static mut argv: *mut *mut c_char = ptr::null_mut(); #[allow(non_upper_case_globals)] diff --git a/src/platform/pal/mod.rs b/src/platform/pal/mod.rs index c80069001e..6c55a98955 100644 --- a/src/platform/pal/mod.rs +++ b/src/platform/pal/mod.rs @@ -25,6 +25,7 @@ mod signal; pub use self::socket::PalSocket; mod socket; +/// Platform abstraction layer, a platform-agnostic abstraction over syscalls. pub trait Pal { fn access(path: CStr, mode: c_int) -> Result<()>; diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index e186b5de90..8cbd5b7b8e 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -74,6 +74,7 @@ macro_rules! path_from_c_str { use self::{exec::Executable, path::canonicalize}; +/// Redox syscall implementation of the platform abstraction layer. pub struct Sys; impl Pal for Sys { diff --git a/src/platform/types.rs b/src/platform/types.rs index 202bea286b..10ac216107 100644 --- a/src/platform/types.rs +++ b/src/platform/types.rs @@ -1,3 +1,5 @@ +//! C data types for this platform. + use core::i32; // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable diff --git a/src/start.rs b/src/start.rs index 5f2326ec3a..754a7bbe07 100644 --- a/src/start.rs +++ b/src/start.rs @@ -1,3 +1,5 @@ +//! Startup code. + use alloc::{boxed::Box, vec::Vec}; use core::{intrinsics, ptr}; diff --git a/src/sync/mod.rs b/src/sync/mod.rs index 254bd68108..6b22256386 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -1,3 +1,5 @@ +//! Synchronization primitives. + // TODO: set this for entire crate when possible #![deny(unsafe_op_in_unsafe_fn)]