move timeval to sys_select

This commit is contained in:
Ron Williams
2026-01-30 15:53:15 +00:00
parent a32fd56e61
commit 2c3201eaeb
11 changed files with 35 additions and 28 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
use crate::{
error::ResultExt,
header::sys_time::timeval,
header::sys_select::timeval,
out::Out,
platform::{
Pal, Sys,
+1 -4
View File
@@ -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"
+13 -2
View File
@@ -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 <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_select.h.html>.
///
#[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 <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_select.h.html>.
+4 -1
View File
@@ -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 <bits/sys/time.h>"
@@ -8,3 +8,6 @@ cpp_compat = true
[enum]
prefix_with_name = true
[export.rename]
"timeval" = "struct timeval"
+1 -11
View File
@@ -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 <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_time.h.html>.
///
/// 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 <https://www.man7.org/linux/man-pages/man2/gettimeofday.2.html>.
#[repr(C)]
#[derive(Default)]
+4 -1
View File
@@ -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},
};
-1
View File
@@ -5,7 +5,6 @@ sys_includes = [
"sys/types_internal.h",
"stddef.h",
"sys/select.h",
"bits/pthread.h",
"features.h",
]
+6 -4
View File
@@ -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,
},
+2 -1
View File
@@ -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},
},
+2 -1
View File
@@ -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},
+1 -1
View File
@@ -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,
},