a0ed8e0fc183314aa68c5a78a164fc5204c99141
[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 <features.h>
8
9 #include <sys/select.h>
10
11 int gettimeofday (struct timeval *__restrict, void *__restrict);
12
13 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
14  || defined(_BSD_SOURCE)
15
16 #define ITIMER_REAL    0
17 #define ITIMER_VIRTUAL 1
18 #define ITIMER_PROF    2
19
20 struct itimerval
21 {
22         struct timeval it_interval;
23         struct timeval it_value;
24 };
25
26 int getitimer (int, struct itimerval *);
27 int setitimer (int, const struct itimerval *__restrict, struct itimerval *__restrict);
28 int utimes (const char *, const struct timeval [2]);
29
30 #endif
31
32 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
33 int futimes(int, const struct timeval [2]);
34 int lutimes(const char *, const struct timeval [2]);
35 int settimeofday (const struct timeval *, void *);
36 int adjtime (const struct timeval *, struct timeval *);
37 struct timezone {
38         int tz_minuteswest;
39         int tz_dsttime;
40 };
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) ( (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) ( (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--) )
51 #endif
52
53 #ifdef __cplusplus
54 }
55 #endif
56 #endif