Large reorganization of headers (WIP)

This commit is contained in:
Jeremy Soller
2018-08-26 08:11:35 -06:00
parent ff32c8cbbd
commit c20ce5ffed
261 changed files with 236 additions and 1672 deletions
+10
View File
@@ -0,0 +1,10 @@
sys_includes = ["sys/types.h"]
include_guard = "_SYS_TIME_H"
language = "C"
# WORKAROUND:
# Timeval is used by another header, and cbindgen doesn't prefix that with `struct` :|
style = "Both"
[enum]
prefix_with_name = true
+92
View File
@@ -0,0 +1,92 @@
//! sys/time implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/systime.h.html
use platform;
use platform::{Pal, Sys};
use platform::types::*;
pub const ITIMER_REAL: c_int = 0;
pub const ITIMER_VIRTUAL: c_int = 1;
pub const ITIMER_PROF: c_int = 2;
#[repr(C)]
#[derive(Default)]
pub struct timeval {
pub tv_sec: time_t,
pub tv_usec: suseconds_t,
}
#[repr(C)]
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,
}
#[repr(C)]
pub struct fd_set {
pub fds_bits: [c_long; 16usize],
}
#[no_mangle]
pub extern "C" fn getitimer(which: c_int, value: *mut itimerval) -> c_int {
Sys::getitimer(which, value as *mut platform::types::itimerval)
}
#[no_mangle]
pub extern "C" fn setitimer(
which: c_int,
value: *const itimerval,
ovalue: *mut itimerval,
) -> c_int {
Sys::setitimer(
which,
value as *const platform::types::itimerval,
ovalue as *mut platform::types::itimerval,
)
}
#[no_mangle]
pub extern "C" fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c_int {
Sys::gettimeofday(
tp as *mut platform::types::timeval,
tzp as *mut platform::types::timezone,
)
}
// #[no_mangle]
pub extern "C" fn select(
nfds: c_int,
readfds: *mut fd_set,
writefds: *mut fd_set,
errorfds: *mut fd_set,
timeout: *mut timeval,
) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn utimes(path: *const c_char, times: *const timeval) -> c_int {
let times_spec = [
timespec {
tv_sec: (*times.offset(0)).tv_sec,
tv_nsec: ((*times.offset(0)).tv_usec as i64) * 1000,
},
timespec {
tv_sec: (*times.offset(1)).tv_sec,
tv_nsec: ((*times.offset(1)).tv_usec as i64) * 1000,
},
];
Sys::utimens(path, times_spec.as_ptr())
}
/*
#[no_mangle]
pub extern "C" fn func(args) -> c_int {
unimplemented!();
}
*/