diff --git a/src/header/sys_times/mod.rs b/src/header/sys_times/mod.rs index f949566ad5..8149f352bf 100644 --- a/src/header/sys_times/mod.rs +++ b/src/header/sys_times/mod.rs @@ -1,9 +1,11 @@ -//! sys/times.h implementation +//! `sys/times.h` implementation. +//! +//! See . -use platform; -use platform::types::*; -use platform::{Pal, Sys}; +use crate::platform; +use platform::{Pal, Sys, types::clock_t}; +/// See . #[repr(C)] pub struct tms { tms_utime: clock_t, @@ -12,6 +14,7 @@ pub struct tms { tms_cstime: clock_t, } +/// See . #[unsafe(no_mangle)] pub extern "C" fn times(out: *mut tms) -> clock_t { Sys::times(out) diff --git a/src/header/termios/mod.rs b/src/header/termios/mod.rs index feab8deea6..608ecf3555 100644 --- a/src/header/termios/mod.rs +++ b/src/header/termios/mod.rs @@ -1,11 +1,16 @@ -//! termios implementation, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/termios.h.html +//! `termios.h` implementation. +//! +//! See . use crate::{ header::{ errno, sys_ioctl::{self, winsize}, }, - platform::{self, types::*}, + platform::{ + self, + types::{c_int, c_ulong, c_void}, + }, }; pub use self::sys::*; @@ -35,6 +40,7 @@ pub const TCSANOW: c_int = 0; pub const TCSADRAIN: c_int = 1; pub const TCSAFLUSH: c_int = 2; +/// See . #[cfg(target_os = "linux")] #[repr(C)] #[derive(Default, Clone)] @@ -50,6 +56,7 @@ pub struct termios { } // Must match structure in redox_termios +/// See . #[cfg(target_os = "redox")] #[repr(C)] #[derive(Default, Clone)] @@ -61,11 +68,13 @@ pub struct termios { pub c_cc: [cc_t; NCCS], } +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn tcgetattr(fd: c_int, out: *mut termios) -> c_int { sys_ioctl::ioctl(fd, sys_ioctl::TCGETS, out as *mut c_void) } +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn tcsetattr(fd: c_int, act: c_int, value: *const termios) -> c_int { if act < 0 || act > 2 { @@ -76,12 +85,14 @@ pub unsafe extern "C" fn tcsetattr(fd: c_int, act: c_int, value: *const termios) sys_ioctl::ioctl(fd, sys_ioctl::TCSETS + act as c_ulong, value as *mut c_void) } +/// See . #[cfg(target_os = "linux")] #[unsafe(no_mangle)] pub unsafe extern "C" fn cfgetispeed(termios_p: *const termios) -> speed_t { (*termios_p).__c_ispeed } +/// See . #[cfg(target_os = "redox")] #[unsafe(no_mangle)] pub unsafe extern "C" fn cfgetispeed(termios_p: *const termios) -> speed_t { @@ -89,12 +100,14 @@ pub unsafe extern "C" fn cfgetispeed(termios_p: *const termios) -> speed_t { 0 } +/// See . #[cfg(target_os = "linux")] #[unsafe(no_mangle)] pub unsafe extern "C" fn cfgetospeed(termios_p: *const termios) -> speed_t { (*termios_p).__c_ospeed } +/// See . #[cfg(target_os = "redox")] #[unsafe(no_mangle)] pub unsafe extern "C" fn cfgetospeed(termios_p: *const termios) -> speed_t { @@ -102,6 +115,7 @@ pub unsafe extern "C" fn cfgetospeed(termios_p: *const termios) -> speed_t { 0 } +/// See . #[cfg(target_os = "linux")] #[unsafe(no_mangle)] pub unsafe extern "C" fn cfsetispeed(termios_p: *mut termios, speed: speed_t) -> c_int { @@ -117,6 +131,7 @@ pub unsafe extern "C" fn cfsetispeed(termios_p: *mut termios, speed: speed_t) -> } } +/// See . #[cfg(target_os = "redox")] #[unsafe(no_mangle)] pub unsafe extern "C" fn cfsetispeed(termios_p: *mut termios, speed: speed_t) -> c_int { @@ -125,6 +140,7 @@ pub unsafe extern "C" fn cfsetispeed(termios_p: *mut termios, speed: speed_t) -> -1 } +/// See . #[cfg(target_os = "linux")] #[unsafe(no_mangle)] pub unsafe extern "C" fn cfsetospeed(termios_p: *mut termios, speed: speed_t) -> c_int { @@ -140,6 +156,7 @@ pub unsafe extern "C" fn cfsetospeed(termios_p: *mut termios, speed: speed_t) -> } } +/// See . #[cfg(target_os = "redox")] #[unsafe(no_mangle)] pub unsafe extern "C" fn cfsetospeed(termios_p: *mut termios, speed: speed_t) -> c_int { @@ -148,6 +165,9 @@ pub unsafe extern "C" fn cfsetospeed(termios_p: *mut termios, speed: speed_t) -> -1 } +/// Non-POSIX, 4.4 BSD extension +/// +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn cfsetspeed(termios_p: *mut termios, speed: speed_t) -> c_int { let r = cfsetispeed(termios_p, speed); @@ -157,16 +177,19 @@ pub unsafe extern "C" fn cfsetspeed(termios_p: *mut termios, speed: speed_t) -> cfsetospeed(termios_p, speed) } +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn tcflush(fd: c_int, queue: c_int) -> c_int { sys_ioctl::ioctl(fd, sys_ioctl::TCFLSH, queue as *mut c_void) } +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn tcdrain(fd: c_int) -> c_int { sys_ioctl::ioctl(fd, sys_ioctl::TCSBRK, 1 as *mut _) } +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn tcsendbreak(fd: c_int, _dur: c_int) -> c_int { // non-zero duration is ignored by musl due to it being @@ -174,11 +197,13 @@ pub unsafe extern "C" fn tcsendbreak(fd: c_int, _dur: c_int) -> c_int { sys_ioctl::ioctl(fd, sys_ioctl::TCSBRK, 0 as *mut _) } +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn tcsetwinsize(fd: c_int, mut sws: winsize) -> c_int { sys_ioctl::ioctl(fd, sys_ioctl::TIOCSWINSZ, &mut sws as *mut _ as *mut c_void) } +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn tcflow(fd: c_int, action: c_int) -> c_int { // non-zero duration is ignored by musl due to it being @@ -186,6 +211,9 @@ pub unsafe extern "C" fn tcflow(fd: c_int, action: c_int) -> c_int { sys_ioctl::ioctl(fd, sys_ioctl::TCXONC, action as *mut _) } +/// Non-POSIX, BSD extension +/// +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn cfmakeraw(termios_p: *mut termios) { (*termios_p).c_iflag &=