fa98944264752fc3230c463d5f473be21f0ffd73
[musl] / include / sys / time.h
1 #ifndef _SYS_TIME_H
2 #define _SYS_TIME_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6
7 #include <sys/select.h>
8
9 int gettimeofday (struct timeval *, void *);
10
11 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
12
13 #define ITIMER_REAL    0
14 #define ITIMER_VIRTUAL 1
15 #define ITIMER_PROF    2
16
17 struct itimerval
18 {
19         struct timeval it_interval;
20         struct timeval it_value;
21 };
22
23 int getitimer (int, struct itimerval *);
24 int setitimer (int, const struct itimerval *, struct itimerval *);
25 int utimes (const char *, const struct timeval [2]);
26
27 #endif
28
29 #ifdef _GNU_SOURCE
30 int futimes(int, const struct timeval [2]);
31 int lutimes(const char *, const struct timeval [2]);
32 int settimeofday (const struct timeval *, void *);
33 int adjtime (const struct timeval *, struct timeval *);
34 struct timezone {
35         int tz_minuteswest;
36         int tz_dsttime;
37 };
38 #define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
39 #define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
40 #define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \
41         (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec)
42 #define timeradd(s,t,a) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
43         ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
44         ((a)->tv_usec -= 1000000, (a)->tv_sec++) )
45 #define timersub(s,t,a) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
46         ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
47         ((a)->tv_usec += 1000000, (a)->tv_sec--) )
48 #endif
49
50 #ifdef __cplusplus
51 }
52 #endif
53 #endif