diff --git a/src/header/sys_resource/mod.rs b/src/header/sys_resource/mod.rs index d9259a7342..8d4d661f05 100644 --- a/src/header/sys_resource/mod.rs +++ b/src/header/sys_resource/mod.rs @@ -4,7 +4,7 @@ use crate::{ error::ResultExt, - header::sys_time::timeval, + header::sys_select::timeval, out::Out, platform::{ Pal, Sys, diff --git a/src/header/sys_select/cbindgen.toml b/src/header/sys_select/cbindgen.toml index 2fe42a7155..61a50a0595 100644 --- a/src/header/sys_select/cbindgen.toml +++ b/src/header/sys_select/cbindgen.toml @@ -1,4 +1,4 @@ -sys_includes = ["bits/sys/select.h", "sys/time.h", "signal.h"] +sys_includes = ["bits/sys/select.h", "time.h", "signal.h"] include_guard = "_SYS_SELECT_H" language = "C" style = "Tag" @@ -11,6 +11,3 @@ prefix_with_name = true [export] # fd_set is also defined in C because cbindgen is incompatible with mem::size_of booo exclude = ["FD_SETSIZE", "fd_set"] - -[export.rename] -"timeval" = "struct timeval" diff --git a/src/header/sys_select/mod.rs b/src/header/sys_select/mod.rs index 69afb10670..39b7599322 100644 --- a/src/header/sys_select/mod.rs +++ b/src/header/sys_select/mod.rs @@ -14,11 +14,22 @@ use crate::{ EPOLL_CLOEXEC, EPOLL_CTL_ADD, EPOLLERR, EPOLLIN, EPOLLOUT, epoll_create1, epoll_ctl, epoll_data, epoll_event, epoll_wait, }, - sys_time::timeval, }, - platform::{self, types::c_int}, + platform::{ + self, + types::{c_int, suseconds_t, time_t}, + }, }; +/// See . +/// +#[repr(C)] +#[derive(Default)] +pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, +} + // fd_set is also defined in C because cbindgen is incompatible with mem::size_of booo /// See . diff --git a/src/header/sys_time/cbindgen.toml b/src/header/sys_time/cbindgen.toml index c7894fcfcc..5d8bf0b6a6 100644 --- a/src/header/sys_time/cbindgen.toml +++ b/src/header/sys_time/cbindgen.toml @@ -1,4 +1,4 @@ -sys_includes = ["sys/types.h", "features.h"] +sys_includes = ["sys/types.h", "features.h", "sys/select.h"] include_guard = "_SYS_TIME_H" language = "C" trailer = "#include " @@ -8,3 +8,6 @@ cpp_compat = true [enum] prefix_with_name = true + +[export.rename] +"timeval" = "struct timeval" diff --git a/src/header/sys_time/mod.rs b/src/header/sys_time/mod.rs index 1de62a9da3..c3d08444f6 100644 --- a/src/header/sys_time/mod.rs +++ b/src/header/sys_time/mod.rs @@ -5,7 +5,7 @@ use crate::{ c_str::CStr, error::ResultExt, - header::time::timespec, + header::{sys_select::timeval, time::timespec}, out::Out, platform::{ Pal, PalSignal, Sys, @@ -59,16 +59,6 @@ pub struct itimerval { pub it_value: timeval, } -/// See . -/// -/// TODO: specified for `sys/select.h` in modern POSIX? -#[repr(C)] -#[derive(Default)] -pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, -} - /// Non-POSIX, see . #[repr(C)] #[derive(Default)] diff --git a/src/header/sys_timeb/mod.rs b/src/header/sys_timeb/mod.rs index 0abf94e490..c0ab30ec78 100644 --- a/src/header/sys_timeb/mod.rs +++ b/src/header/sys_timeb/mod.rs @@ -10,7 +10,10 @@ use core::ptr::NonNull; use crate::{ - header::sys_time::{gettimeofday, timeval, timezone}, + header::{ + sys_select::timeval, + sys_time::{gettimeofday, timezone}, + }, platform::types::{c_int, c_short, c_ushort, time_t}, }; diff --git a/src/header/sys_types/cbindgen.toml b/src/header/sys_types/cbindgen.toml index e33c3366ad..3d50b41267 100644 --- a/src/header/sys_types/cbindgen.toml +++ b/src/header/sys_types/cbindgen.toml @@ -5,7 +5,6 @@ sys_includes = [ "sys/types_internal.h", "stddef.h", - "sys/select.h", "bits/pthread.h", "features.h", ] diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index f014f4d632..b760c6e653 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -17,7 +17,9 @@ use crate::{ errno::{self, ENAMETOOLONG}, fcntl, limits, stdlib::getenv, - sys_ioctl, sys_resource, sys_time, sys_utsname, termios, + sys_ioctl, sys_resource, + sys_select::timeval, + sys_time, sys_utsname, termios, time::timespec, }, out::Out, @@ -146,7 +148,7 @@ pub unsafe extern "C" fn access(path: *const c_char, mode: c_int) -> c_int { pub extern "C" fn alarm(seconds: c_uint) -> c_uint { // TODO setitimer is unimplemented on Redox and obsolete let mut timer = sys_time::itimerval { - it_value: sys_time::timeval { + it_value: timeval { tv_sec: seconds as time_t, tv_usec: 0, }, @@ -1133,11 +1135,11 @@ pub extern "C" fn ttyname_r(fildes: c_int, name: *mut c_char, namesize: size_t) pub extern "C" fn ualarm(usecs: useconds_t, interval: useconds_t) -> useconds_t { // TODO setitimer is unimplemented on Redox and obsolete let mut timer = sys_time::itimerval { - it_value: sys_time::timeval { + it_value: timeval { tv_sec: 0, tv_usec: usecs as suseconds_t, }, - it_interval: sys_time::timeval { + it_interval: timeval { tv_sec: 0, tv_usec: interval as suseconds_t, }, diff --git a/src/platform/pal/mod.rs b/src/platform/pal/mod.rs index 60c1c29fda..227c9b4d1e 100644 --- a/src/platform/pal/mod.rs +++ b/src/platform/pal/mod.rs @@ -7,9 +7,10 @@ use crate::{ header::{ signal::sigevent, sys_resource::{rlimit, rusage}, + sys_select::timeval, sys_stat::stat, sys_statvfs::statvfs, - sys_time::{timeval, timezone}, + sys_time::timezone, sys_utsname::utsname, time::{itimerspec, timespec}, }, diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index 02a46a0d40..707f402dfc 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -39,9 +39,10 @@ use crate::{ sys_mman::{MAP_ANONYMOUS, MAP_FAILED, PROT_READ, PROT_WRITE}, sys_random, sys_resource::{RLIM_INFINITY, rlimit, rusage}, + sys_select::timeval, sys_stat::{S_ISGID, S_ISUID, S_ISVTX, stat}, sys_statvfs::statvfs, - sys_time::{timeval, timezone}, + sys_time::timezone, sys_utsname::{UTSLENGTH, utsname}, sys_wait, time::{TIMER_ABSTIME, itimerspec, timer_internal_t, timespec}, diff --git a/src/platform/redox/socket.rs b/src/platform/redox/socket.rs index aa47416f65..64146a5ff2 100644 --- a/src/platform/redox/socket.rs +++ b/src/platform/redox/socket.rs @@ -21,11 +21,11 @@ use crate::{ }, netinet_in::{in_addr, in_port_t, sockaddr_in}, string::strnlen, + sys_select::timeval, sys_socket::{ CMSG_ALIGN, CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_NXTHDR, CMSG_SPACE, cmsghdr, constants::*, msghdr, sa_family_t, sockaddr, socklen_t, ucred, }, - sys_time::timeval, sys_uio::iovec, sys_un::sockaddr_un, },