[project @ 2001-02-22 16:10:12 by rrt]
[ghc-hetmet.git] / ghc / lib / std / CPUTime.lhs
index d1d7179..df37a04 100644 (file)
@@ -1,7 +1,9 @@
+% -----------------------------------------------------------------------------
+% $Id: CPUTime.lhs,v 1.28 2001/02/22 13:17:58 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      ( IOException(..), 
+                         IOErrorType( UnsupportedOperation ), 
+                         unsafePerformIO, stToIO, ioException )
 import Ratio
 \end{code}
 
@@ -49,27 +53,27 @@ 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")
+                        "can't get CPU time"
+                        Nothing)
 
 cpuTimePrecision :: Integer
 cpuTimePrecision = round ((1000000000000::Integer) % 
-                          fromInt (unsafePerformIO clockTicks))
+                          fromIntegral (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 Prelude
-import privileged Prelude ( nh_getCPUtime
-                         , nh_getCPUprec
-                         , unsafePerformIO
-                         )
+import PrelPrim ( nh_getCPUtime
+               , nh_getCPUprec
+               , unsafePerformIO
+               )
 
 getCPUTime :: IO Integer
 getCPUTime