summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/thread/thrd_sleep.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-top-half/musl/src/thread/thrd_sleep.c')
-rw-r--r--libc-top-half/musl/src/thread/thrd_sleep.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/thread/thrd_sleep.c b/libc-top-half/musl/src/thread/thrd_sleep.c
new file mode 100644
index 0000000..97de534
--- /dev/null
+++ b/libc-top-half/musl/src/thread/thrd_sleep.c
@@ -0,0 +1,14 @@
+#include <threads.h>
+#include <time.h>
+#include <errno.h>
+#include "syscall.h"
+
+int thrd_sleep(const struct timespec *req, struct timespec *rem)
+{
+ int ret = -__clock_nanosleep(CLOCK_REALTIME, 0, req, rem);
+ switch (ret) {
+ case 0: return 0;
+ case -EINTR: return -1; /* value specified by C11 */
+ default: return -2;
+ }
+}