3 * sys/time.h compatibility shim
6 #if defined(_MSC_VER) && (_MSC_VER >= 1900)
7 #include <../ucrt/time.h>
8 #elif defined(_MSC_VER) && (_MSC_VER < 1900)
9 #include <../include/time.h>
14 #ifndef _COMPAT_TIME_H
15 #define _COMPAT_TIME_H
17 #ifndef CLOCK_MONOTONIC
18 #define CLOCK_MONOTONIC CLOCK_REALTIME
21 #ifndef CLOCK_REALTIME
22 #define CLOCK_REALTIME 0
25 #ifndef HAVE_CLOCK_GETTIME
26 typedef int clockid_t;
27 int clock_gettime(clockid_t, struct timespec *);
30 #ifdef HAVE_TIMESPECSUB
34 #ifndef HAVE_TIMESPECSUB
35 #define timespecadd(tsp, usp, vsp) \
37 (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \
38 (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \
39 if ((vsp)->tv_nsec >= 1000000000L) { \
41 (vsp)->tv_nsec -= 1000000000L; \
45 #define timespecsub(tsp, usp, vsp) \
47 (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
48 (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
49 if ((vsp)->tv_nsec < 0) { \
51 (vsp)->tv_nsec += 1000000000L; \
55 #define timespeccmp(tsp, usp, cmp) \
56 (((tsp)->tv_sec == (usp)->tv_sec) ? \
57 ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
58 ((tsp)->tv_sec cmp (usp)->tv_sec))
61 #endif /* _COMPAT_TIME_H */