diff options
Diffstat (limited to 'libraries/base/System')
-rw-r--r-- | libraries/base/System/CPUTime/Windows.hsc | 25 |
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 |