File tree Expand file tree Collapse file tree
core/shared/platform/common/posix Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66#include <time.h>
77
88#include "platform_api_extension.h"
9- #include "libc_errno.h"
109
1110int
1211os_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
2428os_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}
You can’t perform that action at this time.
0 commit comments