util: add function to subtract NTP timestamps

This will be needed to work with monotonic timestamps, which don't have
a stable epoch and cannot be converted to timespec.
This commit is contained in:
Miroslav Lichvar
2021-11-10 14:28:53 +01:00
parent a97ca73704
commit a652ce7d0e
3 changed files with 21 additions and 1 deletions

3
util.h
View File

@@ -155,6 +155,9 @@ extern void UTI_TimespecToNtp64(const struct timespec *src, NTP_int64 *dest,
/* Convert an NTP timestamp into a timespec */
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);
/* Check if time + offset is sane */
extern int UTI_IsTimeOffsetSane(const struct timespec *ts, double offset);