Add sem_timedwait

This commit is contained in:
Wildan M
2025-08-28 08:36:16 +07:00
parent 3a08d40c67
commit 7ab71a0ad5
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
sys_includes = []
sys_includes = ["time.h"]
include_guard = "_RELIBC_SEMAPHORE_H"
language = "C"
style = "Type"
+9 -1
View File
@@ -2,7 +2,7 @@
//!
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/semaphore.h.html>.
use crate::platform::types::*;
use crate::{header::time::timespec, platform::types::*};
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/semaphore.h.html>.
// TODO: Statically verify size and align
@@ -83,6 +83,14 @@ pub unsafe extern "C" fn sem_wait(sem: *mut sem_t) -> c_int {
0
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sem_timedwait.html>.
#[no_mangle]
pub unsafe extern "C" fn sem_timedwait(sem: *mut sem_t, abstime: *const timespec) -> c_int {
get(sem).wait(Some(&*abstime));
0
}
unsafe fn get<'any>(sem: *mut sem_t) -> &'any RlctSempahore {
&*sem.cast()
}