add descriptions to sleep and nanosleep
This commit is contained in:
+1
-1
@@ -38,7 +38,7 @@ ptr_as_ptr = "warn" # TODO review occurrences
|
||||
ptr_cast_constness = "warn" # TODO review occurrences
|
||||
ref_as_ptr = "warn" # TODO review occurrences
|
||||
upper_case_acronyms = "allow" # TODO review occurrences
|
||||
zero_ptr = "warn" # must allow on public constants due to cbindgen issue
|
||||
zero_ptr = "deny" # must allow on public constants due to cbindgen issue
|
||||
|
||||
[workspace.lints.rust]
|
||||
dangling_pointers_from_temporaries = "deny"
|
||||
|
||||
@@ -485,7 +485,21 @@ pub unsafe extern "C" fn mktime(timeptr: *mut tm) -> time_t {
|
||||
timestamp
|
||||
}
|
||||
|
||||
// FIXME seems redox-rt sys posix_nanosleep calls wrapper which disables signals
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/nanosleep.html>.
|
||||
///
|
||||
/// Causes the current thread to be suspended from execution until either the
|
||||
/// time interval specified by `rqtp` has elapsed or a signal is delivered to
|
||||
/// the calling thread, and its action is to invoke a signal-catching function
|
||||
/// or to terminate the process.
|
||||
///
|
||||
/// Has no effect on the action or blockage of any signal.
|
||||
///
|
||||
/// Upon success, returns `0`. Upon failure, returns `-1` and sets errno to
|
||||
/// indicate the error. If `rmtp` is non-NULL and `nanosleep()` is interrupted
|
||||
/// by a signal, returns `-1` and updates `rmtp` to contain the requested time
|
||||
/// minus the actually elapsed time. If `rmtp` is NULL the remaining time is
|
||||
/// not returned.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int {
|
||||
unsafe { Sys::nanosleep(rqtp, rmtp) }
|
||||
|
||||
@@ -1047,6 +1047,14 @@ pub extern "C" fn setuid(uid: uid_t) -> c_int {
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sleep.html>.
|
||||
///
|
||||
/// Causes the calling thread to be suspended from execution until either the
|
||||
/// number of realtime seconds by the specified argument `seconds` has elapsed
|
||||
/// or a signal is delivered to the calling thread and its action is to invoke
|
||||
/// a signal-catching function or to terminate the process.
|
||||
///
|
||||
/// Upon success, returns `0`. Upon interruption by a signal, returns the
|
||||
/// unslept amount in seconds.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn sleep(seconds: c_uint) -> c_uint {
|
||||
let rqtp = timespec {
|
||||
@@ -1062,8 +1070,8 @@ pub extern "C" fn sleep(seconds: c_uint) -> c_uint {
|
||||
// If sleep() returns due to delivery of a signal, the return value shall be the "unslept" amount
|
||||
// (the requested time minus the time actually slept) in seconds.
|
||||
match unsafe { Sys::nanosleep(&raw const rqtp, &raw mut rmtp) } {
|
||||
Err(Errno(EINTR)) => rmtp.tv_sec as c_uint,
|
||||
r => 0,
|
||||
Err(Errno(_)) => rmtp.tv_sec as c_uint,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user