9 #include <sys/select.h>
11 int gettimeofday (struct timeval *__restrict, void *__restrict);
13 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
14 || defined(_BSD_SOURCE)
17 #define ITIMER_VIRTUAL 1
21 struct timeval it_interval;
22 struct timeval it_value;
25 int getitimer (int, struct itimerval *);
26 int setitimer (int, const struct itimerval *__restrict, struct itimerval *__restrict);
27 int utimes (const char *, const struct timeval [2]);
31 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
36 int futimes(int, const struct timeval [2]);
37 int futimesat(int, const char *, const struct timeval [2]);
38 int lutimes(const char *, const struct timeval [2]);
39 int settimeofday(const struct timeval *, const struct timezone *);
40 int adjtime (const struct timeval *, struct timeval *);
41 #define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
42 #define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
43 #define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \
44 (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec)
45 #define timeradd(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
46 ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
47 ((a)->tv_usec -= 1000000, (a)->tv_sec++) )
48 #define timersub(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
49 ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
50 ((a)->tv_usec += 1000000, (a)->tv_sec--) )
53 #if defined(_GNU_SOURCE)
54 #define TIMEVAL_TO_TIMESPEC(tv, ts) ( \
55 (ts)->tv_sec = (tv)->tv_sec, \
56 (ts)->tv_nsec = (tv)->tv_usec * 1000, \
58 #define TIMESPEC_TO_TIMEVAL(tv, ts) ( \
59 (tv)->tv_sec = (ts)->tv_sec, \
60 (tv)->tv_usec = (ts)->tv_nsec / 1000, \