diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-06-09 09:50:41 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-06-12 08:20:25 -0400 |
commit | 898f7e9235eff57ececac4836f6ba74388131db2 (patch) | |
tree | c9dcbdaa5f6c66c55970458f4a5650836092ebf6 | |
parent | 0782141ef52c72523b82cd83b7466a3a65d94a31 (diff) | |
download | haskell-898f7e9235eff57ececac4836f6ba74388131db2.tar.gz |
Fix uses of #ifdef/#ifndef
The linter now enforces our preference for `#if defined()` and
`#if !defined()`.
-rw-r--r-- | aclocal.m4 | 12 | ||||
-rw-r--r-- | hadrian/src/Rules/Generate.hs | 10 | ||||
-rw-r--r-- | includes/ghc.mk | 6 |
3 files changed, 14 insertions, 14 deletions
diff --git a/aclocal.m4 b/aclocal.m4 index f33c50c5ac..0d4727ff2b 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -866,7 +866,7 @@ case $TargetPlatform in esac ;; i386-unknown-mingw32) fptools_cv_leading_underscore=yes;; x86_64-unknown-mingw32) fptools_cv_leading_underscore=no;; - *) AC_RUN_IFELSE([AC_LANG_SOURCE([[#ifdef HAVE_NLIST_H + *) AC_RUN_IFELSE([AC_LANG_SOURCE([[#if defined(HAVE_NLIST_H) #include <nlist.h> struct nlist xYzzY1[] = {{"xYzzY1", 0},{0}}; struct nlist xYzzY2[] = {{"_xYzzY2", 0},{0}}; @@ -876,7 +876,7 @@ int main(argc, argv) int argc; char **argv; { -#ifdef HAVE_NLIST_H +#if defined(HAVE_NLIST_H) if(nlist(argv[0], xYzzY1) == 0 && xYzzY1[0].n_value != 0) exit(1); if(nlist(argv[0], xYzzY2) == 0 && xYzzY2[0].n_value != 0) @@ -1650,16 +1650,16 @@ then [fptools_cv_timer_create_works], [AC_TRY_RUN([ #include <stdio.h> -#ifdef HAVE_STDLIB_H +#if defined(HAVE_STDLIB_H) #include <stdlib.h> #endif -#ifdef HAVE_TIME_H +#if defined(HAVE_TIME_H) #include <time.h> #endif -#ifdef HAVE_SIGNAL_H +#if defined(HAVE_SIGNAL_H) #include <signal.h> #endif -#ifdef HAVE_UNISTD_H +#if defined(HAVE_UNISTD_H) #include <unistd.h> #endif diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index c755e389eb..7f7fd2ee47 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -233,7 +233,7 @@ generateGhcPlatformH = do targetVendor <- getSetting TargetVendor ghcUnreg <- getFlag GhcUnregisterised return . unlines $ - [ "#ifndef __GHCPLATFORM_H__" + [ "#if !defined(__GHCPLATFORM_H__)" , "#define __GHCPLATFORM_H__" , "" , "#define BuildPlatform_TYPE " ++ cppify hostPlatform @@ -386,7 +386,7 @@ generateGhcAutoconfH = do ccLlvmBackend <- getSetting CcLlvmBackend ccClangBackend <- getSetting CcClangBackend return . unlines $ - [ "#ifndef __GHCAUTOCONF_H__" + [ "#if !defined(__GHCAUTOCONF_H__)" , "#define __GHCAUTOCONF_H__" ] ++ configHContents ++ [ "\n#define TABLES_NEXT_TO_CODE 1" | tablesNextToCode && not ghcUnreg ] @@ -422,7 +422,7 @@ generateGhcBootPlatformH = do targetOs <- getSetting TargetOs targetVendor <- getSetting TargetVendor return $ unlines - [ "#ifndef __PLATFORM_H__" + [ "#if !defined(__PLATFORM_H__)" , "#define __PLATFORM_H__" , "" , "#define BuildPlatform_NAME " ++ show buildPlatform @@ -464,10 +464,10 @@ generateGhcVersionH = do patchLevel1 <- getSetting ProjectPatchLevel1 patchLevel2 <- getSetting ProjectPatchLevel2 return . unlines $ - [ "#ifndef __GHCVERSION_H__" + [ "#if !defined(__GHCVERSION_H__)" , "#define __GHCVERSION_H__" , "" - , "#ifndef __GLASGOW_HASKELL__" + , "#if !defined(__GLASGOW_HASKELL__)" , "# define __GLASGOW_HASKELL__ " ++ version , "#endif" , ""] diff --git a/includes/ghc.mk b/includes/ghc.mk index 2421d9ca96..0d55c772e0 100644 --- a/includes/ghc.mk +++ b/includes/ghc.mk @@ -57,7 +57,7 @@ endif $(includes_H_VERSION) : mk/project.mk | $$(dir $$@)/. @echo "Creating $@..." - @echo "#ifndef __GHCVERSION_H__" > $@ + @echo "#if !defined(__GHCVERSION_H__)" > $@ @echo "#define __GHCVERSION_H__" >> $@ @echo >> $@ @echo "#define __GLASGOW_HASKELL__ $(ProjectVersionInt)" >> $@ @@ -92,7 +92,7 @@ else $(includes_H_CONFIG) : mk/config.h mk/config.mk includes/ghc.mk | $$(dir $$@)/. @echo "Creating $@..." - @echo "#ifndef __GHCAUTOCONF_H__" >$@ + @echo "#if !defined(__GHCAUTOCONF_H__)" >$@ @echo "#define __GHCAUTOCONF_H__" >>$@ # # Copy the contents of mk/config.h, turning '#define PACKAGE_FOO @@ -125,7 +125,7 @@ endif $(includes_H_PLATFORM) : includes/Makefile | $$(dir $$@)/. $(call removeFiles,$@) @echo "Creating $@..." - @echo "#ifndef __GHCPLATFORM_H__" >$@ + @echo "#if !defined(__GHCPLATFORM_H__)" >$@ @echo "#define __GHCPLATFORM_H__" >>$@ @echo >> $@ @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@ |