FIX #1621: bug in Windows code for getCPUTime
authorSimon Marlow <simonmar@microsoft.com>
Wed, 5 Dec 2007 12:01:18 +0000 (12:01 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Wed, 5 Dec 2007 12:01:18 +0000 (12:01 +0000)
We were reading the components of FILETIME as CLong, when they should
be unsigned.  Word32 seems to be the correct type here.

System/CPUTime.hsc

index 3309c2c..2846d4c 100644 (file)
@@ -108,8 +108,8 @@ foreign import ccall unsafe times :: Ptr CTms -> IO CClock
   where 
        ft2psecs :: Ptr FILETIME -> IO Integer
         ft2psecs ft = do
-          high <- (#peek FILETIME,dwHighDateTime) ft :: IO CLong
-          low <- (#peek FILETIME,dwLowDateTime) ft :: IO CLong
+          high <- (#peek FILETIME,dwHighDateTime) ft :: IO Word32
+          low  <- (#peek FILETIME,dwLowDateTime)  ft :: IO Word32
            -- Convert 100-ns units to picosecs (10^-12) 
            -- => multiply by 10^5.
           return (((fromIntegral high) * (2^32) + (fromIntegral low)) * 100000)