From 3558089a22451fa8b2e977942be96f64211c6653 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Tue, 8 Jun 2021 18:55:52 +0300 Subject: [PATCH] get_now_monotonic_u64() --- src/libs/tools.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libs/tools.h b/src/libs/tools.h index ec0cb95..381b820 100644 --- a/src/libs/tools.h +++ b/src/libs/tools.h @@ -110,10 +110,14 @@ INLINE long double get_now_monotonic(void) { return (long double)sec + ((long double)msec) / 1000; } -INLINE uint64_t get_now_id(void) { +INLINE uint64_t get_now_monotonic_u64(void) { struct timespec ts; assert(!clock_gettime(X_CLOCK_MONOTONIC, &ts)); - uint64_t now = (uint64_t)(ts.tv_nsec / 1000) + (uint64_t)ts.tv_sec * 1000000; + return (uint64_t)(ts.tv_nsec / 1000) + (uint64_t)ts.tv_sec * 1000000; +} + +INLINE uint64_t get_now_id(void) { + uint64_t now = get_now_monotonic_u64(); return (uint64_t)triple_u32(now) | ((uint64_t)triple_u32(now + 12345) << 32); }