tmv: introduce an initializer from nanoseconds

Interestingly, although tmv_t is a wrapper over nanoseconds, there is no
initializer from a raw nanosecond value. So add one.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
master
Vladimir Oltean 2020-08-18 02:19:28 +03:00 committed by Richard Cochran
parent 6325880094
commit cef87c6f03
1 changed files with 7 additions and 0 deletions

7
tmv.h
View File

@ -112,6 +112,13 @@ static inline int64_t tmv_to_nanoseconds(tmv_t x)
return x.ns; return x.ns;
} }
static inline tmv_t nanoseconds_to_tmv(int64_t ns)
{
tmv_t t;
t.ns = ns;
return t;
}
static inline TimeInterval tmv_to_TimeInterval(tmv_t x) static inline TimeInterval tmv_to_TimeInterval(tmv_t x)
{ {
if (x.ns < (int64_t)MIN_TMV_TO_TIMEINTERVAL) { if (x.ns < (int64_t)MIN_TMV_TO_TIMEINTERVAL) {