X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2FCPUTime.lhs;h=acf514eaa7ebdf393788fa400fb70b15dbabb95c;hb=531d0d264fafd66aece5ca38d2bfcd266a8fd3e5;hp=9d7e6a7c7942487115ce99ce4266b7eba277a370;hpb=e921b2e307532e0f30eefa88b11a124be592bde4;p=ghc-hetmet.git diff --git a/ghc/lib/std/CPUTime.lhs b/ghc/lib/std/CPUTime.lhs index 9d7e6a7..acf514e 100644 --- a/ghc/lib/std/CPUTime.lhs +++ b/ghc/lib/std/CPUTime.lhs @@ -1,7 +1,9 @@ +% ----------------------------------------------------------------------------- +% $Id: CPUTime.lhs,v 1.25 2000/09/14 13:46:42 simonpj Exp $ % -% (c) The GRASP/AQUA Project, Glasgow University, 1995-1997 +% (c) The University of Glasgow, 1995-2000 % -\section[CPUTime]{Haskell 1.4 CPU Time Library} +\section[CPUTime]{Haskell 98 CPU Time Library} \begin{code} {-# OPTIONS -#include "cbits/stgio.h" #-} @@ -20,10 +22,12 @@ module CPUTime import Prelude -- To generate the dependency import PrelGHC ( indexIntArray# ) import PrelBase ( Int(..) ) -import PrelByteArr ( ByteArray(..), newIntArray, unsafeFreezeByteArray ) +import PrelByteArr ( ByteArray(..), newIntArray ) +import PrelArrExtra ( unsafeFreezeByteArray ) import PrelNum ( fromInt ) -import PrelIOBase ( IOError(..), IOErrorType( UnsupportedOperation ), - unsafePerformIO, stToIO ) +import PrelIOBase ( IOError, IOException(..), + IOErrorType( UnsupportedOperation ), + unsafePerformIO, stToIO, ioException ) import Ratio \end{code} @@ -49,7 +53,7 @@ getCPUTime = do fromIntegral (I# (indexIntArray# frozen# 2#)) * 1000000000 + fromIntegral (I# (indexIntArray# frozen# 3#))) * 1000) else - ioError (IOError Nothing UnsupportedOperation + ioException (IOError Nothing UnsupportedOperation "getCPUTime" "can't get CPU time") @@ -58,13 +62,18 @@ cpuTimePrecision = round ((1000000000000::Integer) % fromInt (unsafePerformIO clockTicks)) foreign import "libHS_cbits" "getCPUTime" unsafe primGetCPUTime :: ByteArray Int -> IO Int -foreign import "libHS_cbits" "clockTicks" clockTicks :: IO Int +foreign import "libHS_cbits" "clockTicks" unsafe clockTicks :: IO Int \end{code} #else \begin{code} +import PrelPrim ( nh_getCPUtime + , nh_getCPUprec + , unsafePerformIO + ) + getCPUTime :: IO Integer getCPUTime = do seconds <- nh_getCPUtime @@ -72,7 +81,7 @@ getCPUTime cpuTimePrecision :: Integer cpuTimePrecision - = primRunST ( + = unsafePerformIO ( do resolution <- nh_getCPUprec return (round (resolution * 1.0e+12)) )