Remove implementation of tvtohz() - since the timecounters branch

was merged, this is now in sys/kern/kern_clock.c .
This commit is contained in:
riz 2006-06-13 15:43:04 +00:00
parent 39140597bf
commit 58d052216c
1 changed files with 1 additions and 48 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_carp.c,v 1.3 2006/05/25 15:22:05 liamjfoy Exp $ */
/* $NetBSD: ip_carp.c,v 1.4 2006/06/13 15:43:04 riz Exp $ */
/* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */
/*
@ -2228,53 +2228,6 @@ carp_ether_purgemulti(struct carp_softc *sc)
}
}
/*
* Compute number of hz in the specified amount of time. This
* function is from OpenBSD.
*/
int
tvtohz(struct timeval *tv)
{
unsigned long ticks;
long sec, usec;
/*
* If the number of usecs in the whole seconds part of the time
* fits in a long, then the total number of usecs will
* fit in an unsigned long. Compute the total and convert it to
* ticks, rounding up and adding 1 to allow for the current tick
* to expire. Rounding also depends on unsigned long arithmetic
* to avoid overflow.
*
* Otherwise, if the number of ticks in the whole seconds part of
* the time fits in a long, then convert the parts to
* ticks separately and add, using similar rounding methods and
* overflow avoidance. This method would work in the previous
* case but it is slightly slower and assumes that hz is integral.
*
* Otherwise, round the time down to the maximum
* representable value.
*
* If ints have 32 bits, then the maximum value for any timeout in
* 10ms ticks is 248 days.
*/
sec = tv->tv_sec;
usec = tv->tv_usec;
if (sec < 0 || (sec == 0 && usec <= 0))
ticks = 0;
else if (sec <= LONG_MAX / 1000000)
ticks = (sec * 1000000 + (unsigned long)usec + (tick - 1))
/ tick + 1;
else if (sec <= LONG_MAX / hz)
ticks = sec * hz
+ ((unsigned long)usec + (tick - 1)) / tick + 1;
else
ticks = LONG_MAX;
if (ticks > INT_MAX)
ticks = INT_MAX;
return ((int)ticks);
}
SYSCTL_SETUP(sysctl_net_inet_carp_setup, "sysctl net.inet.carp subtree setup")
{