From 25c99d499407dff25f2528de2cb8652afa26288c Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Sun, 16 Aug 2020 18:28:04 -0400 Subject: force definition of struct timespec --- src/unistd/sleep.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') 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 -#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 +#include +#include +#include +#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) */ -- cgit v1.2.1