mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Add few more bintime math macros.
This commit is contained in:
parent
fc780ca17e
commit
170a7705ae
1 changed files with 19 additions and 0 deletions
|
|
@ -90,6 +90,25 @@ bintime_sub(struct bintime *bt, const struct bintime *bt2)
|
|||
bt->sec -= bt2->sec;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
bintime_mul(struct bintime *bt, u_int x)
|
||||
{
|
||||
uint64_t p1, p2;
|
||||
|
||||
p1 = (bt->frac & 0xffffffffllu) * x;
|
||||
p2 = (bt->frac >> 32) * x + (p1 >> 32);
|
||||
bt->sec *= x;
|
||||
bt->sec += (p2 >> 32);
|
||||
bt->frac = (p2 << 32) | (p1 & 0xffffffffllu);
|
||||
}
|
||||
|
||||
#define bintime_clear(a) ((a)->sec = (a)->frac = 0)
|
||||
#define bintime_isset(a) ((a)->sec || (a)->frac)
|
||||
#define bintime_cmp(a, b, cmp) \
|
||||
(((a)->sec == (b)->sec) ? \
|
||||
((a)->frac cmp (b)->frac) : \
|
||||
((a)->sec cmp (b)->sec))
|
||||
|
||||
/*-
|
||||
* Background information:
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue