X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FCPUTime.hsc;h=c2faa1c51b7a4d52042de1eb384c06275db4705d;hb=ca4fc090b0ad583d07017a69430227ce32684ac0;hp=7fe4fc2a74ad17ee38508fc2a9375d4f6d4f8804;hpb=8cd48b73c49ffe2685df8bd623b9eeb8de75ed69;p=ghc-base.git diff --git a/System/CPUTime.hsc b/System/CPUTime.hsc index 7fe4fc2..c2faa1c 100644 --- a/System/CPUTime.hsc +++ b/System/CPUTime.hsc @@ -34,7 +34,35 @@ import CPUTime ( getCPUTime, cpuTimePrecision ) import Foreign import Foreign.C -#include "HsBase.h" +#include "HsBaseConfig.h" + +-- For _SC_CLK_TCK +#if HAVE_UNISTD_H +#include +#endif + +-- For struct rusage +#if !defined(mingw32_HOST_OS) && !defined(irix_HOST_OS) +# if HAVE_SYS_RESOURCE_H +# include +# endif +#endif + +-- For FILETIME etc. on Windows +#if HAVE_WINDOWS_H +#include +#endif + +-- for CLK_TCK +#if HAVE_TIME_H +#include +#endif + +-- for struct tms +#if HAVE_SYS_TIMES_H +#include +#endif + #endif #if !defined(mingw32_HOST_OS) && !defined(cygwin32_HOST_OS) @@ -63,7 +91,7 @@ getCPUTime = do -- #if defined(HAVE_GETRUSAGE) && ! irix_HOST_OS && ! solaris2_HOST_OS allocaBytes (#const sizeof(struct rusage)) $ \ p_rusage -> do - getrusage (#const RUSAGE_SELF) p_rusage + throwErrnoIfMinus1_ "getrusage" $ getrusage (#const RUSAGE_SELF) p_rusage let ru_utime = (#ptr struct rusage, ru_utime) p_rusage let ru_stime = (#ptr struct rusage, ru_stime) p_rusage @@ -80,7 +108,7 @@ foreign import ccall unsafe getrusage :: CInt -> Ptr CRUsage -> IO CInt #else # if defined(HAVE_TIMES) allocaBytes (#const sizeof(struct tms)) $ \ p_tms -> do - times p_tms + _ <- times p_tms u_ticks <- (#peek struct tms,tms_utime) p_tms :: IO CClock s_ticks <- (#peek struct tms,tms_stime) p_tms :: IO CClock return (( (realToInteger u_ticks + realToInteger s_ticks) * 1000000000000)