Commit 94e6d7db authored by Simon Marlow's avatar Simon Marlow
Browse files

Removes the assumption that CLK_TCK is a constant (#7519)

(which is not true on QNXNTO).

Submitted by: Stephen Paul Weber <singpolyma@singpolyma.net>
parent c0d723ec
......@@ -39,14 +39,6 @@ import CPUTime ( getCPUTime, cpuTimePrecision )
#ifdef __GLASGOW_HASKELL__
import Foreign.Safe
import Foreign.C
#if !defined(CLK_TCK)
import System.IO.Unsafe (unsafePerformIO)
#endif
-- For _SC_CLK_TCK
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-- For struct rusage
#if !defined(mingw32_HOST_OS) && !defined(irix_HOST_OS)
......@@ -60,11 +52,6 @@ import System.IO.Unsafe (unsafePerformIO)
#include <windows.h>
#endif
-- for CLK_TCK
#if HAVE_TIME_H
#include <time.h>
#endif
-- for struct tms
#if HAVE_SYS_TIMES_H
#include <sys/times.h>
......@@ -185,13 +172,8 @@ cpuTimePrecision = round ((1000000000000::Integer) % fromIntegral (clockTicks))
#endif
#ifdef __GLASGOW_HASKELL__
foreign import ccall unsafe clk_tck :: CLong
clockTicks :: Int
clockTicks =
#if defined(CLK_TCK)
(#const CLK_TCK)
#else
unsafePerformIO (sysconf (#const _SC_CLK_TCK) >>= return . fromIntegral)
foreign import ccall unsafe sysconf :: CInt -> IO CLong
#endif
clockTicks = fromIntegral clk_tck
#endif /* __GLASGOW_HASKELL__ */
......@@ -225,6 +225,7 @@ Library {
cbits/inputReady.c
cbits/primFloat.c
cbits/md5.c
cbits/sysconf.c
include-dirs: include
includes: HsBase.h
install-includes: HsBase.h HsBaseConfig.h EventConfig.h WCsubst.h consUtils.h Typeable.h
......
#include "HsBaseConfig.h"
/* For _SC_CLK_TCK */
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
/* for CLK_TCK */
#if HAVE_TIME_H
#include <time.h>
#endif
long clk_tck(void) {
#if defined(CLK_TCK)
return (CLK_TCK);
#else
return sysconf(_SC_CLK_TCK);
#endif
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment