src/util/nsec.h
raw| 1 | #pragma once |
| 2 | |
| 3 | /* |
| 4 | * Nanosecond Time Management |
| 5 | */ |
| 6 | |
| 7 | #include <c-stdaux.h> |
| 8 | #include <stdlib.h> |
| 9 | #include <sys/time.h> |
| 10 | #include <time.h> |
| 11 | |
| 12 | typedef uint64_t nsec_t; |
| 13 | |
| 14 | #define NSEC_PRI PRIu64 |
| 15 | |
| 16 | /* nsec */ |
| 17 | |
| 18 | nsec_t nsec_now(clockid_t clock); |
| 19 | void nsec_sleep(clockid_t clock, nsec_t until); |
| 20 | |
| 21 | /* inline helpers */ |
| 22 | |
| 23 | static inline uint64_t nsec_to_usec(nsec_t t) { |
| 24 | return t / 1000; |
| 25 | } |