From 5c9fb9a0f3be945e19f4cdeb86a7732ae218888c Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Mon, 14 Dec 2015 11:23:33 +0000 Subject: server: Add time constants to go with spice_get_monotonic_time_ns() They clarify the time unit being used, reduce the need for casts and simplify calculations. Signed-off-by: Francois Gouget Acked-by: Christophe Fergeau --- server/utils.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'server/utils.h') diff --git a/server/utils.h b/server/utils.h index 3aa5be02..b85b1048 100644 --- a/server/utils.h +++ b/server/utils.h @@ -50,13 +50,16 @@ static inline int test_bit(int index, uint32_t val) typedef int64_t red_time_t; +#define NSEC_PER_SEC 1000000000LL +#define NSEC_PER_MILLISEC 1000000LL + /* FIXME: consider g_get_monotonic_time (), but in microseconds */ static inline red_time_t spice_get_monotonic_time_ns(void) { struct timespec time; clock_gettime(CLOCK_MONOTONIC, &time); - return (red_time_t) time.tv_sec * (1000 * 1000 * 1000) + time.tv_nsec; + return NSEC_PER_SEC * time.tv_sec + time.tv_nsec; } static inline red_time_t spice_get_monotonic_time_ms(void) -- cgit v1.2.3