[PATCH] do not use CLK_TCK on Solaris host

Karel Gardas karel.gardas at centrum.cz
Fri Jan 18 22:32:09 CET 2013


This patch fixes Solaris cross-compilation issue as CLK_TCK is not constant
on Solaris and hsc2hs chokes on it when cross-compiling from i386-solaris
to x86_64-solaris.
---
 System/CPUTime.hsc |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/System/CPUTime.hsc b/System/CPUTime.hsc
index 8934a7e..270fd13 100644
--- a/System/CPUTime.hsc
+++ b/System/CPUTime.hsc
@@ -39,7 +39,7 @@ import CPUTime ( getCPUTime, cpuTimePrecision )
 #ifdef __GLASGOW_HASKELL__
 import Foreign.Safe
 import Foreign.C
-#if !defined(CLK_TCK)
+#if !defined(CLK_TCK) || solaris2_HOST_OS
 import System.IO.Unsafe (unsafePerformIO)
 #endif
 
@@ -187,7 +187,10 @@ cpuTimePrecision = round ((1000000000000::Integer) % fromIntegral (clockTicks))
 #ifdef __GLASGOW_HASKELL__
 clockTicks :: Int
 clockTicks =
-#if defined(CLK_TCK)
+-- CLK_TCK is no longer a constant on Solaris so avoid to use it
+-- this way. In fact it's defined in a way like syscall below in
+-- Solaris' <time.h>
+#if defined(CLK_TCK) && ! solaris2_HOST_OS
     (#const CLK_TCK)
 #else
     unsafePerformIO (sysconf (#const _SC_CLK_TCK) >>= return . fromIntegral)
-- 
1.7.3.2




More information about the ghc-devs mailing list