Add sem_timedwait
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
sys_includes = []
|
||||
sys_includes = ["time.h"]
|
||||
include_guard = "_RELIBC_SEMAPHORE_H"
|
||||
language = "C"
|
||||
style = "Type"
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user