lib: posix: sleep() should report unslept time in seconds
In the case that `sleep()` is interrupted, the POSIX spec requires it to return the number of "unslept" seconds (i.e. the number of seconds requested minus the number of seconds actually slept). Since `k_sleep()` already returns the amount of "unslept" time in ms, we can simply use that. Signed-off-by: Chris Friedt <cfriedt@meta.com>
This commit is contained in:
parent
23a1f0a672
commit
dcfcc6454b
@ -14,8 +14,12 @@
|
||||
*/
|
||||
unsigned sleep(unsigned int seconds)
|
||||
{
|
||||
k_sleep(K_SECONDS(seconds));
|
||||
return 0;
|
||||
int rem;
|
||||
|
||||
rem = k_sleep(K_SECONDS(seconds));
|
||||
__ASSERT_NO_MSG(rem >= 0);
|
||||
|
||||
return rem / MSEC_PER_SEC;
|
||||
}
|
||||
/**
|
||||
* @brief Suspend execution for microsecond intervals.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user