[project @ 1999-09-19 19:12:39 by sof]
[ghc-hetmet.git] / ghc / lib / std / CPUTime.lhs
index 32297e8..54691bf 100644 (file)
@@ -28,17 +28,6 @@ import IO            ( ioError )
 import PrelNum ( Num(..), Integral(..) )       -- To get fromInt/toInt
 import Ratio
 
-#ifdef __HUGS__
-#define cat2(x,y)  x/**/y
-#define CCALL(fun) cat2(prim_,fun)
-#define stToIO id
-#define sizeof_int64 8
-#else
-#define CCALL(fun) _ccall_ fun
-#define const_BUFSIZ ``BUFSIZ''
-#define primPackString
-#endif
-
 \end{code}
 
 Computation @getCPUTime@ returns the number of picoseconds CPU time
@@ -55,7 +44,7 @@ integral number of picoseconds.
 getCPUTime :: IO Integer
 getCPUTime = do
     marr <- primNewByteArray (sizeof_int * 4)
-    ptr  <- CCALL(getCPUTime) marr
+    ptr  <- getCPUTime marr
     if (ptr /= nullAddr) then do
         x0 <- primReadIntArray marr 0
         x1 <- primReadIntArray marr 1
@@ -75,8 +64,8 @@ getCPUTime :: IO Integer
 getCPUTime = 
     stToIO (newIntArray ((0::Int),3))  >>= \ marr ->
     stToIO (unsafeFreezeByteArray marr)        >>= \ barr@(ByteArray _ frozen#) ->
-    _ccall_ getCPUTime barr            >>= \ ptr ->
-    if (ptr::Addr) /= ``NULL'' then
+    primGetCPUTime barr                        >>= \ ptr ->
+    if (ptr::Addr) /= nullAddr then
         return ((fromIntegral (I# (indexIntArray# frozen# 0#)) * 1000000000 + 
                  fromIntegral (I# (indexIntArray# frozen# 1#)) + 
                 fromIntegral (I# (indexIntArray# frozen# 2#)) * 1000000000 + 
@@ -90,17 +79,16 @@ getCPUTime =
 
 cpuTimePrecision :: Integer
 cpuTimePrecision = round ((1000000000000::Integer) % 
-                          fromInt (unsafePerformIO (CCALL(clockTicks) )))
+                          fromInt (unsafePerformIO clockTicks))
 \end{code}
 
 \begin{code}
-#ifdef __HUGS__
-
+sizeof_int :: Int
 sizeof_int = 4
 
-foreign import stdcall "libHS_cbits.so" "getCPUTime" prim_getCPUTime :: Bytes -> IO Addr
-foreign import stdcall "libHS_cbits.so" "clockTicks" prim_clockTicks :: IO Int
-#endif
+foreign import "libHS_cbits" "getCPUTime" primGetCPUTime :: ByteArray Int -> IO Addr
+foreign import "libHS_cbits" "clockTicks" clockTicks :: IO Int
+
 \end{code}