tmv: introduce a conversion helper from ptp_clock_time

This is useful when dealing with timestamps returned by various
ancillary PHC ioctl kernel APIs, such as extts.

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

8
tmv.h
View File

@ -20,6 +20,7 @@
#ifndef HAVE_TMV_H
#define HAVE_TMV_H
#include <linux/ptp_clock.h>
#include <time.h>
#include "ddt.h"
@ -160,4 +161,11 @@ static inline tmv_t timestamp_to_tmv(struct timestamp ts)
return t;
}
static inline tmv_t pct_to_tmv(struct ptp_clock_time pct)
{
tmv_t t;
t.ns = pct.sec * NS_PER_SEC + pct.nsec;
return t;
}
#endif