From 202e1a58d5228e4efd6bafbe7b755d7bd192f516 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 26 May 2017 03:45:39 +0300 Subject: fix x86 builds --- src/WindowsEnv/Registry.hs | 10 +++++++--- src/WindowsEnv/Utils.hs | 6 +++++- src/WindowsEnv/ccall.h | 13 +++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/WindowsEnv/ccall.h diff --git a/src/WindowsEnv/Registry.hs b/src/WindowsEnv/Registry.hs index da889d4..6eb52ca 100644 --- a/src/WindowsEnv/Registry.hs +++ b/src/WindowsEnv/Registry.hs @@ -8,6 +8,8 @@ -- -- Lower-level functions for reading and writing registry values. +{-# LANGUAGE CPP #-} + module WindowsEnv.Registry ( IsKeyPath(..) , RootKey(..) @@ -148,13 +150,15 @@ decodeString (_, bytes) = T.unpack dropLastZero | otherwise = T.takeWhile (/= '\0') text text = decodeUtf16LE bytes -foreign import ccall unsafe "Windows.h RegQueryValueExW" +#include "ccall.h" + +foreign import WINDOWS_ENV_CCALL unsafe "Windows.h RegQueryValueExW" c_RegQueryValueEx :: WinAPI.PKEY -> WinAPI.LPCTSTR -> WinAPI.LPDWORD -> WinAPI.LPDWORD -> WinAPI.LPBYTE -> WinAPI.LPDWORD -> IO WinAPI.ErrCode -foreign import ccall unsafe "Windows.h RegSetValueExW" +foreign import WINDOWS_ENV_CCALL unsafe "Windows.h RegSetValueExW" c_RegSetValueEx :: WinAPI.PKEY -> WinAPI.LPCTSTR -> WinAPI.DWORD -> WinAPI.DWORD -> WinAPI.LPBYTE -> WinAPI.DWORD -> IO WinAPI.ErrCode -foreign import ccall unsafe "Windows.h RegGetValueW" +foreign import WINDOWS_ENV_CCALL unsafe "Windows.h RegGetValueW" c_RegGetValue :: WinAPI.PKEY -> WinAPI.LPCTSTR -> WinAPI.LPCTSTR -> WinAPI.DWORD -> WinAPI.LPDWORD -> WinAPI.LPBYTE -> WinAPI.LPDWORD -> IO WinAPI.ErrCode queryValue :: IsKeyPath a => a -> ValueName -> ExceptT IOError IO ValueData diff --git a/src/WindowsEnv/Utils.hs b/src/WindowsEnv/Utils.hs index c852229..4432a95 100644 --- a/src/WindowsEnv/Utils.hs +++ b/src/WindowsEnv/Utils.hs @@ -5,6 +5,8 @@ -- Stability : experimental -- Portability : Windows-only +{-# LANGUAGE CPP #-} + module WindowsEnv.Utils ( notifyEnvironmentUpdate ) where @@ -14,7 +16,9 @@ import qualified Graphics.Win32.GDI.Types as WinAPI import qualified Graphics.Win32.Message as WinAPI import qualified System.Win32.Types as WinAPI -foreign import ccall "Windows.h SendNotifyMessageW" +#include "ccall.h" + +foreign import WINDOWS_ENV_CCALL "Windows.h SendNotifyMessageW" c_SendNotifyMessage :: WinAPI.HWND -> WinAPI.WindowMessage -> WinAPI.WPARAM -> WinAPI.LPARAM -> IO WinAPI.LRESULT notifyEnvironmentUpdate :: IO () diff --git a/src/WindowsEnv/ccall.h b/src/WindowsEnv/ccall.h new file mode 100644 index 0000000..541cd5e --- /dev/null +++ b/src/WindowsEnv/ccall.h @@ -0,0 +1,13 @@ +#ifndef WINDOWS_ENV_CCALL_H +#define WINDOWS_ENV_CCALL_H + +#if defined(i386_HOST_ARCH) +#define WINDOWS_ENV_CCALL stdcall +#elif defined(x86_64_HOST_ARCH) +#define WINDOWS_ENV_CCALL ccall +#else +#define WINDOWS_ENV_CCALL ccall +#warning "Unsupported architecture" +#endif + +#endif -- cgit v1.2.3