Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sleep.c « posix « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0d6cd710ded80381001f35a28301e6a0d591885e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* libc/posix/sleep.c - sleep function */

/* Written 2000 by Werner Almesberger */

#ifdef HAVE_NANOSLEEP

#include <errno.h>
#include <time.h>
#include <unistd.h>
#include <limits.h>

unsigned sleep(unsigned seconds)
{
    struct timespec ts;

    ts.tv_sec = seconds;
    ts.tv_nsec = 0;
    if (!nanosleep(&ts,&ts)) return 0;
    if (errno == EINTR) return ts.tv_sec & UINT_MAX;
    return -1;
}

#endif