aboutsummaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-08-02 12:27:32 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-08-02 12:27:32 -0400
commit250a25c8572e557772a9973542f9cfca6ac10b9b (patch)
tree7d4aaa36a7d5b6c3c5e03fb844fb844da4c037d2 /Utility
parenta39c161ab377eed381186bc57953cd59d6188108 (diff)
get rid of __WINDOWS__, use mingw32_HOST_OS
The latter is harder for me to remember, but avoids build failures in code used by the configure program.
Diffstat (limited to 'Utility')
-rw-r--r--Utility/CoProcess.hs2
-rw-r--r--Utility/CopyFile.hs2
-rw-r--r--Utility/Daemon.hs10
-rw-r--r--Utility/FileMode.hs8
-rw-r--r--Utility/Gpg.hs4
-rw-r--r--Utility/LogFile.hs6
-rw-r--r--Utility/Path.hs10
-rw-r--r--Utility/ThreadScheduler.hs4
-rw-r--r--Utility/UserInfo.hs4
9 files changed, 25 insertions, 25 deletions
diff --git a/Utility/CoProcess.hs b/Utility/CoProcess.hs
index 700ef6eb1..710d2af13 100644
--- a/Utility/CoProcess.hs
+++ b/Utility/CoProcess.hs
@@ -88,6 +88,6 @@ rawMode ch = do
where
raw h = do
fileEncoding h
-#ifdef __WINDOWS__
+#ifdef mingw32_HOST_OS
hSetNewlineMode h noNewlineTranslation
#endif
diff --git a/Utility/CopyFile.hs b/Utility/CopyFile.hs
index 9f10cb790..4a609fd16 100644
--- a/Utility/CopyFile.hs
+++ b/Utility/CopyFile.hs
@@ -36,7 +36,7 @@ copyFileExternal src dest = do
{- Create a hard link if the filesystem allows it, and fall back to copying
- the file. -}
createLinkOrCopy :: FilePath -> FilePath -> IO Bool
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
createLinkOrCopy src dest = go `catchIO` const fallback
where
go = do
diff --git a/Utility/Daemon.hs b/Utility/Daemon.hs
index ad0950de2..124005795 100644
--- a/Utility/Daemon.hs
+++ b/Utility/Daemon.hs
@@ -12,7 +12,7 @@ module Utility.Daemon where
import Common
import Utility.LogFile
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
import System.Posix
#else
import System.PosixCompat
@@ -26,7 +26,7 @@ import System.Posix.Types
-
- When successful, does not return. -}
daemonize :: Fd -> Maybe FilePath -> Bool -> IO () -> IO ()
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
daemonize logfd pidfile changedirectory a = do
maybe noop checkalreadyrunning pidfile
_ <- forkProcess child1
@@ -58,7 +58,7 @@ daemonize = error "daemonize is not implemented on Windows" -- TODO
lockPidFile :: FilePath -> IO ()
lockPidFile file = do
createDirectoryIfMissing True (parentDir file)
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
fd <- openFd file ReadWrite (Just stdFileMode) defaultFileFlags
locked <- catchMaybeIO $ setLock fd (WriteLock, AbsoluteSeek, 0, 0)
fd' <- openFd newfile ReadWrite (Just stdFileMode) defaultFileFlags
@@ -85,7 +85,7 @@ alreadyRunning = error "Daemon is already running."
-
- If it's running, returns its pid. -}
checkDaemon :: FilePath -> IO (Maybe ProcessID)
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
checkDaemon pidfile = do
v <- catchMaybeIO $
openFd pidfile ReadOnly (Just stdFileMode) defaultFileFlags
@@ -110,7 +110,7 @@ checkDaemon pidfile = maybe Nothing readish <$> catchMaybeIO (readFile pidfile)
{- Stops the daemon, safely. -}
stopDaemon :: FilePath -> IO ()
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
stopDaemon pidfile = go =<< checkDaemon pidfile
where
go Nothing = noop
diff --git a/Utility/FileMode.hs b/Utility/FileMode.hs
index 47247e2a1..d76fb5703 100644
--- a/Utility/FileMode.hs
+++ b/Utility/FileMode.hs
@@ -13,7 +13,7 @@ import Common
import Control.Exception (bracket)
import System.PosixCompat.Types
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
import System.Posix.Files
#endif
import Foreign (complement)
@@ -76,7 +76,7 @@ checkMode checkfor mode = checkfor `intersectFileModes` mode == checkfor
{- Checks if a file mode indicates it's a symlink. -}
isSymLink :: FileMode -> Bool
-#ifdef __WINDOWS__
+#ifdef mingw32_HOST_OS
isSymLink _ = False
#else
isSymLink = checkMode symbolicLinkMode
@@ -89,7 +89,7 @@ isExecutable mode = combineModes executeModes `intersectFileModes` mode /= 0
{- Runs an action without that pesky umask influencing it, unless the
- passed FileMode is the standard one. -}
noUmask :: FileMode -> IO a -> IO a
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
noUmask mode a
| mode == stdFileMode = a
| otherwise = bracket setup cleanup go
@@ -107,7 +107,7 @@ combineModes [m] = m
combineModes (m:ms) = foldl unionFileModes m ms
isSticky :: FileMode -> Bool
-#ifdef __WINDOWS__
+#ifdef mingw32_HOST_OS
isSticky _ = False
#else
isSticky = checkMode stickyMode
diff --git a/Utility/Gpg.hs b/Utility/Gpg.hs
index 33a26e272..d9969ed2f 100644
--- a/Utility/Gpg.hs
+++ b/Utility/Gpg.hs
@@ -29,7 +29,7 @@ gpgcmd = fromMaybe "gpg" SysConfig.gpg
stdParams :: [CommandParam] -> IO [String]
stdParams params = do
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
-- Enable batch mode if GPG_AGENT_INFO is set, to avoid extraneous
-- gpg output about password prompts. GPG_BATCH is set by the test
-- suite for a similar reason.
@@ -77,7 +77,7 @@ pipeStrict params input = do
- Note that to avoid deadlock with the cleanup stage,
- the reader must fully consume gpg's input before returning. -}
feedRead :: [CommandParam] -> String -> (Handle -> IO ()) -> (Handle -> IO a) -> IO a
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
feedRead params passphrase feeder reader = do
-- pipe the passphrase into gpg on a fd
(frompipe, topipe) <- createPipe
diff --git a/Utility/LogFile.hs b/Utility/LogFile.hs
index 339d6e8b9..25f2e10fe 100644
--- a/Utility/LogFile.hs
+++ b/Utility/LogFile.hs
@@ -14,7 +14,7 @@ import Common
import System.Posix.Types
openLog :: FilePath -> IO Fd
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
openLog logfile = do
rotateLog logfile
openFd logfile WriteOnly (Just stdFileMode)
@@ -50,7 +50,7 @@ maxLogs :: Int
maxLogs = 9
redirLog :: Fd -> IO ()
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
redirLog logfd = do
mapM_ (redir logfd) [stdOutput, stdError]
closeFd logfd
@@ -58,7 +58,7 @@ redirLog logfd = do
redirLog _ = error "redirLog TODO"
#endif
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
redir :: Fd -> Fd -> IO ()
redir newh h = do
closeFd h
diff --git a/Utility/Path.hs b/Utility/Path.hs
index 0a9931c46..79e8e8089 100644
--- a/Utility/Path.hs
+++ b/Utility/Path.hs
@@ -16,7 +16,7 @@ import Data.List
import Data.Maybe
import Control.Applicative
-#ifdef __WINDOWS__
+#ifdef mingw32_HOST_OS
import Data.Char
import qualified System.FilePath.Posix as Posix
#else
@@ -38,7 +38,7 @@ import Utility.UserInfo
- no normalization is done.
-}
absNormPath :: FilePath -> FilePath -> Maybe FilePath
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
absNormPath dir path = MissingH.absNormPath dir path
#else
absNormPath dir path = Just $ combine dir path
@@ -183,7 +183,7 @@ searchPath command
where
indir d = check $ d </> command
check f = firstM doesFileExist
-#ifdef __WINDOWS__
+#ifdef mingw32_HOST_OS
[f, f ++ ".exe"]
#else
[f]
@@ -203,7 +203,7 @@ dotfile file
{- Converts a DOS style path to a Cygwin style path. Only on Windows.
- Any trailing '\' is preserved as a trailing '/' -}
toCygPath :: FilePath -> FilePath
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
toCygPath = id
#else
toCygPath p
@@ -226,7 +226,7 @@ toCygPath p
- limit.
-}
fileNameLengthLimit :: FilePath -> IO Int
-#ifdef __WINDOWS__
+#ifdef mingw32_HOST_OS
fileNameLengthLimit _ = return 255
#else
fileNameLengthLimit dir = do
diff --git a/Utility/ThreadScheduler.hs b/Utility/ThreadScheduler.hs
index 2b26baeb6..c3e871cde 100644
--- a/Utility/ThreadScheduler.hs
+++ b/Utility/ThreadScheduler.hs
@@ -13,7 +13,7 @@ module Utility.ThreadScheduler where
import Common
import Control.Concurrent
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
import System.Posix.Signals
#ifndef __ANDROID__
import System.Posix.Terminal
@@ -54,7 +54,7 @@ unboundDelay time = do
waitForTermination :: IO ()
waitForTermination = do
lock <- newEmptyMVar
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
let check sig = void $
installHandler sig (CatchOnce $ putMVar lock ()) Nothing
check softwareTermination
diff --git a/Utility/UserInfo.hs b/Utility/UserInfo.hs
index 3a71c6baf..9c3bfd42f 100644
--- a/Utility/UserInfo.hs
+++ b/Utility/UserInfo.hs
@@ -24,7 +24,7 @@ import Utility.Env
myHomeDir :: IO FilePath
myHomeDir = myVal env homeDirectory
where
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
env = ["HOME"]
#else
env = ["USERPROFILE", "HOME"] -- HOME is used in Cygwin
@@ -34,7 +34,7 @@ myHomeDir = myVal env homeDirectory
myUserName :: IO String
myUserName = myVal env userName
where
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
env = ["USER", "LOGNAME"]
#else
env = ["USERNAME", "USER", "LOGNAME"]