Skip to content

Commit 1e98749

Browse files
committed
fix(zephyr): avoid including errno headers in os_nanosleep to keep CMake unchanged
1 parent a3d7396 commit 1e98749

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

core/shared/platform/common/posix/posix_sleep.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <time.h>
77

88
#include "platform_api_extension.h"
9-
#include "libc_errno.h"
109

1110
int
1211
os_usleep(uint32 usec)
@@ -20,12 +19,23 @@ os_usleep(uint32 usec)
2019
return ret == 0 ? 0 : -1;
2120
}
2221

22+
/*
23+
* This function relies on a small workaround (hardcoded errno values)
24+
* to avoid including <errno.h> or the project-specific `libc_errno.h`,
25+
* thus preventing changes to the current CMake configuration.
26+
*/
2327
__wasi_errno_t
2428
os_nanosleep(const os_timespec *req, os_timespec *rem)
2529
{
26-
int ret;
30+
int ret = 0;
2731

2832
ret = nanosleep(req, rem);
2933

30-
return convert_errno(ret);
34+
switch(ret)
35+
{
36+
case 14 /* EFAULT */: return __WASI_EFAULT;
37+
case 4 /* EINTR */: return __WASI_EFAULT;
38+
case 22 /* EINVAL */: return __WASI_EINVAL;
39+
case 0: return __WASI_ESUCCESS;
40+
}
3141
}

0 commit comments

Comments
 (0)