35 lines
1.1 KiB
Diff
35 lines
1.1 KiB
Diff
diff --git a/src/header/time/mod.rs b/src/header/time/mod.rs
|
|
index 1a432bf3..db30e0d7 100644
|
|
--- a/src/header/time/mod.rs
|
|
+++ b/src/header/time/mod.rs
|
|
@@ -7,7 +7,7 @@ use crate::{
|
|
error::{Errno, ResultExt},
|
|
header::{
|
|
bits_timespec::timespec,
|
|
- errno::{EFAULT, ENOMEM, EOVERFLOW, ETIMEDOUT},
|
|
+ errno::{EFAULT, EINVAL, ENOMEM, EOVERFLOW, ETIMEDOUT},
|
|
signal::sigevent,
|
|
stdlib::getenv,
|
|
unistd::readlink,
|
|
@@ -280,7 +280,19 @@ pub extern "C" fn clock_nanosleep(
|
|
rqtp: *const timespec,
|
|
rmtp: *mut timespec,
|
|
) -> c_int {
|
|
- unimplemented!();
|
|
+ match clock_id {
|
|
+ CLOCK_REALTIME | CLOCK_MONOTONIC => {
|
|
+ if flags == TIMER_ABSTIME {
|
|
+ return EINVAL;
|
|
+ }
|
|
+ match unsafe { Sys::nanosleep(rqtp, rmtp) } {
|
|
+ Ok(()) => 0,
|
|
+ Err(Errno(ETIMEDOUT)) => ETIMEDOUT,
|
|
+ Err(Errno(e)) => e,
|
|
+ }
|
|
+ }
|
|
+ _ => EINVAL,
|
|
+ }
|
|
}
|
|
|
|
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/clock_getres.html>.
|