Merge branch 'time__var_impl' into 'master'

clock_getres/clock_settime additions

See merge request redox-os/relibc!389
This commit is contained in:
Jeremy Soller
2023-05-09 14:24:25 +00:00
4 changed files with 29 additions and 5 deletions
+5 -5
View File
@@ -198,9 +198,9 @@ pub extern "C" fn clock() -> clock_t {
}
}
// #[no_mangle]
pub extern "C" fn clock_getres(clock_id: clockid_t, res: *mut timespec) -> c_int {
unimplemented!();
#[no_mangle]
pub extern "C" fn clock_getres(clock_id: clockid_t, tp: *mut timespec) -> c_int {
Sys::clock_getres(clock_id, tp)
}
#[no_mangle]
@@ -208,9 +208,9 @@ pub extern "C" fn clock_gettime(clock_id: clockid_t, tp: *mut timespec) -> c_int
Sys::clock_gettime(clock_id, tp)
}
// #[no_mangle]
#[no_mangle]
pub extern "C" fn clock_settime(clock_id: clockid_t, tp: *const timespec) -> c_int {
unimplemented!();
Sys::clock_settime(clock_id, tp)
}
#[no_mangle]
+8
View File
@@ -106,10 +106,18 @@ impl Pal for Sys {
}) as c_int
}
fn clock_getres(clk_id: clockid_t, tp: *mut timespec) -> c_int {
e(unsafe { syscall!(CLOCK_GETRES, clk_id, tp) }) as c_int
}
fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int {
e(unsafe { syscall!(CLOCK_GETTIME, clk_id, tp) }) as c_int
}
fn clock_settime(clk_id: clockid_t, tp: *const timespec) -> c_int {
e(unsafe { syscall!(CLOCK_SETTIME, clk_id, tp) }) as c_int
}
fn close(fildes: c_int) -> c_int {
e(unsafe { syscall!(CLOSE, fildes) }) as c_int
}
+4
View File
@@ -35,8 +35,12 @@ pub trait Pal {
fn chown(path: &CStr, owner: uid_t, group: gid_t) -> c_int;
fn clock_getres(clk_id: clockid_t, tp: *mut timespec) -> c_int;
fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int;
fn clock_settime(clk_id: clockid_t, tp: *const timespec) -> c_int;
fn close(fildes: c_int) -> c_int;
fn dup(fildes: c_int) -> c_int;
+12
View File
@@ -184,6 +184,12 @@ impl Pal for Sys {
}
}
fn clock_getres(clk_id: clockid_t, tp: *mut timespec) -> c_int {
// TODO
unsafe { errno = ENOSYS };
-1
}
fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int {
let mut redox_tp = unsafe { redox_timespec::from(&*tp) };
match e(syscall::clock_gettime(clk_id as usize, &mut redox_tp)) as c_int {
@@ -198,6 +204,12 @@ impl Pal for Sys {
}
}
fn clock_settime(clk_id: clockid_t, tp: *const timespec) -> c_int {
// TODO
unsafe { errno = ENOSYS };
-1
}
fn close(fd: c_int) -> c_int {
e(syscall::close(fd as usize)) as c_int
}