summaryrefslogtreecommitdiff
path: root/server/utils.h
diff options
context:
space:
mode:
authorFrancois Gouget <fgouget@codeweavers.com>2015-12-14 11:23:33 +0000
committerFrediano Ziglio <fziglio@redhat.com>2015-12-14 11:24:34 +0000
commit5c9fb9a0f3be945e19f4cdeb86a7732ae218888c (patch)
treeef47e5a59816f155aa3a49304cb56f87e61478d4 /server/utils.h
parentcbc4e07682a8a40f8d270e7a092973ac4f93f36d (diff)
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 <fgouget@codeweavers.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
Diffstat (limited to 'server/utils.h')
-rw-r--r--server/utils.h5
1 files changed, 4 insertions, 1 deletions
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)