From b829580a33366231642c2ce7bed4c61612dbea50 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Thu, 16 Jan 2020 21:16:37 -0800 Subject: [PATCH] Provide a method to convert a tmv_t into a timespec. Currently there is a method to convert a timespec into a tmv_t, but not the other way round. This patch adds the missing function in anticipation of a new feature that will need this conversion. Signed-off-by: Richard Cochran --- tmv.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tmv.h b/tmv.h index cca4da7..f4a1a22 100644 --- a/tmv.h +++ b/tmv.h @@ -143,6 +143,16 @@ static inline tmv_t timespec_to_tmv(struct timespec ts) return t; } +static inline struct timespec tmv_to_timespec(tmv_t t) +{ + struct timespec ts; + + ts.tv_sec = t.ns / NS_PER_SEC; + ts.tv_nsec = t.ns % NS_PER_SEC; + + return ts; +} + static inline tmv_t timestamp_to_tmv(struct timestamp ts) { tmv_t t;