summaryrefslogtreecommitdiff
path: root/rts/PrimOps.cmm
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2006-11-28 21:05:16 +0000
committerIan Lynagh <igloo@earth.li>2006-11-28 21:05:16 +0000
commit98cb2efd8279ec48eee1be37dad263e16552fafb (patch)
treece5dc4519ea674fc6fe03a399b4a7668beaf90e5 /rts/PrimOps.cmm
parent7e84448c9ed32f4fdc3de3155913bafd416898af (diff)
downloadhaskell-98cb2efd8279ec48eee1be37dad263e16552fafb.tar.gz
Make the non-threaded-RTS threadDelay wait at least as long as asked
Diffstat (limited to 'rts/PrimOps.cmm')
-rw-r--r--rts/PrimOps.cmm5
1 files changed, 4 insertions, 1 deletions
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index 3252993b1d..bfb0b86078 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -2052,8 +2052,11 @@ delayzh_fast
#else
W_ time;
+ W_ divisor;
time = foreign "C" getourtimeofday() [R1];
- target = (R1 / (TO_W_(RtsFlags_MiscFlags_tickInterval(RtsFlags))*1000)) + time;
+ divisor = TO_W_(RtsFlags_MiscFlags_tickInterval(RtsFlags))*1000;
+ target = ((R1 + divisor - 1) / divisor) /* divide rounding up */
+ + time + 1; /* Add 1 as getourtimeofday rounds down */
StgTSO_block_info(CurrentTSO) = target;
/* Insert the new thread in the sleeping queue. */