util: add UTI_IsZeroTimespec()
This commit is contained in:
parent
45f86122fa
commit
c8373f1649
4 changed files with 14 additions and 3 deletions
|
@ -1770,9 +1770,9 @@ NCR_SlewTimes(NCR_Instance inst, struct timespec *when, double dfreq, double dof
|
||||||
{
|
{
|
||||||
double delta;
|
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);
|
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);
|
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;
|
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",
|
DEBUG_LOG(LOGF_Refclock, "PPS sample ignored seq=%lu ts=%lu.%09lu",
|
||||||
seq, ts.tv_sec, ts.tv_nsec);
|
seq, ts.tv_sec, ts.tv_nsec);
|
||||||
return 0;
|
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
|
void
|
||||||
UTI_TimevalToTimespec(struct timeval *tv, struct timespec *ts)
|
UTI_TimevalToTimespec(struct timeval *tv, struct timespec *ts)
|
||||||
{
|
{
|
||||||
|
|
3
util.h
3
util.h
|
@ -37,6 +37,9 @@
|
||||||
/* Zero a timespec */
|
/* Zero a timespec */
|
||||||
extern void UTI_ZeroTimespec(struct timespec *ts);
|
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 */
|
/* Convert a timeval into a timespec */
|
||||||
extern void UTI_TimevalToTimespec(struct timeval *tv, struct timespec *ts);
|
extern void UTI_TimevalToTimespec(struct timeval *tv, struct timespec *ts);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue