Add sem_clockwait and fix timedwait clock_id

This commit is contained in:
Wildan M
2025-08-28 12:58:54 +07:00
parent 7ab71a0ad5
commit 80ea3bc6a1
2 changed files with 13 additions and 5 deletions
+2 -2
View File
@@ -51,7 +51,7 @@ impl Semaphore {
}
}
pub fn wait(&self, timeout_opt: Option<&timespec>) -> Result<(), ()> {
pub fn wait(&self, timeout_opt: Option<&timespec>, clock_id: clockid_t) -> Result<(), ()> {
loop {
let value = self.try_wait();
@@ -61,7 +61,7 @@ impl Semaphore {
if let Some(timeout) = timeout_opt {
let mut time = timespec::default();
unsafe { clock_gettime(CLOCK_MONOTONIC, &mut time) };
unsafe { clock_gettime(clock_id, &mut time) };
if (time.tv_sec > timeout.tv_sec)
|| (time.tv_sec == timeout.tv_sec && time.tv_nsec >= timeout.tv_nsec)
{