libroot: Use timespec_to_bigtime in clock_nanosleep.

No functional change intended.
This commit is contained in:
Augustin Cavalier 2024-10-14 13:00:20 -04:00
parent 2a39b810fa
commit a2afad0d66

View File

@ -14,6 +14,7 @@
#include <OS.h>
#include <errno_private.h>
#include <time_private.h>
#include <syscall_utils.h>
#include <syscalls.h>
@ -106,12 +107,10 @@ clock_nanosleep(clockid_t clockID, int flags, const struct timespec* time,
struct timespec* remainingTime)
{
// convert time to microseconds (round up)
if (time->tv_sec < 0 || time->tv_nsec < 0 || time->tv_nsec >= 1000000000)
bigtime_t microSeconds;
if (!timespec_to_bigtime(*time, microSeconds))
RETURN_AND_TEST_CANCEL(EINVAL);
bigtime_t microSeconds = (bigtime_t)time->tv_sec * 1000000
+ (time->tv_nsec + 999) / 1000;
// get timeout flags
uint32 timeoutFlags;
if ((flags & TIMER_ABSTIME) != 0) {