summaryrefslogtreecommitdiff
path: root/usr/src/uts
diff options
context:
space:
mode:
authorqiao <none@none>2007-03-09 07:19:31 -0800
committerqiao <none@none>2007-03-09 07:19:31 -0800
commit30392143708689bd11c23f26010219185c61a4b8 (patch)
treeffe745470498d7a088b25c147695d356d7d5dea6 /usr/src/uts
parent690555a1dfb3e9c3b00be26ece1988ed10a6fbe5 (diff)
downloadillumos-gate-30392143708689bd11c23f26010219185c61a4b8.tar.gz
6531693 timeout_common completely broken on 32-bit systems
Diffstat (limited to 'usr/src/uts')
-rw-r--r--usr/src/uts/common/os/callout.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/usr/src/uts/common/os/callout.c b/usr/src/uts/common/os/callout.c
index 92b52e27af..e477155b76 100644
--- a/usr/src/uts/common/os/callout.c
+++ b/usr/src/uts/common/os/callout.c
@@ -173,9 +173,14 @@ timeout_common(void (*func)(void *), void *arg, clock_t delta,
delta = 1;
cp->c_runtime = runtime = lbolt + delta;
- /* Calculate the future time in milli-second */
- hresms = now.tv_sec * MILLISEC + now.tv_nsec / MICROSEC +
- TICK_TO_MSEC(delta);
+ /*
+ * Calculate the future time in millisecond.
+ * We must cast tv_sec and delta to 64-bit integers
+ * to avoid integer overflow on 32-platforms.
+ */
+ hresms = (int64_t)now.tv_sec * MILLISEC + now.tv_nsec / MICROSEC +
+ TICK_TO_MSEC((int64_t)delta);
+
cp->c_hresms = hresms;
/*
@@ -349,8 +354,12 @@ callout_execute(callout_table_t *ct)
gethrestime(&now);
- /* Calculate the current time in milli-second */
- hresms = now.tv_sec * MILLISEC + now.tv_nsec / MICROSEC;
+ /*
+ * Calculate the future time in millisecond.
+ * We must cast tv_sec to 64-bit integer
+ * to avoid integer overflow on 32-platforms.
+ */
+ hresms = (int64_t)now.tv_sec * MILLISEC + now.tv_nsec / MICROSEC;
cp = ct->ct_hresq;
while (cp != NULL && hresms >= cp->c_hresms) {
@@ -420,8 +429,12 @@ callout_schedule_1(callout_table_t *ct)
gethrestime(&now);
- /* Calculate the current time in milli-second */
- hresms = now.tv_sec * MILLISEC + now.tv_nsec / MICROSEC;
+ /*
+ * Calculate the future time in millisecond.
+ * We must cast tv_sec to 64-bit integer
+ * to avoid integer overflow on 32-platforms.
+ */
+ hresms = (int64_t)now.tv_sec * MILLISEC + now.tv_nsec / MICROSEC;
cp = ct->ct_hresq;
while (cp != NULL && hresms >= cp->c_hresms) {