|
@@ -1,6 +1,3 @@
|
|
|
-use core::mem;
|
|
|
-#[cfg(target_os = "redox")]
|
|
|
-use syscall::data::TimeSpec as redox_timespec;
|
|
|
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable
|
|
|
// more optimization opportunities around it recognizing things like
|
|
|
// malloc/free.
|
|
@@ -68,195 +65,3 @@ pub type suseconds_t = c_int;
|
|
|
pub type clock_t = c_long;
|
|
|
pub type clockid_t = c_int;
|
|
|
pub type timer_t = *mut c_void;
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-#[derive(Default)]
|
|
|
-pub struct timespec {
|
|
|
- pub tv_sec: time_t,
|
|
|
- pub tv_nsec: c_long,
|
|
|
-}
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-#[derive(Default)]
|
|
|
-pub struct timeval {
|
|
|
- pub tv_sec: time_t,
|
|
|
- pub tv_usec: suseconds_t,
|
|
|
-}
|
|
|
-#[repr(C)]
|
|
|
-#[derive(Default)]
|
|
|
-pub struct timezone {
|
|
|
- pub tz_minuteswest: c_int,
|
|
|
- pub tz_dsttime: c_int,
|
|
|
-}
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-#[derive(Default)]
|
|
|
-pub struct itimerval {
|
|
|
- pub it_interval: timeval,
|
|
|
- pub it_value: timeval,
|
|
|
-}
|
|
|
-
|
|
|
-#[cfg(target_os = "redox")]
|
|
|
-impl<'a> From<&'a timespec> for redox_timespec {
|
|
|
- fn from(tp: ×pec) -> redox_timespec {
|
|
|
- redox_timespec {
|
|
|
- tv_sec: tp.tv_sec,
|
|
|
- tv_nsec: tp.tv_nsec as i32,
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-#[derive(Default)]
|
|
|
-pub struct stat {
|
|
|
- pub st_dev: dev_t,
|
|
|
- pub st_ino: ino_t,
|
|
|
- pub st_nlink: nlink_t,
|
|
|
- pub st_mode: mode_t,
|
|
|
- pub st_uid: uid_t,
|
|
|
- pub st_gid: gid_t,
|
|
|
- pub st_rdev: dev_t,
|
|
|
- pub st_size: off_t,
|
|
|
- pub st_blksize: blksize_t,
|
|
|
- pub st_blocks: blkcnt_t,
|
|
|
-
|
|
|
- pub st_atim: timespec,
|
|
|
- pub st_mtim: timespec,
|
|
|
- pub st_ctim: timespec,
|
|
|
-
|
|
|
- // Compared to glibc, our struct is for some reason 24 bytes too small.
|
|
|
- // Accessing atime works, so clearly the struct isn't incorrect...
|
|
|
- // This works.
|
|
|
- pub _pad: [c_char; 24],
|
|
|
-}
|
|
|
-
|
|
|
-pub const AF_INET: c_int = 2;
|
|
|
-pub const SOCK_STREAM: c_int = 1;
|
|
|
-pub const SOCK_DGRAM: c_int = 2;
|
|
|
-pub const SOCK_NONBLOCK: c_int = 0o4000;
|
|
|
-pub const SOCK_CLOEXEC: c_int = 0o2000000;
|
|
|
-
|
|
|
-pub const SIG_BLOCK: c_int = 0;
|
|
|
-pub const SIG_UNBLOCK: c_int = 1;
|
|
|
-pub const SIG_SETMASK: c_int = 2;
|
|
|
-
|
|
|
-pub type in_addr_t = [u8; 4];
|
|
|
-pub type in_port_t = u16;
|
|
|
-pub type sa_family_t = u16;
|
|
|
-pub type socklen_t = u32;
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-pub struct sockaddr {
|
|
|
- pub sa_family: sa_family_t,
|
|
|
- pub data: [c_char; 14],
|
|
|
-}
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-#[derive(Debug, Clone, Copy)]
|
|
|
-pub struct in_addr {
|
|
|
- pub s_addr: in_addr_t,
|
|
|
-}
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-pub struct sockaddr_in {
|
|
|
- pub sin_family: sa_family_t,
|
|
|
- pub sin_port: in_port_t,
|
|
|
- pub sin_addr: in_addr,
|
|
|
-}
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-pub struct sigaction {
|
|
|
- pub sa_handler: Option<extern "C" fn(c_int)>,
|
|
|
- pub sa_flags: c_ulong,
|
|
|
- pub sa_restorer: Option<unsafe extern "C" fn()>,
|
|
|
- pub sa_mask: sigset_t,
|
|
|
-}
|
|
|
-
|
|
|
-pub type sigset_t = c_ulong;
|
|
|
-
|
|
|
-const UTSLENGTH: usize = 65;
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-pub struct utsname {
|
|
|
- pub sysname: [c_char; UTSLENGTH],
|
|
|
- pub nodename: [c_char; UTSLENGTH],
|
|
|
- pub release: [c_char; UTSLENGTH],
|
|
|
- pub version: [c_char; UTSLENGTH],
|
|
|
- pub machine: [c_char; UTSLENGTH],
|
|
|
- pub domainname: [c_char; UTSLENGTH],
|
|
|
-}
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-pub struct dirent {
|
|
|
- pub d_ino: ino_t,
|
|
|
- pub d_off: off_t,
|
|
|
- pub d_reclen: c_ushort,
|
|
|
- pub d_type: c_uchar,
|
|
|
- pub d_name: [c_char; 256],
|
|
|
-}
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-#[derive(Default)]
|
|
|
-pub struct winsize {
|
|
|
- ws_row: c_ushort,
|
|
|
- ws_col: c_ushort,
|
|
|
- ws_xpixel: c_ushort,
|
|
|
- ws_ypixel: c_ushort,
|
|
|
-}
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-pub struct rusage {
|
|
|
- pub ru_utime: timeval,
|
|
|
- pub ru_stime: timeval,
|
|
|
- pub ru_maxrss: c_long,
|
|
|
- pub ru_ixrss: c_long,
|
|
|
- pub ru_idrss: c_long,
|
|
|
- pub ru_isrss: c_long,
|
|
|
- pub ru_minflt: c_long,
|
|
|
- pub ru_majflt: c_long,
|
|
|
- pub ru_nswap: c_long,
|
|
|
- pub ru_inblock: c_long,
|
|
|
- pub ru_oublock: c_long,
|
|
|
- pub ru_msgsnd: c_long,
|
|
|
- pub ru_msgrcv: c_long,
|
|
|
- pub ru_nsignals: c_long,
|
|
|
- pub ru_nvcsw: c_long,
|
|
|
- pub ru_nivcsw: c_long,
|
|
|
-}
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-pub struct tms {
|
|
|
- tms_utime: clock_t,
|
|
|
- tms_stime: clock_t,
|
|
|
- tms_cutime: clock_t,
|
|
|
- tms_cstime: clock_t,
|
|
|
-}
|
|
|
-
|
|
|
-pub const FD_SETSIZE: usize = 1024;
|
|
|
-#[repr(C)]
|
|
|
-pub struct fd_set {
|
|
|
- pub fds_bits: [c_ulong; FD_SETSIZE / (8 * mem::size_of::<c_ulong>())],
|
|
|
-}
|
|
|
-
|
|
|
-pub const F_OK: c_int = 0;
|
|
|
-pub const R_OK: c_int = 4;
|
|
|
-pub const W_OK: c_int = 2;
|
|
|
-pub const X_OK: c_int = 1;
|
|
|
-
|
|
|
-pub type cc_t = u8;
|
|
|
-pub type speed_t = u32;
|
|
|
-pub type tcflag_t = u32;
|
|
|
-
|
|
|
-pub const NCCS: usize = 32;
|
|
|
-
|
|
|
-#[repr(C)]
|
|
|
-pub struct termios {
|
|
|
- c_iflag: tcflag_t,
|
|
|
- c_oflag: tcflag_t,
|
|
|
- c_cflag: tcflag_t,
|
|
|
- c_lflag: tcflag_t,
|
|
|
- c_line: cc_t,
|
|
|
- c_cc: [cc_t; NCCS],
|
|
|
- __c_ispeed: speed_t,
|
|
|
- __c_ospeed: speed_t,
|
|
|
-}
|