Commit 945c45ad authored by Ben Gamari's avatar Ben Gamari 🐢

Prefer #if defined to #ifdef

Our new CPP linter enforces this.
parent e5b3492f
......@@ -483,7 +483,7 @@ plusParent p1 p2@(FldParent _ _) = hasParent p2 p1
plusParent _ _ = NoParent
hasParent :: Parent -> Parent -> Parent
#ifdef DEBUG
#if defined(DEBUG)
hasParent p NoParent = p
hasParent p p'
| p /= p' = pprPanic "hasParent" (ppr p <+> ppr p') -- Parents should agree
......
......@@ -183,7 +183,7 @@ mkNop :: CmmAGraph
mkNop = nilOL
mkComment :: FastString -> CmmAGraph
#ifdef DEBUG
#if defined(DEBUG)
-- SDM: generating all those comments takes time, this saved about 4% for me
mkComment fs = mkMiddle $ CmmComment fs
#else
......
......@@ -541,7 +541,7 @@ findRhsArity dflags bndr rhs old_arity
| cur_arity <= old_arity = cur_arity
| new_arity == cur_arity = cur_arity
| otherwise = ASSERT( new_arity < cur_arity )
#ifdef DEBUG
#if defined(DEBUG)
pprTrace "Exciting arity"
(vcat [ ppr bndr <+> ppr cur_arity <+> ppr new_arity
, ppr rhs])
......
......@@ -156,7 +156,7 @@ deSugar hsc_env
-- You might think it doesn't matter, but the simplifier brings all top-level
-- things into the in-scope set before simplifying; so we get no unfolding for F#!
#ifdef DEBUG
#if defined(DEBUG)
-- Debug only as pre-simple-optimisation program may be really big
; endPassIO hsc_env print_unqual CoreDesugar final_pgm rules_for_imps
#endif
......
......@@ -47,7 +47,7 @@ module GHCi
) where
import GHCi.Message
#ifdef GHCI
#if defined(GHCI)
import GHCi.Run
#endif
import GHCi.RemoteTypes
......@@ -83,7 +83,7 @@ import GHC.Stack (CostCentre,CostCentreStack)
import System.Exit
import Data.Maybe
import GHC.IO.Handle.Types (Handle)
#ifdef mingw32_HOST_OS
#if defined(mingw32_HOST_OS)
import Foreign.C
import GHC.IO.Handle.FD (fdToHandle)
#if !MIN_VERSION_process(1,4,2)
......@@ -162,7 +162,7 @@ Other Notes on Remote GHCi
* Note [Remote Template Haskell] in libraries/ghci/GHCi/TH.hs
-}
#ifndef GHCI
#if !defined(GHCI)
needExtInt :: IO a
needExtInt = throwIO
(InstallationError "this operation requires -fexternal-interpreter")
......@@ -180,7 +180,7 @@ iservCmd hsc_env@HscEnv{..} msg
uninterruptibleMask_ $ do -- Note [uninterruptibleMask_]
iservCall iserv msg
| otherwise = -- Just run it directly
#ifdef GHCI
#if defined(GHCI)
run msg
#else
needExtInt
......@@ -385,7 +385,7 @@ lookupSymbol hsc_env@HscEnv{..} str
writeIORef iservLookupSymbolCache $! addToUFM cache str p
return (Just p)
| otherwise =
#ifdef GHCI
#if defined(GHCI)
fmap fromRemotePtr <$> run (LookupSymbol (unpackFS str))
#else
needExtInt
......@@ -525,7 +525,7 @@ stopIServ HscEnv{..} =
runWithPipes :: (CreateProcess -> IO ProcessHandle)
-> FilePath -> [String] -> IO (ProcessHandle, Handle, Handle)
#ifdef mingw32_HOST_OS
#if defined(mingw32_HOST_OS)
foreign import ccall "io.h _close"
c__close :: CInt -> IO CInt
......@@ -652,7 +652,7 @@ wormholeRef dflags _r
| gopt Opt_ExternalInterpreter dflags
= throwIO (InstallationError
"this operation requires -fno-external-interpreter")
#ifdef GHCI
#if defined(GHCI)
| otherwise
= localRef _r
#else
......
......@@ -1400,7 +1400,7 @@ checkModUsage _this_pkg UsageFile{ usg_file_path = file,
where
recomp = RecompBecause (file ++ " changed")
handle =
#ifdef DEBUG
#if defined(DEBUG)
\e -> pprTrace "UsageFile" (text (show e)) $ return recomp
#else
\_ -> return recomp -- if we can't find the file, just recompile, don't fail
......
......@@ -868,7 +868,7 @@ ppFloat = ppDouble . widenFp
-- | Reverse or leave byte data alone to fix endianness on this target.
fixEndian :: [a] -> [a]
#ifdef WORDS_BIGENDIAN
#if defined(WORDS_BIGENDIAN)
fixEndian = id
#else
fixEndian = reverse
......
......@@ -986,7 +986,7 @@ which will eliminate the expression entirely.
However, it's certainly possible and reasonable for this to occur in
hand-written C-- code. Consider something like:
#ifndef SOME_CONDITIONAL
#if !defined(SOME_CONDITIONAL)
#define CHECK_THING(x) 1
#else
#define CHECK_THING(x) some_operation((x))
......
......@@ -2636,7 +2636,7 @@ dynamic_flags_deps = [
, make_ord_flag defGhcFlag "static" (NoArg removeWayDyn)
, make_ord_flag defGhcFlag "dynamic" (NoArg (addWay WayDyn))
, make_ord_flag defGhcFlag "rdynamic" $ noArg $
#ifdef linux_HOST_OS
#if defined(linux_HOST_OS)
addOptl "-rdynamic"
#elif defined (mingw32_HOST_OS)
addOptl "-Wl,--export-all-symbols"
......@@ -4884,7 +4884,7 @@ addIncludePath p =
addFrameworkPath p =
upd (\s -> s{frameworkPaths = frameworkPaths s ++ splitPathList p})
#ifndef mingw32_TARGET_OS
#if !defined(mingw32_TARGET_OS)
split_marker :: Char
split_marker = ':' -- not configurable (ToDo)
#endif
......@@ -4896,7 +4896,7 @@ splitPathList s = filter notNull (splitUp s)
-- cause confusion when they are translated into -I options
-- for passing to gcc.
where
#ifndef mingw32_TARGET_OS
#if !defined(mingw32_TARGET_OS)
splitUp xs = split split_marker xs
#else
-- Windows: 'hybrid' support for DOS-style paths in directory lists.
......
......@@ -2,7 +2,7 @@
-- | Dynamically lookup up values from modules and loading them.
module DynamicLoading (
#ifdef GHCI
#if defined(GHCI)
-- * Loading plugins
loadPlugins,
loadFrontendPlugin,
......@@ -24,7 +24,7 @@ module DynamicLoading (
#endif
) where
#ifdef GHCI
#if defined(GHCI)
import Linker ( linkModule, getHValue )
import GHCi ( wormhole )
import SrcLoc ( noSrcSpan )
......@@ -66,7 +66,7 @@ import Data.List ( intercalate )
#endif
#ifdef GHCI
#if defined(GHCI)
loadPlugins :: HscEnv -> IO [(ModuleName, Plugin, [CommandLineOption])]
loadPlugins hsc_env
......
......@@ -81,7 +81,7 @@ import Data.List
import qualified Data.Map as Map
import qualified Data.Set as Set
#ifndef mingw32_HOST_OS
#if !defined(mingw32_HOST_OS)
import qualified System.Posix.Internals
#else /* Must be Win32 */
import Foreign
......@@ -102,7 +102,7 @@ import Control.Concurrent
import FastString
import SrcLoc ( SrcLoc, mkSrcLoc, noSrcSpan, mkSrcSpan )
#ifdef mingw32_HOST_OS
#if defined(mingw32_HOST_OS)
# if defined(i386_HOST_ARCH)
# define WINDOWS_CCONV stdcall
# elif defined(x86_64_HOST_ARCH)
......@@ -1539,7 +1539,7 @@ foreign import WINDOWS_CCONV unsafe "dynamic"
getBaseDir = return Nothing
#endif
#ifdef mingw32_HOST_OS
#if defined(mingw32_HOST_OS)
foreign import ccall unsafe "_getpid" getProcessID :: IO Int -- relies on Int == Int32 on Windows
#else
getProcessID :: IO Int
......
......@@ -9,7 +9,7 @@ places in the GHC library.
#include <string.h>
#ifdef HAVE_UNISTD_H
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
......
......@@ -2272,7 +2272,7 @@ primop WaitWriteOp "waitWrite#" GenPrimOp
has_side_effects = True
out_of_line = True
#ifdef mingw32_TARGET_OS
#if defined(mingw32_TARGET_OS)
primop AsyncReadOp "asyncRead#" GenPrimOp
Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
{Asynchronously read bytes from specified file descriptor.}
......
......@@ -56,7 +56,7 @@ import Outputable
import Control.Monad
import qualified GHC.LanguageExtensions as LangExt
#ifdef GHCI
#if defined(GHCI)
import DynamicLoading ( loadPlugins )
import Plugins ( installCoreToDos )
#else
......@@ -368,7 +368,7 @@ getCoreToDo dflags
-- Loading plugins
addPluginPasses :: [CoreToDo] -> CoreM [CoreToDo]
#ifndef GHCI
#if !defined(GHCI)
addPluginPasses builtin_passes
= do { dflags <- getDynFlags
; let pluginMods = pluginModNames dflags
......@@ -493,7 +493,7 @@ doCorePass (CoreDoRuleCheck phase pat) = ruleCheckPass phase pat
doCorePass CoreDoNothing = return
doCorePass (CoreDoPasses passes) = runCorePasses passes
#ifdef GHCI
#if defined(GHCI)
doCorePass (CoreDoPluginPass _ pass) = {-# SCC "Plugin" #-} pass
#endif
......
......@@ -843,7 +843,7 @@ match_co renv subst co1 co2
_ -> Nothing
match_co _ _ _co1 _co2
-- Currently just deals with CoVarCo, TyConAppCo and Refl
#ifdef DEBUG
#if defined(DEBUG)
= pprTrace "match_co: needs more cases" (ppr _co1 $$ ppr _co2) Nothing
#else
= Nothing
......
......@@ -263,7 +263,7 @@ newCoercionHole
fillCoercionHole :: CoercionHole -> Coercion -> TcM ()
fillCoercionHole (CoercionHole u ref) co
= do {
#ifdef DEBUG
#if defined(DEBUG)
; cts <- readTcRef ref
; whenIsJust cts $ \old_co ->
pprPanic "Filling a filled coercion hole" (ppr u $$ ppr co $$ ppr old_co)
......
......@@ -3,7 +3,7 @@
-- access select functions of the 'TcM', principally those to do with
-- reading parts of the state.
module TcPluginM (
#ifdef GHCI
#if defined(GHCI)
-- * Basic TcPluginM functionality
TcPluginM,
tcPluginIO,
......@@ -52,7 +52,7 @@ module TcPluginM (
#endif
) where
#ifdef GHCI
#if defined(GHCI)
import qualified TcRnMonad as TcM
import qualified TcSMonad as TcS
import qualified TcEnv as TcM
......
......@@ -54,7 +54,7 @@ import RnFixity ( lookupFixityRn )
import MkId
import TidyPgm ( globaliseAndTidyId )
import TysWiredIn ( unitTy, mkListTy )
#ifdef GHCI
#if defined(GHCI)
import DynamicLoading ( loadPlugins )
import Plugins ( tcPlugin )
#endif
......@@ -2622,7 +2622,7 @@ withTcPlugins hsc_env m =
return (solve s, stop s)
loadTcPlugins :: HscEnv -> IO [TcPlugin]
#ifndef GHCI
#if !defined(GHCI)
loadTcPlugins _ = return []
#else
loadTcPlugins hsc_env =
......
......@@ -167,7 +167,7 @@ import MonadUtils
import Data.IORef
import Data.List ( foldl', partition )
#ifdef DEBUG
#if defined(DEBUG)
import Digraph
import UniqSet
#endif
......@@ -2397,14 +2397,14 @@ runTcSWithEvBinds ev_binds_var tcs
; when (count > 0) $
csTraceTcM $ return (text "Constraint solver steps =" <+> int count)
#ifdef DEBUG
#if defined(DEBUG)
; ev_binds <- TcM.getTcEvBindsMap ev_binds_var
; checkForCyclicBinds ev_binds
#endif
; return res }
#ifdef DEBUG
#if defined(DEBUG)
checkForCyclicBinds :: EvBindMap -> TcM ()
checkForCyclicBinds ev_binds_map
| null cycles
......@@ -2456,7 +2456,7 @@ nestImplicTcS ref inner_tclvl (TcS thing_inside)
; res <- TcM.setTcLevel inner_tclvl $
thing_inside nest_env
#ifdef DEBUG
#if defined(DEBUG)
-- Perform a check that the thing_inside did not cause cycles
; ev_binds <- TcM.getTcEvBindsMap ref
; checkForCyclicBinds ev_binds
......
......@@ -38,7 +38,7 @@ import Debug.Trace ( trace )
import System.IO.Unsafe
import System.Environment
#ifndef mingw32_HOST_OS
#if !defined(mingw32_HOST_OS)
import System.Posix.Signals as S
#endif
......
......@@ -168,7 +168,7 @@ import qualified Data.Set as Set
import Data.Time
#ifdef DEBUG
#if defined(DEBUG)
import {-# SOURCE #-} Outputable ( warnPprTrace, text )
#endif
......@@ -192,42 +192,42 @@ the flags are off.
-}
ghciSupported :: Bool
#ifdef GHCI
#if defined(GHCI)
ghciSupported = True
#else
ghciSupported = False
#endif
debugIsOn :: Bool
#ifdef DEBUG
#if defined(DEBUG)
debugIsOn = True
#else
debugIsOn = False
#endif
ncgDebugIsOn :: Bool
#ifdef NCG_DEBUG
#if defined(NCG_DEBUG)
ncgDebugIsOn = True
#else
ncgDebugIsOn = False
#endif
ghciTablesNextToCode :: Bool
#ifdef GHCI_TABLES_NEXT_TO_CODE
#if defined(GHCI_TABLES_NEXT_TO_CODE)
ghciTablesNextToCode = True
#else
ghciTablesNextToCode = False
#endif
isWindowsHost :: Bool
#ifdef mingw32_HOST_OS
#if defined(mingw32_HOST_OS)
isWindowsHost = True
#else
isWindowsHost = False
#endif
isDarwinHost :: Bool
#ifdef darwin_HOST_OS
#if defined(darwin_HOST_OS)
isDarwinHost = True
#else
isDarwinHost = False
......@@ -326,7 +326,7 @@ zipWithEqual :: String -> (a->b->c) -> [a]->[b]->[c]
zipWith3Equal :: String -> (a->b->c->d) -> [a]->[b]->[c]->[d]
zipWith4Equal :: String -> (a->b->c->d->e) -> [a]->[b]->[c]->[d]->[e]
#ifndef DEBUG
#if !defined(DEBUG)
zipEqual _ = zip
zipWithEqual _ = zipWith
zipWith3Equal _ = zipWith3
......@@ -544,7 +544,7 @@ notNull [] = False
notNull _ = True
only :: [a] -> a
#ifdef DEBUG
#if defined(DEBUG)
only [a] = a
#else
only (a:_) = a
......@@ -1345,7 +1345,7 @@ type HasCallStack = (() :: Constraint)
#endif
-- | A call stack constraint, but only when 'isDebugOn'.
#ifdef DEBUG
#if defined(DEBUG)
type HasDebugCallStack = HasCallStack
#else
type HasDebugCallStack = (() :: Constraint)
......
......@@ -52,7 +52,7 @@ int main(int argc, char** argv) {
from that in preference to the in-tree files. */
preArgv[0] = mkString("-B%s", binDir);
preArgv[1] = mkString("-B%s/../lib", binDir);
#ifdef __MINGW64__
#if defined(__MINGW64__)
base = mkString("x86_64-w64-mingw32");
#else
base = mkString("i686-w64-mingw32");
......
......@@ -122,7 +122,7 @@ import Text.Read.Lex (isSymbolChar)
import Unsafe.Coerce
#ifndef mingw32_HOST_OS
#if !defined(mingw32_HOST_OS)
import System.Posix hiding ( getEnv )
#else
import qualified System.Win32
......@@ -379,7 +379,7 @@ findEditor :: IO String
findEditor = do
getEnv "EDITOR"
`catchIO` \_ -> do
#ifdef mingw32_HOST_OS
#if defined(mingw32_HOST_OS)
win <- System.Win32.getWindowsDirectory
return (win </> "notepad.exe")
#else
......@@ -669,7 +669,7 @@ checkFileAndDirPerms file = do
d -> d
checkPerms :: FilePath -> IO Bool
#ifdef mingw32_HOST_OS
#if defined(mingw32_HOST_OS)
checkPerms _ = return True
#else
checkPerms file =
......@@ -720,7 +720,7 @@ formatCurrentTime format =
getUserName :: IO String
getUserName = do
#ifdef mingw32_HOST_OS
#if defined(mingw32_HOST_OS)
getEnv "USERNAME"
`catchIO` \e -> do
putStrLn $ show e
......
......@@ -25,12 +25,12 @@ import HscMain ( newHscEnv )
import DriverPipeline ( oneShot, compileFile )
import DriverMkDepend ( doMkDependHS )
import DriverBkp ( doBackpack )
#ifdef GHCI
#if defined(GHCI)
import GHCi.UI ( interactiveUI, ghciWelcomeMsg, defaultGhciSettings )
#endif
-- Frontend plugins
#ifdef GHCI
#if defined(GHCI)
import DynamicLoading ( loadFrontendPlugin )
import Plugins
#else
......@@ -258,7 +258,7 @@ main' postLoadMode dflags0 args flagWarnings = do
liftIO $ dumpFinalStats dflags6
ghciUI :: [(FilePath, Maybe Phase)] -> Maybe [String] -> Ghc ()
#ifndef GHCI
#if !defined(GHCI)
ghciUI _ _ = throwGhcException (CmdLineError "not built for interactive use")
#else
ghciUI = interactiveUI defaultGhciSettings
......@@ -504,7 +504,7 @@ isDoEvalMode :: Mode -> Bool
isDoEvalMode (Right (Right (DoEval _))) = True
isDoEvalMode _ = False
#ifdef GHCI
#if defined(GHCI)
isInteractiveMode :: PostLoadMode -> Bool
isInteractiveMode DoInteractive = True
isInteractiveMode _ = False
......@@ -735,7 +735,7 @@ showBanner :: PostLoadMode -> DynFlags -> IO ()
showBanner _postLoadMode dflags = do
let verb = verbosity dflags
#ifdef GHCI
#if defined(GHCI)
-- Show the GHCi banner
when (isInteractiveMode _postLoadMode && verb >= 1) $ putStrLn ghciWelcomeMsg
#endif
......@@ -831,7 +831,7 @@ dumpPackagesSimple dflags = putMsg dflags (pprPackagesSimple dflags)
-- Frontend plugin support
doFrontend :: ModuleName -> [(String, Maybe Phase)] -> Ghc ()
#ifndef GHCI
#if !defined(GHCI)
doFrontend modname _ = pluginError [modname]
#else
doFrontend modname srcs = do
......
......@@ -18,7 +18,7 @@ in instead of the defaults.
#include <string.h>
#include <stdbool.h>
#ifdef HAVE_UNISTD_H
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
......
......@@ -120,13 +120,13 @@
name : bits8[] str; \
} \
#ifdef TABLES_NEXT_TO_CODE
#if defined(TABLES_NEXT_TO_CODE)
#define RET_LBL(f) f##_info
#else
#define RET_LBL(f) f##_ret
#endif
#ifdef TABLES_NEXT_TO_CODE
#if defined(TABLES_NEXT_TO_CODE)
#define ENTRY_LBL(f) f##_info
#else
#define ENTRY_LBL(f) f##_entry
......@@ -204,7 +204,7 @@
Assertions and Debuggery
-------------------------------------------------------------------------- */
#ifdef DEBUG
#if defined(DEBUG)
#define ASSERT(predicate) \
if (predicate) { \
/*null*/; \
......@@ -215,7 +215,7 @@
#define ASSERT(p) /* nothing */
#endif
#ifdef DEBUG
#if defined(DEBUG)
#define DEBUG_ONLY(s) s
#else
#define DEBUG_ONLY(s) /* nothing */
......@@ -230,7 +230,7 @@
*
* Note the syntax is slightly different to the C version of this macro.
*/
#ifdef DEBUG
#if defined(DEBUG)
#define IF_DEBUG(c,s) if (RtsFlags_DebugFlags_##c(RtsFlags) != 0::CBool) { s; }
#else
#define IF_DEBUG(c,s) /* nothing */
......@@ -256,7 +256,7 @@
Indirections can contain tagged pointers, so their tag is checked.
-------------------------------------------------------------------------- */
#ifdef PROFILING
#if defined(PROFILING)
// When profiling, we cannot shortcut ENTER() by checking the tag,
// because LDV profiling relies on entering closures to mark them as
......@@ -589,7 +589,7 @@
* depending on TABLES_NEXT_TO_CODE. So we define field access
* macros which use the appropriate version here:
*/
#ifdef TABLES_NEXT_TO_CODE
#if defined(TABLES_NEXT_TO_CODE)
/*
* when TABLES_NEXT_TO_CODE, slow_apply is stored as an offset
* instead of the normal pointer.
......@@ -623,7 +623,7 @@
#define OVERWRITING_CLOSURE_OFS(c,n) /* nothing */
#endif
#ifdef THREADED_RTS
#if defined(THREADED_RTS)
#define prim_write_barrier prim %write_barrier()
#else
#define prim_write_barrier /* nothing */
......@@ -633,7 +633,7 @@
Ticky macros
-------------------------------------------------------------------------- */
#ifdef TICKY_TICKY
#if defined(TICKY_TICKY)
#define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n
#else
#define TICK_BUMP_BY(ctr,n) /* nothing */
......
This diff is collapsed.
......@@ -11,7 +11,7 @@
#pragma once
#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif
......@@ -118,6 +118,6 @@ extern void hs_try_putmvar (int capability, HsStablePtr sp);
#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif
......@@ -100,7 +100,7 @@
#define SIZEOF_WORD64 SIZEOF_UINT64_T
#define ALIGNMENT_WORD64 ALIGNMENT_UINT64_T
#ifndef WORD_SIZE_IN_BITS
#if !defined(WORD_SIZE_IN_BITS)
#if SIZEOF_HSWORD == 4
#define WORD_SIZE_IN_BITS 32
#define WORD_SIZE_IN_BITS_FLOAT 32.0
......@@ -110,7 +110,7 @@
#endif
#endif
#ifndef TAG_BITS
#if !defined(TAG_BITS)
#if SIZEOF_HSWORD == 4
#define TAG_BITS 2
#else
......
......@@ -12,7 +12,7 @@
#pragma once
#ifdef __cplusplus