From 029cb46788da1108bab08eaec61a22f16131d838 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Thu, 21 Jun 2007 04:43:34 +0000 Subject: Fix microtime to not lose clocik ticks, gives us among other things, real ping times on slow links; from mickey --- sys/arch/sh/sh/clock.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/arch/sh/sh/clock.c b/sys/arch/sh/sh/clock.c index 6a9954ff043..15e3ea1b143 100644 --- a/sys/arch/sh/sh/clock.c +++ b/sys/arch/sh/sh/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.3 2006/11/04 02:08:25 mickey Exp $ */ +/* $OpenBSD: clock.c,v 1.4 2007/06/21 04:43:33 miod Exp $ */ /* $NetBSD: clock.c,v 1.32 2006/09/05 11:09:36 uwe Exp $ */ /*- @@ -209,14 +209,15 @@ void microtime(struct timeval *tv) { static struct timeval lasttime; + u_int32_t tcnt0; int s; s = splclock(); *tv = time; + tcnt0 = _reg_read_4(SH_(TCNT0)); splx(s); - tv->tv_usec += ((sh_clock.hz_cnt - _reg_read_4(SH_(TCNT0))) - * 1000000) / sh_clock.tmuclk; + tv->tv_usec += ((sh_clock.hz_cnt - tcnt0) * 1000000) / sh_clock.tmuclk; while (tv->tv_usec >= 1000000) { tv->tv_usec -= 1000000; tv->tv_sec++; -- cgit v1.2.3