1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use arceos_posix_api::{sys_clock_gettime, sys_nanosleep};
use core::ffi::c_int;

use crate::{ctypes, utils::e};

/// Get clock time since booting
#[no_mangle]
pub unsafe extern "C" fn clock_gettime(clk: ctypes::clockid_t, ts: *mut ctypes::timespec) -> c_int {
    e(sys_clock_gettime(clk, ts))
}

/// Sleep some nanoseconds
///
/// TODO: should be woken by signals, and set errno
#[no_mangle]
pub unsafe extern "C" fn nanosleep(
    req: *const ctypes::timespec,
    rem: *mut ctypes::timespec,
) -> c_int {
    e(sys_nanosleep(req, rem))
}