#include #include #include "syscall.h" #include "libc.h" #include "threads.h" /* Roughly __syscall already returns the right thing: 0 if all went well or a negative error indication, otherwise. */ int thrd_sleep(const struct timespec *req, struct timespec *rem) { int ret = __syscall(SYS_nanosleep, req, rem); switch (ret) { case 0: return 0; /* error described by POSIX: */ /* EINTR The nanosleep() function was interrupted by a signal. */ /* The C11 wording is: */ /* -1 if it has been interrupted by a signal */ case -EINTR: return -1; /* EINVAL: described by POSIX */ /* EFAULT: described for linux */ default: return -2; } }