/libfido2/openbsd-compat/time.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Public domain |
3 | | * sys/time.h compatibility shim |
4 | | */ |
5 | | |
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> |
10 | | #else |
11 | | #include <time.h> |
12 | | #endif |
13 | | |
14 | | #ifndef _COMPAT_TIME_H |
15 | | #define _COMPAT_TIME_H |
16 | | |
17 | | #ifndef CLOCK_MONOTONIC |
18 | | #define CLOCK_MONOTONIC CLOCK_REALTIME |
19 | | #endif |
20 | | |
21 | | #ifndef CLOCK_REALTIME |
22 | | #define CLOCK_REALTIME 0 |
23 | | #endif |
24 | | |
25 | | #ifndef HAVE_CLOCK_GETTIME |
26 | | typedef int clockid_t; |
27 | | int clock_gettime(clockid_t, struct timespec *); |
28 | | #endif |
29 | | |
30 | | #ifdef HAVE_TIMESPECSUB |
31 | | #include <sys/time.h> |
32 | | #endif |
33 | | |
34 | | #ifndef HAVE_TIMESPECSUB |
35 | | #define timespecsub(tsp, usp, vsp) \ |
36 | 0 | do { \ |
37 | 0 | (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ |
38 | 0 | (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ |
39 | 0 | if ((vsp)->tv_nsec < 0) { \ |
40 | 0 | (vsp)->tv_sec--; \ |
41 | 0 | (vsp)->tv_nsec += 1000000000L; \ |
42 | 0 | } \ |
43 | 0 | } while (0) |
44 | | #endif |
45 | | |
46 | | #endif /* _COMPAT_TIME_H */ |