summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-08-16 18:28:04 -0400
committerJakob Kaivo <jkk@ung.org>2020-08-16 18:28:04 -0400
commit25c99d499407dff25f2528de2cb8652afa26288c (patch)
tree3c5c7f64921443f41a69030ec4a569c81f366b9c
parent089ecbeb151f896cbe5ef5d3549476d02c6fca78 (diff)
force definition of struct timespec
-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)
*/