Ticket #8395: 0001-Port-ThreadDelay001-to-the-time-library.patch

File 0001-Port-ThreadDelay001-to-the-time-library.patch, 1.3 KB (added by rwbarton, 22 months ago)
  • tests/Concurrent/ThreadDelay001.hs

    From abe6d30e4b2e8ee9a195b57838933bed6c274138 Mon Sep 17 00:00:00 2001
    From: Reid Barton <[email protected]>
    Date: Tue, 1 Oct 2013 21:10:49 -0400
    Subject: [PATCH] Port ThreadDelay001 to the "time" library
    
    ... as "old-time" isn't built when cross-compiling.
    ---
     tests/Concurrent/ThreadDelay001.hs |   11 ++++-------
     1 files changed, 4 insertions(+), 7 deletions(-)
    
    diff --git a/tests/Concurrent/ThreadDelay001.hs b/tests/Concurrent/ThreadDelay001.hs
    index 36aa152..3b0f806 100644
    a b module Main (main) where 
    66
    77import Control.Concurrent
    88import Control.Monad
    9 import System.Time
     9import Data.Time
    1010
    1111main :: IO ()
    1212main = mapM_ delay (0 : take 7 (iterate (*5) 100))
    1313
    1414delay :: Int -> IO ()
    1515delay n = do
    16   tS <- getClockTime
     16  tS <- getCurrentTime
    1717  threadDelay n
    18   tE <- getClockTime
     18  tE <- getCurrentTime
    1919
    2020  let req = fromIntegral n * 10 ^ (6 :: Int)
    21       obs = case normalizeTimeDiff (diffClockTimes tE tS) of
    22                 TimeDiff 0 0 0 0 0 s ps -> 10 ^ (12 :: Int) * fromIntegral s + ps
    23                 td ->
    24                     error ("Bad TimeDiff: " ++ show td)
     21      obs = floor (diffUTCTime tE tS * 10 ^ (12 :: Int))
    2522      diff = obs - req
    2623      diff' :: Double
    2724      diff' = fromIntegral diff /  10 ^ (12 :: Int)