diff options
Diffstat (limited to 'libraries/base/System')
-rw-r--r-- | libraries/base/System/Environment.hs | 28 | ||||
-rw-r--r-- | libraries/base/System/IO.hs | 8 | ||||
-rw-r--r-- | libraries/base/System/Posix/Internals.hs | 6 | ||||
-rw-r--r-- | libraries/base/System/Timeout.hs | 4 |
4 files changed, 23 insertions, 23 deletions
diff --git a/libraries/base/System/Environment.hs b/libraries/base/System/Environment.hs index 61b728cb9c..56e6961f8a 100644 --- a/libraries/base/System/Environment.hs +++ b/libraries/base/System/Environment.hs @@ -33,7 +33,7 @@ import Foreign import Foreign.C import System.IO.Error (mkIOError) import Control.Exception.Base (bracket_, throwIO) -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) import Control.Exception.Base (bracket) #endif -- import GHC.IO @@ -41,7 +41,7 @@ import GHC.IO.Exception import GHC.IO.Encoding (getFileSystemEncoding) import qualified GHC.Foreign as GHC import Control.Monad -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) import GHC.Environment import GHC.Windows #else @@ -50,7 +50,7 @@ import System.Posix.Internals (withFilePath) import System.Environment.ExecutablePath -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) # if defined(i386_HOST_ARCH) # define WINDOWS_CCONV stdcall # elif defined(x86_64_HOST_ARCH) @@ -65,7 +65,7 @@ import System.Environment.ExecutablePath -- --------------------------------------------------------------------------- -- getArgs, getProgName, getEnv -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) {- Note [Ignore hs_init argv] @@ -133,7 +133,7 @@ dropRTSArgs (arg:rest) = arg : dropRTSArgs rest -- line arguments (not including the program name). getArgs :: IO [String] -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) getArgs = fmap tail getWin32ProgArgv_certainly #else getArgs = @@ -160,7 +160,7 @@ between platforms: on Windows, for example, a program invoked as foo is probably really @FOO.EXE@, and that is what 'getProgName' will return. -} getProgName :: IO String -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) -- Ignore the arguments to hs_init on Windows for the sake of Unicode compat getProgName = fmap (basename . head) getWin32ProgArgv_certainly #else @@ -188,7 +188,7 @@ basename f = go f f isPathSeparator :: Char -> Bool isPathSeparator '/' = True -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) isPathSeparator '\\' = True #endif isPathSeparator _ = False @@ -206,7 +206,7 @@ basename f = go f f getEnv :: String -> IO String getEnv name = lookupEnv name >>= maybe handleError return where -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) handleError = do err <- c_GetLastError if err == eRROR_ENVVAR_NOT_FOUND @@ -230,7 +230,7 @@ foreign import WINDOWS_CCONV unsafe "windows.h GetLastError" -- -- @since 4.6.0.0 lookupEnv :: String -> IO (Maybe String) -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) lookupEnv name = withCWString name $ \s -> try_size s 256 where try_size s size = allocaArray (fromIntegral size) $ \p_value -> do @@ -295,7 +295,7 @@ setEnv key_ value_ value = takeWhile (/= '\NUL') value_ setEnv_ :: String -> String -> IO () -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) setEnv_ key value = withCWString key $ \k -> withCWString value $ \v -> do success <- c_SetEnvironmentVariable k v unless success (throwGetLastError "setEnv") @@ -329,7 +329,7 @@ foreign import ccall unsafe "putenv" c_putenv :: CString -> IO CInt -- -- @since 4.7.0.0 unsetEnv :: String -> IO () -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) unsetEnv key = withCWString key $ \k -> do success <- c_SetEnvironmentVariable k nullPtr unless success $ do @@ -340,7 +340,7 @@ unsetEnv key = withCWString key $ \k -> do throwGetLastError "unsetEnv" #else -#ifdef HAVE_UNSETENV +#if defined(HAVE_UNSETENV) unsetEnv key = withFilePath key (throwErrnoIf_ (/= 0) "unsetEnv" . c_unsetenv) foreign import ccall unsafe "__hsbase_unsetenv" c_unsetenv :: CString -> IO CInt #else @@ -372,7 +372,7 @@ withProgName nm act = do withArgv :: [String] -> IO a -> IO a -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) -- We have to reflect the updated arguments in the RTS-side variables as -- well, because the RTS still consults them for error messages and the like. -- If we don't do this then ghc-e005 fails. @@ -406,7 +406,7 @@ foreign import ccall unsafe "setProgArgv" -- the @key@ is the whole entry and the @value@ is the empty string. getEnvironment :: IO [(String, String)] -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) getEnvironment = bracket c_GetEnvironmentStrings c_FreeEnvironmentStrings $ \pBlock -> if pBlock == nullPtr then return [] else go pBlock diff --git a/libraries/base/System/IO.hs b/libraries/base/System/IO.hs index 1796200bc4..735d41ba45 100644 --- a/libraries/base/System/IO.hs +++ b/libraries/base/System/IO.hs @@ -224,7 +224,7 @@ import Control.Exception.Base import Data.Bits import Data.Maybe import Foreign.C.Error -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) import Foreign.C.String #endif import Foreign.C.Types @@ -546,7 +546,7 @@ openNewFile filepath binary mode = do errno <- getErrno case errno of _ | errno == eEXIST -> return FileExists -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) -- If c_open throws EACCES on windows, it could mean that filepath is a -- directory. In this case, we want to return FileExists so that the -- enclosing openTempFile can try again instead of failing outright. @@ -565,13 +565,13 @@ openNewFile filepath binary mode = do _ -> return (OpenNewError errno) else return (NewFileCreated fd) -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) foreign import ccall "file_exists" c_fileExists :: CString -> IO Bool #endif -- XXX Should use filepath library pathSeparator :: Char -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) pathSeparator = '\\' #else pathSeparator = '/' diff --git a/libraries/base/System/Posix/Internals.hs b/libraries/base/System/Posix/Internals.hs index 7bb26fa395..93ad4e8137 100644 --- a/libraries/base/System/Posix/Internals.hs +++ b/libraries/base/System/Posix/Internals.hs @@ -43,7 +43,7 @@ import GHC.IO import GHC.IO.IOMode import GHC.IO.Exception import GHC.IO.Device -#ifndef mingw32_HOST_OS +#if !defined(mingw32_HOST_OS) import {-# SOURCE #-} GHC.IO.Encoding (getFileSystemEncoding) import qualified GHC.Foreign as GHC #endif @@ -157,7 +157,7 @@ fdGetMode fd = do return mode -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) withFilePath :: FilePath -> (CWString -> IO a) -> IO a withFilePath = withCWString @@ -545,7 +545,7 @@ s_isfifo cm = c_s_isfifo cm /= 0 foreign import ccall unsafe "HsBase.h __hscore_sizeof_stat" sizeof_stat :: Int foreign import ccall unsafe "HsBase.h __hscore_st_mtime" st_mtime :: Ptr CStat -> IO CTime -#ifdef mingw32_HOST_OS +#if defined(mingw32_HOST_OS) foreign import ccall unsafe "HsBase.h __hscore_st_size" st_size :: Ptr CStat -> IO Int64 #else foreign import ccall unsafe "HsBase.h __hscore_st_size" st_size :: Ptr CStat -> IO COff diff --git a/libraries/base/System/Timeout.hs b/libraries/base/System/Timeout.hs index d4ef0932b5..d34082e64f 100644 --- a/libraries/base/System/Timeout.hs +++ b/libraries/base/System/Timeout.hs @@ -18,7 +18,7 @@ module System.Timeout ( timeout ) where -#ifndef mingw32_HOST_OS +#if !defined(mingw32_HOST_OS) import Control.Monad import GHC.Event (getSystemTimerManager, registerTimeout, unregisterTimeout) @@ -80,7 +80,7 @@ timeout :: Int -> IO a -> IO (Maybe a) timeout n f | n < 0 = fmap Just f | n == 0 = return Nothing -#ifndef mingw32_HOST_OS +#if !defined(mingw32_HOST_OS) | rtsSupportsBoundThreads = do -- In the threaded RTS, we use the Timer Manager to delay the -- (fairly expensive) 'forkIO' call until the timeout has expired. |