2 * Copyright 2002-2012 Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
13 time_t tv_sec
; /* seconds */
14 suseconds_t tv_usec
; /* microseconds */
17 #include <sys/select.h>
18 /* circular dependency: fd_set needs to be defined and the
19 * select prototype exported by this file, but <sys/select.h>
20 * needs struct timeval.
29 struct timeval it_interval
;
30 struct timeval it_value
;
33 #define ITIMER_REAL 1 /* real time */
34 #define ITIMER_VIRTUAL 2 /* process virtual time */
35 #define ITIMER_PROF 3 /* both */
42 extern int getitimer(int which
, struct itimerval
*value
);
43 extern int setitimer(int which
, const struct itimerval
*value
, struct itimerval
*oldValue
);
44 extern int gettimeofday(struct timeval
*tv
, void *tz
);
46 extern int utimes(const char *path
, const struct timeval times
[2]);
53 /* BSDish macros operating on timeval structs */
54 #define timeradd(a, b, res) \
56 (res)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
57 (res)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
58 if ((res)->tv_usec >= 1000000) { \
59 (res)->tv_usec -= 1000000; \
63 #define timersub(a, b, res) \
65 (res)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
66 (res)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
67 if ((res)->tv_usec < 0) { \
68 (res)->tv_usec += 1000000; \
72 #define timerclear(a) ((a)->tv_sec = (a)->tv_usec = 0)
73 #define timerisset(a) ((a)->tv_sec != 0 || (a)->tv_usec != 0)
74 #define timercmp(a, b, cmp) ((a)->tv_sec == (b)->tv_sec \
75 ? (a)->tv_usec cmp (b)->tv_usec : (a)->tv_sec cmp (b)->tv_sec)
77 #endif /* _SYS_TIME_H */