Module Name: src
Committed By: phx
Date: Fri Sep 11 19:43:08 UTC 2009
Modified Files:
src/sys/arch/amiga/dev: clock.c
Log Message:
Handle the situation of a wrapped interval counter, while the hardclock()
interrupt was not yet executed to update the hardclock_ticks variable.
To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/amiga/dev/clock.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amiga/dev/clock.c
diff -u src/sys/arch/amiga/dev/clock.c:1.49 src/sys/arch/amiga/dev/clock.c:1.50
--- src/sys/arch/amiga/dev/clock.c:1.49 Fri Sep 11 13:11:15 2009
+++ src/sys/arch/amiga/dev/clock.c Fri Sep 11 19:43:08 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.49 2009/09/11 13:11:15 phx Exp $ */
+/* $NetBSD: clock.c,v 1.50 2009/09/11 19:43:08 phx Exp $ */
/*
* Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.49 2009/09/11 13:11:15 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.50 2009/09/11 19:43:08 phx Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -326,6 +326,8 @@
static u_int
clk_getcounter(struct timecounter *tc)
{
+ static int last_hardclock_ticks;
+ static u_int last_clock_tick = 0;
int old_hardclock_ticks;
u_int clock_tick;
@@ -334,6 +336,19 @@
clock_tick = clk_gettick();
} while (old_hardclock_ticks != hardclock_ticks);
+ /*
+ * Handle the situation of a wrapped interval counter, while
+ * the hardclock() interrupt was not yet executed to update
+ * hardclock_ticks.
+ */
+ if (last_hardclock_ticks > old_hardclock_ticks)
+ old_hardclock_ticks = last_hardclock_ticks;
+ if (clock_tick < last_clock_tick &&
+ old_hardclock_ticks == last_hardclock_ticks)
+ old_hardclock_ticks++;
+ last_hardclock_ticks = old_hardclock_ticks;
+ last_clock_tick = clock_tick;
+
return old_hardclock_ticks * amiga_clk_interval + clock_tick;
}