Subject: microtime can return invalid tv_usec value
To: None <port-pc532@NetBSD.ORG>
From: Ian Dall <Ian.Dall@dsto.defence.gov.au>
List: port-pc532
Date: 03/26/1997 00:06:43
I had a very annoying problem with select failing with EINVAL in X. I
traced it to microtime(), and hence gettimeofday() sometimes returning
a bad tv_usec value. Here is a patch:
--- ../../../../../src/sys/arch/pc532/pc532/clock.c Thu Mar 20 22:19:01 1997
+++ clock.c Tue Mar 25 22:30:02 1997
@@ -181,10 +181,13 @@
/* check for timer overflow (ie; clock int disabled) */
if (count > 0 && (ipend & (1<<IR_CLK))) {
tvp->tv_usec += tick;
- if (tvp->tv_usec > 1000000) {
- tvp->tv_usec -= 1000000;
- tvp->tv_sec++;
- }
+ }
+ if (tvp->tv_usec >= 1000000) {
+ tvp->tv_usec -= 1000000;
+ tvp->tv_sec++;
+ }
+ if (tvp->tv_usec < 0 || tvp->tv_usec > 1000000) {
+ printf("microtime bad tv_usec: %ld\n", tvp->tv_usec);
}
}