[project @ 1999-09-30 15:50:02 by sof]
authorsof <unknown>
Thu, 30 Sep 1999 15:50:04 +0000 (15:50 +0000)
committersof <unknown>
Thu, 30 Sep 1999 15:50:04 +0000 (15:50 +0000)
Simplified the interface between CPUTime.getCPUTime and getCPUTime()

ghc/lib/std/CPUTime.lhs
ghc/lib/std/cbits/getCPUTime.c
ghc/lib/std/cbits/stgio.h

index 54691bf..74f3668 100644 (file)
@@ -20,7 +20,6 @@ import PrelArr        ( ByteArray(..), newIntArray, unsafeFreezeByteArray )
 import PrelMaybe
 import PrelNum
 import PrelNumExtra
-import PrelAddr
 import PrelIOBase
 import PrelST
 #endif
@@ -44,8 +43,8 @@ integral number of picoseconds.
 getCPUTime :: IO Integer
 getCPUTime = do
     marr <- primNewByteArray (sizeof_int * 4)
-    ptr  <- getCPUTime marr
-    if (ptr /= nullAddr) then do
+    rc   <- getCPUTime marr
+    if rc /= 0 then do
         x0 <- primReadIntArray marr 0
         x1 <- primReadIntArray marr 1
         x2 <- primReadIntArray marr 2
@@ -61,11 +60,11 @@ getCPUTime = do
 #else
 
 getCPUTime :: IO Integer
-getCPUTime = 
+getCPUTime =
     stToIO (newIntArray ((0::Int),3))  >>= \ marr ->
     stToIO (unsafeFreezeByteArray marr)        >>= \ barr@(ByteArray _ frozen#) ->
-    primGetCPUTime barr                        >>= \ ptr ->
-    if (ptr::Addr) /= nullAddr then
+    primGetCPUTime barr                        >>= \ rc ->
+    if rc /= 0 then
         return ((fromIntegral (I# (indexIntArray# frozen# 0#)) * 1000000000 + 
                  fromIntegral (I# (indexIntArray# frozen# 1#)) + 
                 fromIntegral (I# (indexIntArray# frozen# 2#)) * 1000000000 + 
@@ -86,7 +85,7 @@ cpuTimePrecision = round ((1000000000000::Integer) %
 sizeof_int :: Int
 sizeof_int = 4
 
-foreign import "libHS_cbits" "getCPUTime" primGetCPUTime :: ByteArray Int -> IO Addr
+foreign import "libHS_cbits" "getCPUTime" primGetCPUTime :: ByteArray Int -> IO Int
 foreign import "libHS_cbits" "clockTicks" clockTicks :: IO Int
 
 \end{code}
index 8e34841..512aa57 100644 (file)
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: getCPUTime.c,v 1.5 1999/05/03 13:22:29 sof Exp $
+ * $Id: getCPUTime.c,v 1.6 1999/09/30 15:50:02 sof Exp $
  *
  * getCPUTime Runtime Support
  */
@@ -76,7 +76,7 @@ clockTicks ()
  */
 
 #ifndef _WIN32
-StgByteArray
+StgInt
 getCPUTime(StgByteArray cpuStruct)
 {
     StgInt *cpu=(StgInt *)cpuStruct;
@@ -114,10 +114,10 @@ getCPUTime(StgByteArray cpuStruct)
     cpu[3] = (t.tms_stime - cpu[2] * ticks) * (1000000000 / ticks);
 
 # else
-    return NULL;
+    return 0;
 # endif
 #endif
-    return (StgByteArray) cpuStruct;
+    return 1;
 }
 
 #else
@@ -133,7 +133,7 @@ getCPUTime(StgByteArray cpuStruct)
 #endif
 
 /* cygwin32 or mingw32 version */
-StgByteArray
+StgInt
 getCPUTime(StgByteArray cpuStruct)
 {
     FILETIME creationTime, exitTime, kernelTime, userTime;
@@ -150,7 +150,7 @@ getCPUTime(StgByteArray cpuStruct)
         cpu[1]=0;
         cpu[2]=0;
         cpu[3]=0;
-       return (StgByteArray)cpu;
+       return 1;
     }
 
     FT2usecs(uT, userTime);
@@ -160,7 +160,7 @@ getCPUTime(StgByteArray cpuStruct)
     cpu[1] = (unsigned int)(uT * 100);
     cpu[0] = (unsigned int)(kT / NS_PER_SEC);
     cpu[1] = (unsigned int)(kT * 100);
-    return (StgByteArray)cpu;
+    return 1;
 }
 
 #endif /* _WIN32 */
index 8dfa5c2..1c5f2a1 100644 (file)
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: stgio.h,v 1.13 1999/09/30 12:42:26 sof Exp $
+ * $Id: stgio.h,v 1.14 1999/09/30 15:50:03 sof Exp $
  *
  * Helper code for GHC's IO subsystem.
  */
@@ -136,7 +136,7 @@ StgInt      getClockTime (StgByteArray, StgByteArray);
 StgInt  prim_getClockTime(StgByteArray, StgByteArray);
 
 /* getCPUTime.c */
-StgByteArray getCPUTime (StgByteArray);
+StgInt getCPUTime (StgByteArray);
 StgInt clockTicks(void);
 
 /* getCurrentDirectory.c */