diff --git a/ghc/lib/std/CPUTime.lhs b/ghc/lib/std/CPUTime.lhs index 54691bfe69eb1fe0a9ec0433bcec8056ddab1c4d..74f3668e4d6f4eb6c03ee45f061949665dcf82c7 100644 --- a/ghc/lib/std/CPUTime.lhs +++ b/ghc/lib/std/CPUTime.lhs @@ -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} diff --git a/ghc/lib/std/cbits/getCPUTime.c b/ghc/lib/std/cbits/getCPUTime.c index 8e348411c9724fb5d31b292d12775047aa6267f9..512aa573e6c92dd451066d9c8934ceff471aeb94 100644 --- a/ghc/lib/std/cbits/getCPUTime.c +++ b/ghc/lib/std/cbits/getCPUTime.c @@ -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 */ diff --git a/ghc/lib/std/cbits/stgio.h b/ghc/lib/std/cbits/stgio.h index 8dfa5c2b9344ccbc4e3f92d41849e8c9fba9b572..1c5f2a1c9d4782e1a5e04165f8712450a8d0dbba 100644 --- a/ghc/lib/std/cbits/stgio.h +++ b/ghc/lib/std/cbits/stgio.h @@ -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 */