From dc13bb827d6b7dd40d76ff6f7f3f06688e7d58a0 Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Fri, 5 Jun 2020 17:44:30 -0400 Subject: util: fix and move `get_current_time_msec` into a util file This commit makes `get_current_time_msec` correctly return milliseconds as opposed to microseconds. It also considers the value of `tv_sec`, so we don't lose occasionally go back in time by one second. Finally, the function is moved into `util/time.cc` so that it can be reused elsewhere without having to consider these pitfalls. --- include/util/time.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 include/util/time.h (limited to 'include/util') diff --git a/include/util/time.h b/include/util/time.h new file mode 100644 index 00000000..a24656a9 --- /dev/null +++ b/include/util/time.h @@ -0,0 +1,9 @@ +#ifndef UTIL_TIME_H +#define UTIL_TIME_H + +/** + * Get the current time, in milliseconds. + */ +uint32_t get_current_time_msec(void); + +#endif -- cgit v1.2.3