mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 18:25:07 -05:00
util: add UTI_IsZeroTimespec()
This commit is contained in:
@@ -1770,9 +1770,9 @@ NCR_SlewTimes(NCR_Instance inst, struct timespec *when, double dfreq, double dof
|
||||
{
|
||||
double delta;
|
||||
|
||||
if (inst->local_rx.tv_sec || inst->local_rx.tv_nsec)
|
||||
if (!UTI_IsZeroTimespec(&inst->local_rx))
|
||||
UTI_AdjustTimespec(&inst->local_rx, when, &inst->local_rx, &delta, dfreq, doffset);
|
||||
if (inst->local_tx.tv_sec || inst->local_tx.tv_nsec)
|
||||
if (!UTI_IsZeroTimespec(&inst->local_tx))
|
||||
UTI_AdjustTimespec(&inst->local_tx, when, &inst->local_tx, &delta, dfreq, doffset);
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ static int pps_poll(RCL_Instance instance)
|
||||
ts = pps_info.clear_timestamp;
|
||||
}
|
||||
|
||||
if (seq == pps->last_seq || (ts.tv_sec == 0 && ts.tv_nsec == 0)) {
|
||||
if (seq == pps->last_seq || UTI_IsZeroTimespec(&ts)) {
|
||||
DEBUG_LOG(LOGF_Refclock, "PPS sample ignored seq=%lu ts=%lu.%09lu",
|
||||
seq, ts.tv_sec, ts.tv_nsec);
|
||||
return 0;
|
||||
|
||||
8
util.c
8
util.c
@@ -47,6 +47,14 @@ UTI_ZeroTimespec(struct timespec *ts)
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
int
|
||||
UTI_IsZeroTimespec(struct timespec *ts)
|
||||
{
|
||||
return !ts->tv_sec && !ts->tv_nsec;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
UTI_TimevalToTimespec(struct timeval *tv, struct timespec *ts)
|
||||
{
|
||||
|
||||
3
util.h
3
util.h
@@ -37,6 +37,9 @@
|
||||
/* Zero a timespec */
|
||||
extern void UTI_ZeroTimespec(struct timespec *ts);
|
||||
|
||||
/* Check if a timespec is zero */
|
||||
extern int UTI_IsZeroTimespec(struct timespec *ts);
|
||||
|
||||
/* Convert a timeval into a timespec */
|
||||
extern void UTI_TimevalToTimespec(struct timeval *tv, struct timespec *ts);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user