import PrelMaybe
import PrelNum
import PrelNumExtra
-import PrelAddr
import PrelIOBase
import PrelST
#endif
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
#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 +
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}
/*
* (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
*/
*/
#ifndef _WIN32
-StgByteArray
+StgInt
getCPUTime(StgByteArray cpuStruct)
{
StgInt *cpu=(StgInt *)cpuStruct;
cpu[3] = (t.tms_stime - cpu[2] * ticks) * (1000000000 / ticks);
# else
- return NULL;
+ return 0;
# endif
#endif
- return (StgByteArray) cpuStruct;
+ return 1;
}
#else
#endif
/* cygwin32 or mingw32 version */
-StgByteArray
+StgInt
getCPUTime(StgByteArray cpuStruct)
{
FILETIME creationTime, exitTime, kernelTime, userTime;
cpu[1]=0;
cpu[2]=0;
cpu[3]=0;
- return (StgByteArray)cpu;
+ return 1;
}
FT2usecs(uT, userTime);
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 */
/*
* (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.
*/
StgInt prim_getClockTime(StgByteArray, StgByteArray);
/* getCPUTime.c */
-StgByteArray getCPUTime (StgByteArray);
+StgInt getCPUTime (StgByteArray);
StgInt clockTicks(void);
/* getCurrentDirectory.c */