From 49cc01d4b5a126bc4eff1775a049e8e2d57bddc2 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Sun, 18 May 2025 10:58:33 -0400 Subject: [PATCH] libc: common: thrd: use sys_clock_nanosleep() instead of nanosleep() Reduce the dependency on POSIX by taking advantage of the newly added sys_clock_nanosleep(). Signed-off-by: Chris Friedt --- lib/libc/common/source/thrd/thrd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/libc/common/source/thrd/thrd.c b/lib/libc/common/source/thrd/thrd.c index d811fe31ce6..ad2cb72b602 100644 --- a/lib/libc/common/source/thrd/thrd.c +++ b/lib/libc/common/source/thrd/thrd.c @@ -10,6 +10,7 @@ #include #include #include +#include struct thrd_trampoline_arg { thrd_start_t func; @@ -44,7 +45,11 @@ thrd_t thrd_current(void) int thrd_sleep(const struct timespec *duration, struct timespec *remaining) { - return nanosleep(duration, remaining); + if (sys_clock_nanosleep(SYS_CLOCK_REALTIME, 0, duration, remaining) != 0) { + return thrd_error; + } + + return thrd_success; } void thrd_yield(void)