summaryrefslogtreecommitdiff
path: root/libraries/base/System
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2016-03-20 22:15:46 +0100
committerBen Gamari <ben@smart-cactus.org>2016-03-20 23:14:08 +0100
commit286c65f2c7b193311d0710e7de30f4e8c76a84cf (patch)
treef60b28f4e71a69461bbf738f96765b5a7afbefb3 /libraries/base/System
parente6a44f2ae38aaa53834297305030d1b462d8b039 (diff)
downloadhaskell-286c65f2c7b193311d0710e7de30f4e8c76a84cf.tar.gz
base: Fix CPUTime on Windows
Arg, silly CPP.
Diffstat (limited to 'libraries/base/System')
-rw-r--r--libraries/base/System/CPUTime/Windows.hsc25
1 files changed, 11 insertions, 14 deletions
diff --git a/libraries/base/System/CPUTime/Windows.hsc b/libraries/base/System/CPUTime/Windows.hsc
index d1ca856e87..3f8c9eaa4c 100644
--- a/libraries/base/System/CPUTime/Windows.hsc
+++ b/libraries/base/System/CPUTime/Windows.hsc
@@ -1,4 +1,4 @@
-{-# LANGUAGE CPP, CApiFFI, NumDecimals #-}
+{-# LANGUAGE CPP, CApiFFI, NondecreasingIndentation, NumDecimals #-}
#include "HsFFI.h"
#include "HsBaseConfig.h"
@@ -8,7 +8,6 @@ module System.CPUTime.Windows
, getCpuTimePrecision
) where
-import Data.Ratio
import Foreign
import Foreign.C
@@ -17,16 +16,6 @@ import Foreign.C
#include <windows.h>
#endif
-#ifdef mingw32_HOST_OS
-# if defined(i386_HOST_ARCH)
-# define WINDOWS_CCONV stdcall
-# elif defined(x86_64_HOST_ARCH)
-# define WINDOWS_CCONV ccall
-# else
-# error Unknown mingw32 arch
-# endif
-#endif
-
getCPUTime :: IO Integer
getCPUTime = do
-- NOTE: GetProcessTimes() is only supported on NT-based OSes.
@@ -61,6 +50,14 @@ getCpuTimePrecision = return 16e9
type FILETIME = ()
type HANDLE = ()
+
-- need proper Haskell names (initial lower-case character)
-foreign import WINDOWS_CCONV unsafe "GetCurrentProcess" getCurrentProcess :: IO (Ptr HANDLE)
-foreign import WINDOWS_CCONV unsafe "GetProcessTimes" getProcessTimes :: Ptr HANDLE -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> IO CInt
+#if defined(i386_HOST_ARCH)
+foreign import stdcall unsafe "GetCurrentProcess" getCurrentProcess :: IO (Ptr HANDLE)
+foreign import stdcall unsafe "GetProcessTimes" getProcessTimes :: Ptr HANDLE -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> IO CInt
+#elif defined(x86_64_HOST_ARCH)
+foreign import ccall unsafe "GetCurrentProcess" getCurrentProcess :: IO (Ptr HANDLE)
+foreign import ccall unsafe "GetProcessTimes" getProcessTimes :: Ptr HANDLE -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> IO CInt
+#else
+#error Unknown mingw32 arch
+#endif