summaryrefslogtreecommitdiffstats
path: root/libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c')
-rw-r--r--libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c b/libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c
new file mode 100644
index 0000000..5f26c5c
--- /dev/null
+++ b/libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c
@@ -0,0 +1,15 @@
+// Copyright (c) 2015 Nuxi, https://nuxi.nl/
+//
+// SPDX-License-Identifier: BSD-2-Clause
+
+#include <errno.h>
+#include <time.h>
+
+int nanosleep(const struct timespec *rqtp, struct timespec *rem) {
+ int error = clock_nanosleep(CLOCK_REALTIME, 0, rqtp, rem);
+ if (error != 0) {
+ errno = error;
+ return -1;
+ }
+ return 0;
+}