48 lines
907 B
Rust
48 lines
907 B
Rust
use core::{
|
|
ffi::{c_double, c_int},
|
|
time::Duration,
|
|
};
|
|
|
|
use crate::{header::sys_types::time_t, util};
|
|
|
|
use super::timespec;
|
|
|
|
#[no_mangle]
|
|
unsafe extern "C" fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int {
|
|
let rqtp = rqtp.as_ref().unwrap();
|
|
|
|
let amount = Duration::from(*rqtp);
|
|
|
|
match util::nanosleep(amount, None) {
|
|
Ok(()) => {
|
|
if let Some(rmtp) = rmtp.as_mut() {
|
|
// Zero
|
|
*rmtp = timespec::default();
|
|
}
|
|
|
|
0
|
|
}
|
|
Err(_) => {
|
|
if let Some(rmtp) = rmtp.as_mut() {
|
|
todo!();
|
|
}
|
|
-1
|
|
}
|
|
}
|
|
}
|
|
|
|
#[no_mangle]
|
|
unsafe extern "C" fn time(tp: *mut time_t) -> time_t {
|
|
todo!()
|
|
}
|
|
|
|
#[no_mangle]
|
|
unsafe extern "C" fn tzset() {
|
|
todo!()
|
|
}
|
|
|
|
#[no_mangle]
|
|
unsafe extern "C" fn difftime(a: time_t, b: time_t) -> c_double {
|
|
todo!()
|
|
}
|