function to convert monotonic_t to microsecs

This commit is contained in:
Kovid Goyal
2023-10-24 16:38:17 +05:30
parent d94a5bd386
commit 467e7e5041

View File

@@ -13,6 +13,7 @@
#define MONOTONIC_T_MAX INT64_MAX
#define MONOTONIC_T_MIN INT64_MIN
#define MONOTONIC_T_1e6 1000000ll
#define MONOTONIC_T_1e3 1000ll
#define MONOTONIC_T_1e9 1000000000ll
typedef int64_t monotonic_t;
@@ -42,6 +43,12 @@ monotonic_t_to_ms(monotonic_t time) {
return (int)(time / MONOTONIC_T_1e6);
}
static inline int
monotonic_t_to_us(monotonic_t time) {
return (int)(time / MONOTONIC_T_1e3);
}
static inline double
monotonic_t_to_s_double(monotonic_t time) {
return ((double)time) / 1e9;