util: add conversion between intervals and NTP 64-bit format

This will be needed to save PTP correction in NTP timestamp format.
This commit is contained in:
Miroslav Lichvar
2023-09-21 14:02:11 +02:00
parent e08a0ee668
commit bf616eafa1
3 changed files with 72 additions and 0 deletions

4
util.h
View File

@@ -163,6 +163,10 @@ extern void UTI_Ntp64ToTimespec(const NTP_int64 *src, struct timespec *dest);
/* Calculate a - b in any epoch */
extern double UTI_DiffNtp64ToDouble(const NTP_int64 *a, const NTP_int64 *b);
/* Convert a difference in double (not a timestamp) from and to NTP format */
extern double UTI_Ntp64ToDouble(NTP_int64 *src);
extern void UTI_DoubleToNtp64(double src, NTP_int64 *dest);
/* Check if time + offset is sane */
extern int UTI_IsTimeOffsetSane(const struct timespec *ts, double offset);