diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/util.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/common/util.c b/common/util.c index c7ef2ac4..cb142a5e 100644 --- a/common/util.c +++ b/common/util.c @@ -1,8 +1,8 @@ #define _POSIX_C_SOURCE 200809L #include <ctype.h> -#include <float.h> #include <fcntl.h> #include <math.h> +#include <time.h> #include <stdlib.h> #include <string.h> #include <strings.h> @@ -10,6 +10,12 @@ #include "log.h" #include "util.h" +uint32_t get_current_time_msec(void) { + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + return now.tv_sec * 1000 + now.tv_nsec / 1000000; +} + int wrap(int i, int max) { return ((i % max) + max) % max; } |