diff options
Diffstat (limited to '')
-rw-r--r-- | usr/klibc/sleep.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/usr/klibc/sleep.c b/usr/klibc/sleep.c new file mode 100644 index 0000000..47dfd29 --- /dev/null +++ b/usr/klibc/sleep.c @@ -0,0 +1,22 @@ +/* + * sleep.c + */ + +#include <errno.h> +#include <stdlib.h> +#include <time.h> +#include <unistd.h> + +unsigned int sleep(unsigned int seconds) +{ + struct timespec ts; + + ts.tv_sec = seconds; + ts.tv_nsec = 0; + if (!nanosleep(&ts, &ts)) + return 0; + else if (errno == EINTR) + return ts.tv_sec; + else + return -1; +} |