X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=GHC%2FEvent%2FClock.hsc;h=998794bad7fef04912d08e057f321ff7f92ce874;hb=6521ec5cf8c3b3cb9d6733b5d76d6375303f975c;hp=98758a3e3a19a6e37268ee57ae09302b81a6c89d;hpb=9af062a0894f4a3fe52a8fa1c08c0b6ccf724367;p=ghc-base.git diff --git a/GHC/Event/Clock.hsc b/GHC/Event/Clock.hsc index 98758a3..998794b 100644 --- a/GHC/Event/Clock.hsc +++ b/GHC/Event/Clock.hsc @@ -6,7 +6,7 @@ module GHC.Event.Clock (getCurrentTime) where import Foreign (Ptr, Storable(..), nullPtr, with) import Foreign.C.Error (throwErrnoIfMinus1_) -import Foreign.C.Types (CInt, CLong) +import Foreign.C.Types (CInt, CLong, CTime, CSUSeconds) import GHC.Base import GHC.Err import GHC.Num @@ -20,15 +20,15 @@ getCurrentTime = do tv <- with (CTimeval 0 0) $ \tvptr -> do throwErrnoIfMinus1_ "gettimeofday" (gettimeofday tvptr nullPtr) peek tvptr - let !t = fromIntegral (sec tv) + fromIntegral (usec tv) / 1000000.0 + let !t = realToFrac (sec tv) + realToFrac (usec tv) / 1000000.0 return t ------------------------------------------------------------------------ -- FFI binding data CTimeval = CTimeval - { sec :: {-# UNPACK #-} !CLong - , usec :: {-# UNPACK #-} !CLong + { sec :: {-# UNPACK #-} !CTime + , usec :: {-# UNPACK #-} !CSUSeconds } instance Storable CTimeval where