Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
scenefx/include/util/time.h (707B)
1 #ifndef UTIL_TIME_H
2 #define UTIL_TIME_H
3
4 #include <stdint.h>
5 #include <time.h>
6
7 static const long NSEC_PER_SEC = 1000000000;
8
9 /**
10 * Get the current time, in milliseconds.
11 */
12 int64_t get_current_time_msec(void);
13
14 /**
15 * Convert a timespec to milliseconds.
16 */
17 int64_t timespec_to_msec(const struct timespec *a);
18
19 /**
20 * Convert a timespec to nanoseconds.
21 */
22 int64_t timespec_to_nsec(const struct timespec *a);
23
24 /**
25 * Convert nanoseconds to a timespec.
26 */
27 void timespec_from_nsec(struct timespec *r, int64_t nsec);
28
29 /**
30 * Subtracts timespec `b` from timespec `a`, and stores the difference in `r`.
31 */
32 void timespec_sub(struct timespec *r, const struct timespec *a,
33 const struct timespec *b);
34
35 #endif