From 1e987494141961f83a2ee09f26c4764fd59e314e Mon Sep 17 00:00:00 2001 From: Lucas Abad <149054121+lucasAbadFr@users.noreply.github.com> Date: Fri, 6 Feb 2026 19:55:59 +0100 Subject: [PATCH] fix(zephyr): avoid including errno headers in os_nanosleep to keep CMake unchanged --- core/shared/platform/common/posix/posix_sleep.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/shared/platform/common/posix/posix_sleep.c b/core/shared/platform/common/posix/posix_sleep.c index 541c67192..cefcfbc78 100644 --- a/core/shared/platform/common/posix/posix_sleep.c +++ b/core/shared/platform/common/posix/posix_sleep.c @@ -6,7 +6,6 @@ #include #include "platform_api_extension.h" -#include "libc_errno.h" int os_usleep(uint32 usec) @@ -20,12 +19,23 @@ os_usleep(uint32 usec) return ret == 0 ? 0 : -1; } +/* + * This function relies on a small workaround (hardcoded errno values) + * to avoid including or the project-specific `libc_errno.h`, + * thus preventing changes to the current CMake configuration. + */ __wasi_errno_t os_nanosleep(const os_timespec *req, os_timespec *rem) { - int ret; + int ret = 0; ret = nanosleep(req, rem); - return convert_errno(ret); + switch(ret) + { + case 14 /* EFAULT */: return __WASI_EFAULT; + case 4 /* EINTR */: return __WASI_EFAULT; + case 22 /* EINVAL */: return __WASI_EINVAL; + case 0: return __WASI_ESUCCESS; + } } \ No newline at end of file