summaryrefslogtreecommitdiff
path: root/src/unistd/sleep.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/unistd/sleep.c')
-rw-r--r--src/unistd/sleep.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/unistd/sleep.c b/src/unistd/sleep.c
index 656f70f9..e4f8bb1c 100644
--- a/src/unistd/sleep.c
+++ b/src/unistd/sleep.c
@@ -1,25 +1,26 @@
-#include "stddef.h"
-#include "sys/types.h"
-#include <unistd.h>
-#include "time.h"
-
-#if _POSIX_C_SOURCE < 199309
-#define nanosleep __nanosleep
-#include "time/struct_timespec.c"
-#include "time/nanosleep.c"
+#if ((!defined _POSIX_C_SOURCE) || (_POSIX_C_SOURCE < 199309L))
+#undef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 199309L
#endif
+#include <sys/types.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <time.h>
+#include "_syscall.h"
+
unsigned sleep(unsigned seconds)
{
struct timespec tosleep = { seconds, 0 };
struct timespec remaining = { 0 , 0 };
- if (nanosleep(&tosleep, &remaining) == -1) {
+ if (__scall2(nanosleep, &tosleep, &remaining) < 0) {
return seconds;
}
return remaining.tv_sec;
}
+
/*
POSIX(1)
*/