tmv: Generalise tmv_eq() to tmv_cmp()
Time values are compared using an inequality test in mmedian.c Generalise tmv_eq() to tmv_cmp() (by analogy with memcmp()) and replace existing uses of tmv_eq(). Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>master
parent
ea82ae6c28
commit
1b7ff890be
2
clock.c
2
clock.c
|
@ -578,7 +578,7 @@ static enum servo_state clock_no_adjust(struct clock *c, tmv_t ingress,
|
||||||
if (f->count < f->max_count) {
|
if (f->count < f->max_count) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
if (tmv_eq(ingress, f->ingress1)) {
|
if (tmv_cmp(ingress, f->ingress1) == 0) {
|
||||||
pr_warning("bad timestamps in rate ratio calculation");
|
pr_warning("bad timestamps in rate ratio calculation");
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,8 @@ static tmv_t mmedian_sample(struct filter *filter, tmv_t sample)
|
||||||
|
|
||||||
/* Insert index of the new value to order. */
|
/* Insert index of the new value to order. */
|
||||||
for (i = m->cnt - 1; i > 0; i--) {
|
for (i = m->cnt - 1; i > 0; i--) {
|
||||||
if (m->samples[m->order[i - 1]] <= m->samples[m->index])
|
if (tmv_cmp(m->samples[m->order[i - 1]],
|
||||||
|
m->samples[m->index]) <= 0)
|
||||||
break;
|
break;
|
||||||
m->order[i] = m->order[i - 1];
|
m->order[i] = m->order[i - 1];
|
||||||
}
|
}
|
||||||
|
|
2
port.c
2
port.c
|
@ -933,7 +933,7 @@ static void port_nrate_calculate(struct port *p, tmv_t origin, tmv_t ingress)
|
||||||
if (n->count < n->max_count) {
|
if (n->count < n->max_count) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tmv_eq(ingress, n->ingress1)) {
|
if (tmv_cmp(ingress, n->ingress1) == 0) {
|
||||||
pr_warning("bad timestamps in nrate calculation");
|
pr_warning("bad timestamps in nrate calculation");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
4
tmv.h
4
tmv.h
|
@ -51,9 +51,9 @@ static inline tmv_t tmv_div(tmv_t a, int divisor)
|
||||||
return a / divisor;
|
return a / divisor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int tmv_eq(tmv_t a, tmv_t b)
|
static inline int tmv_cmp(tmv_t a, tmv_t b)
|
||||||
{
|
{
|
||||||
return a == b ? 1 : 0;
|
return a == b ? 0 : a > b ? +1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int tmv_is_zero(tmv_t x)
|
static inline int tmv_is_zero(tmv_t x)
|
||||||
|
|
Loading…
Reference in New Issue