summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2005-03-12 00:10:23 +0000
committerpeter <peter@FreeBSD.org>2005-03-12 00:10:23 +0000
commiteca731ac63f6bfef57c674c8ce2fba90fbb34cc4 (patch)
treec3e2bdf4711dde660aff05f78133d69abca7b562 /sys/kern/tty.c
parentf5d07b2dc96107e49b722f82a96202e04b58fdc6 (diff)
downloadFreeBSD-src-eca731ac63f6bfef57c674c8ce2fba90fbb34cc4.zip
FreeBSD-src-eca731ac63f6bfef57c674c8ce2fba90fbb34cc4.tar.gz
Make the tty vmin/vtime timeouts work for hz > 169 on 32 bit machines.
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index f916a1b..bc95f04 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -97,6 +97,7 @@ __FBSDID("$FreeBSD$");
#include <sys/poll.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
+#include <sys/limits.h>
#include <sys/serial.h>
#include <sys/signalvar.h>
#include <sys/resourcevar.h>
@@ -1854,14 +1855,13 @@ loop:
#undef diff
/*
* Rounding down may make us wake up just short
- * of the target, so we round up.
- * The formula is ceiling(slp * hz/1000000).
- * 32-bit arithmetic is enough for hz < 169.
- * XXX see tvtohz() for how to avoid overflow if hz
- * is large (divide by `tick' and/or arrange to
- * use tvtohz() if hz is large).
+ * of the target, so we round up. The 32 bit arithmetic is
+ * sufficient for the first calculation for hz < 169.
*/
- slp = (long) (((u_long)slp * hz) + 999999) / 1000000;
+ if (sizeof(u_long) > 4 || slp <= ULONG_MAX / hz)
+ slp = (long) (((u_long)slp * hz) + 999999) / 1000000;
+ else
+ slp = (slp + (tick - 1)) / tick;
goto sleep;
}
if (qp->c_cc <= 0) {
OpenPOWER on IntegriCloud