X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FCPUTime.hsc;h=b9678a3d50d98070defc67996e43ae0cc400a99e;hb=4f4fbd185f6cea77eb28407b1eadcca2673c6382;hp=77a8e243d96605b642a4c2dd5dd07a138b517b57;hpb=9fc6ea32c6d83da75c30a3b795aed9ff889b3fd1;p=haskell-directory.git diff --git a/System/CPUTime.hsc b/System/CPUTime.hsc index 77a8e24..b9678a3 100644 --- a/System/CPUTime.hsc +++ b/System/CPUTime.hsc @@ -20,13 +20,20 @@ module System.CPUTime import Prelude +import Data.Ratio + +#ifdef __HUGS__ +import Hugs.Time ( getCPUTime, clockTicks ) +#endif + +#ifdef __GLASGOW_HASKELL__ import Foreign import Foreign.C -import Data.Ratio - #include "HsBase.h" +#endif +#ifdef __GLASGOW_HASKELL__ -- ----------------------------------------------------------------------------- -- |Computation 'getCPUTime' returns the number of picoseconds CPU time -- used by the current program. The precision of this result is @@ -106,6 +113,7 @@ foreign import ccall unsafe "GetCurrentProcess" getCurrentProcess :: IO (Ptr HAN foreign import ccall unsafe "GetProcessTimes" getProcessTimes :: Ptr HANDLE -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> IO CInt #endif /* not _WIN32 */ +#endif /* __GLASGOW_HASKELL__ */ -- |The 'cpuTimePrecision' constant is the smallest measurable difference -- in CPU time that the implementation can record, and is given as an @@ -114,6 +122,7 @@ foreign import ccall unsafe "GetProcessTimes" getProcessTimes :: Ptr HANDLE -> P cpuTimePrecision :: Integer cpuTimePrecision = round ((1000000000000::Integer) % fromIntegral (clockTicks)) +#ifdef __GLASGOW_HASKELL__ clockTicks :: Int clockTicks = #if defined(CLK_TCK) @@ -122,3 +131,4 @@ clockTicks = unsafePerformIO (sysconf (#const _SC_CLK_TCK) >>= return . fromIntegral) foreign import ccall unsafe sysconf :: CInt -> IO CLong #endif +#endif /* __GLASGOW_HASKELL__ */