diff options
67 files changed, 489 insertions, 332 deletions
diff --git a/ghc/compiler/HsVersions.h b/ghc/compiler/HsVersions.h index af83b10c35..1c07d2c5ae 100644 --- a/ghc/compiler/HsVersions.h +++ b/ghc/compiler/HsVersions.h @@ -10,6 +10,18 @@ you will screw up the layout where they are used in case expressions! #endif +/* Useful in the headers that we share with the RTS */ +#define COMPILING_GHC 1 + +/* Pull in all the platform defines for this build (foo_TARGET_ARCH etc.) */ +#include "ghc_boot_platform.h" + +/* Pull in the autoconf defines (HAVE_FOO), but don't include + * ghcconfig.h, because that will include ghcplatform.h which has the + * wrong platform settings for the compiler (it has the platform + * settings for the target plat instead). */ +#include "../includes/ghcautoconf.h" + #if __GLASGOW_HASKELL__ >= 504 #define CONCURRENT Control.Concurrent diff --git a/ghc/compiler/Makefile b/ghc/compiler/Makefile index b145c60401..8324e8b03c 100644 --- a/ghc/compiler/Makefile +++ b/ghc/compiler/Makefile @@ -194,9 +194,6 @@ $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk Makefile @echo "cProjectPatchLevel = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS) @echo "cBooterVersion = \"$(GhcVersion)\"" >> $(CONFIG_HS) @echo "cHscIfaceFileVersion = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS) - @echo "cTARGETPLATFORM = \"$(TARGETPLATFORM)\"" >> $(CONFIG_HS) - @echo "cTARGETOS = \"$(TargetOS_CPP)\"" >> $(CONFIG_HS) - @echo "cTARGETARCH = \"$(TargetArch_CPP)\"" >> $(CONFIG_HS) @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS) @echo "cGhcUnregisterised = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS) @echo "cLeadingUnderscore = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS) @@ -231,6 +228,112 @@ endif CLEAN_FILES += $(CONFIG_HS) # ----------------------------------------------------------------------------- +# Create platform includes + +# Here we generate a little header file containing CPP symbols that GHC +# uses to determine which platform it is building on/for. The platforms +# can differ between stage1 and stage2 if we're cross-compiling, so we +# need one of these header files per stage. + +PLATFORM_H = ghc_boot_platform.h + +stage1/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk Makefile + @echo "Creating $@..." + @$(RM) $@ + @echo "#ifndef __PLATFORM_H__" >$@ + @echo "#define __PLATFORM_H__" >>$@ + @echo >> $@ + @echo "#define BuildPlatform_TYPE $(BuildPlatform_CPP)" >> $@ + @echo "#define HostPlatform_TYPE $(HostPlatform_CPP)" >> $@ + @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@ + @echo >> $@ + @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@ + @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@ + @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@ + @echo >> $@ + @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@ + @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@ + @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@ + @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@ + @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@ + @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@ + @echo >> $@ + @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@ + @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@ + @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@ + @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@ + @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@ + @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@ +ifeq "$(HostOS_CPP)" "irix" + @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@ + @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@ + @echo "#endif " >> $@ +endif + @echo >> $@ + @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@ + @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@ + @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@ + @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@ + @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@ + @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@ + @echo >> $@ + @echo "#endif /* __PLATFORM_H__ */" >> $@ + @echo "Done." + +# For stage2 and above, the BUILD platform is the HOST of stage1, and +# the HOST platform is the TARGET of stage1. The TARGET remains the same +# (stage1 is the cross-compiler, not stage2). +stage2/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk Makefile + @echo "Creating $@..." + @$(RM) $@ + @echo "#ifndef __PLATFORM_H__" >$@ + @echo "#define __PLATFORM_H__" >>$@ + @echo >> $@ + @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@ + @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@ + @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@ + @echo >> $@ + @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@ + @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@ + @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@ + @echo >> $@ + @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@ + @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@ + @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@ + @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@ + @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@ + @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@ + @echo >> $@ + @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@ + @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@ + @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@ + @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@ + @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@ + @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@ +ifeq "$(HostOS_CPP)" "irix" + @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@ + @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@ + @echo "#endif " >> $@ +endif + @echo >> $@ + @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@ + @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@ + @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@ + @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@ + @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@ + @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@ + @echo >> $@ + @echo "#endif /* __PLATFORM_H__ */" >> $@ + @echo "Done." + +stage3/$(PLATFORM_H) : stage2/$(PLATFORM_H) + $(CP) stage2/$(PLATFORM_H) stage3/$(PLATFORM_H) + +boot :: stage$(stage)/$(PLATFORM_H) + +SRC_HC_OPTS += -Istage$(stage) + +# ----------------------------------------------------------------------------- # Set SRCS etc. # # First figure out ALL_DIRS, the source sub-directories diff --git a/ghc/compiler/cmm/CLabel.hs b/ghc/compiler/cmm/CLabel.hs index 0fd4ba45ef..e73232176b 100644 --- a/ghc/compiler/cmm/CLabel.hs +++ b/ghc/compiler/cmm/CLabel.hs @@ -98,7 +98,6 @@ module CLabel ( #include "HsVersions.h" -#include "../includes/ghcconfig.h" import CmdLineOpts ( DynFlags, opt_Static, opt_DoTickyProfiling ) import Packages ( isHomeModule, isDllName ) diff --git a/ghc/compiler/cmm/MachOp.hs b/ghc/compiler/cmm/MachOp.hs index dcf9bb6fc5..5bbff6de78 100644 --- a/ghc/compiler/cmm/MachOp.hs +++ b/ghc/compiler/cmm/MachOp.hs @@ -80,7 +80,6 @@ module MachOp ( ) where #include "HsVersions.h" -#include "../includes/ghcconfig.h" import Constants import Outputable diff --git a/ghc/compiler/codeGen/CgProf.hs b/ghc/compiler/codeGen/CgProf.hs index d54718f495..5177072bf6 100644 --- a/ghc/compiler/codeGen/CgProf.hs +++ b/ghc/compiler/codeGen/CgProf.hs @@ -24,8 +24,6 @@ module CgProf ( ) where #include "HsVersions.h" -#include "../includes/ghcconfig.h" - -- Needed by Constants.h #include "../includes/Constants.h" -- For LDV_CREATE_MASK, LDV_STATE_USE -- which are StgWords diff --git a/ghc/compiler/codeGen/CgUtils.hs b/ghc/compiler/codeGen/CgUtils.hs index 8c29e9c136..9a99bfd126 100644 --- a/ghc/compiler/codeGen/CgUtils.hs +++ b/ghc/compiler/codeGen/CgUtils.hs @@ -60,9 +60,6 @@ import Char ( ord ) import DATA_BITS import Maybe ( isNothing ) -#include "../includes/ghcconfig.h" - -- For WORDS_BIGENDIAN - ------------------------------------------------------------------------- -- -- Random small functions diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 35f98144f8..ec59f0b4e1 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,6 +1,6 @@ {-# OPTIONS -#include "Linker.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.184 2005/01/26 12:58:09 simonmar Exp $ +-- $Id: InteractiveUI.hs,v 1.185 2005/01/28 12:55:23 simonmar Exp $ -- -- GHC Interactive User Interface -- @@ -12,7 +12,6 @@ module InteractiveUI ( ghciWelcomeMsg ) where -#include "../includes/ghcconfig.h" #include "HsVersions.h" import CompManager diff --git a/ghc/compiler/ghci/Linker.lhs b/ghc/compiler/ghci/Linker.lhs index 95d81bc891..ab4cafe246 100644 --- a/ghc/compiler/ghci/Linker.lhs +++ b/ghc/compiler/ghci/Linker.lhs @@ -20,7 +20,6 @@ module Linker ( HValue, showLinkerState, linkPackages, ) where -#include "../includes/ghcconfig.h" #include "HsVersions.h" import ObjLink ( loadDLL, loadObj, unloadObj, resolveObjs, initObjLinker ) diff --git a/ghc/compiler/main/CmdLineOpts.lhs b/ghc/compiler/main/CmdLineOpts.lhs index 57fc0ae152..2d4b4e9d78 100644 --- a/ghc/compiler/main/CmdLineOpts.lhs +++ b/ghc/compiler/main/CmdLineOpts.lhs @@ -348,11 +348,10 @@ data PackageFlag | IgnorePackage String defaultHscTarget - | cGhcWithNativeCodeGen == "YES" && - (prefixMatch "i386" cTARGETPLATFORM || - prefixMatch "sparc" cTARGETPLATFORM || - prefixMatch "powerpc" cTARGETPLATFORM) = HscAsm - | otherwise = HscC +#if defined(i386_TARGET_ARCH) || defined(sparc_TARGET_ARCH) || defined(powerpc_TARGET_ARCH) + | cGhcWithNativeCodeGen == "YES" = HscAsm +#endif + | otherwise = HscC defaultDynFlags = DynFlags { coreToDo = Nothing, stgToDo = [], diff --git a/ghc/compiler/main/Constants.lhs b/ghc/compiler/main/Constants.lhs index ac6bddc1ac..0f9f49286a 100644 --- a/ghc/compiler/main/Constants.lhs +++ b/ghc/compiler/main/Constants.lhs @@ -12,7 +12,6 @@ module Constants (module Constants) where -- be in trouble. #include "HsVersions.h" -#include "../includes/ghcconfig.h" #include "../includes/MachRegs.h" #include "../includes/Constants.h" #include "../includes/MachDeps.h" diff --git a/ghc/compiler/main/DriverFlags.hs b/ghc/compiler/main/DriverFlags.hs index 55c8e5456a..2148f5ebcd 100644 --- a/ghc/compiler/main/DriverFlags.hs +++ b/ghc/compiler/main/DriverFlags.hs @@ -18,7 +18,6 @@ module DriverFlags ( ) where #include "HsVersions.h" -#include "../includes/ghcconfig.h" import MkIface ( showIface ) import DriverState @@ -639,7 +638,7 @@ setMainIs arg -- ) machdepCCOpts dflags - | prefixMatch "alpha" cTARGETPLATFORM +#if alpha_TARGET_ARCH = return ( ["-w", "-mieee" #ifdef HAVE_THREADED_RTS_SUPPORT , "-D_REENTRANT" @@ -649,12 +648,12 @@ machdepCCOpts dflags -- register used for global register variable", we simply -- disable all warnings altogether using the -w flag. Oh well. - | prefixMatch "hppa" cTARGETPLATFORM +#elif hppa_TARGET_ARCH -- ___HPUX_SOURCE, not _HPUX_SOURCE, is #defined if -ansi! -- (very nice, but too bad the HP /usr/include files don't agree.) = return ( ["-D_HPUX_SOURCE"], [] ) - | prefixMatch "m68k" cTARGETPLATFORM +#elif m68k_TARGET_ARCH -- -fno-defer-pop : for the .hc files, we want all the pushing/ -- popping of args to routines to be explicit; if we let things -- be deferred 'til after an STGJUMP, imminent death is certain! @@ -666,7 +665,7 @@ machdepCCOpts dflags -- as on iX86, where we *do* steal the frame pointer [%ebp].) = return ( [], ["-fno-defer-pop", "-fno-omit-frame-pointer"] ) - | prefixMatch "i386" cTARGETPLATFORM +#elif i386_TARGET_ARCH -- -fno-defer-pop : basically the same game as for m68k -- -- -fomit-frame-pointer : *must* in .hc files; because we're stealing @@ -692,22 +691,22 @@ machdepCCOpts dflags "-DSTOLEN_X86_REGS="++show n_regs ] ) - | prefixMatch "ia64" cTARGETPLATFORM +#elif ia64_TARGET_ARCH = return ( [], ["-fomit-frame-pointer", "-G0"] ) - | prefixMatch "x86_64" cTARGETPLATFORM +#elif x86_64_TARGET_ARCH = return ( [], ["-fomit-frame-pointer"] ) - | prefixMatch "mips" cTARGETPLATFORM +#elif mips_TARGET_ARCH = return ( ["-static"], [] ) - | prefixMatch "sparc" cTARGETPLATFORM +#elif sparc_TARGET_ARCH = return ( [], ["-w"] ) -- For now, to suppress the gcc warning "call-clobbered -- register used for global register variable", we simply -- disable all warnings altogether using the -w flag. Oh well. - | prefixMatch "powerpc-apple-darwin" cTARGETPLATFORM +#elif powerpc_apple_darwin_TARGET -- -no-cpp-precomp: -- Disable Apple's precompiling preprocessor. It's a great thing -- for "normal" programs, but it doesn't support register variable @@ -724,11 +723,12 @@ machdepCCOpts dflags else return ( ["-no-cpp-precomp", "-mdynamic-no-pic"], ["-mdynamic-no-pic"] ) - | prefixMatch "powerpc" cTARGETPLATFORM && opt_PIC +#elif powerpc_TARGET_ARCH + | opt_PIC = return ( ["-fPIC"], ["-fPIC"] ) - | otherwise = return ( [], [] ) +#endif ----------------------------------------------------------------------------- -- local utils diff --git a/ghc/compiler/main/DriverPhases.hs b/ghc/compiler/main/DriverPhases.hs index 0b1c41536e..a16ad32c7b 100644 --- a/ghc/compiler/main/DriverPhases.hs +++ b/ghc/compiler/main/DriverPhases.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverPhases.hs,v 1.32 2005/01/27 10:44:27 simonpj Exp $ +-- $Id: DriverPhases.hs,v 1.33 2005/01/28 12:55:33 simonmar Exp $ -- -- GHC Driver -- @@ -7,8 +7,6 @@ -- ----------------------------------------------------------------------------- -#include "../includes/ghcconfig.h" - module DriverPhases ( HscSource(..), isHsBoot, hscSourceString, HscTarget(..), Phase(..), diff --git a/ghc/compiler/main/DriverPipeline.hs b/ghc/compiler/main/DriverPipeline.hs index 9b83280dbf..84b7a69db4 100644 --- a/ghc/compiler/main/DriverPipeline.hs +++ b/ghc/compiler/main/DriverPipeline.hs @@ -816,10 +816,12 @@ runPhase cc_phase todo dflags basename suff input_fn get_output_fn maybe_loc runPhase Mangle todo dflags _basename _suff input_fn get_output_fn maybe_loc = do let mangler_opts = getOpts dflags opt_m - machdep_opts <- if (prefixMatch "i386" cTARGETPLATFORM) - then do let n_regs = stolen_x86_regs dflags - return [ show n_regs ] - else return [] + +#if i386_TARGET_ARCH + machdep_opts <- return [ show (stolen_x86_regs dflags) ] +#else + machdep_opts <- return [] +#endif split <- readIORef v_Split_object_files let next_phase @@ -1253,8 +1255,12 @@ doCpp dflags raw include_cc_opts input_fn output_fn = do | otherwise = SysTools.runCc dflags (SysTools.Option "-E" : args) let target_defs = - [ "-D" ++ cTARGETOS ++ "_TARGET_OS=1", - "-D" ++ cTARGETARCH ++ "_TARGET_ARCH=1" ] + [ "-D" ++ HOST_OS ++ "BUILD_OS=1", + "-D" ++ HOST_ARCH ++ "BUILD_ARCH=1", + "-D" ++ TARGET_OS ++ "HOST_OS=1", + "-D" ++ TARGET_ARCH ++ "HOST_ARCH=1" ] + -- remember, in code we *compile*, the HOST is the same our TARGET, + -- and BUILD is the same as our HOST. cpp_prog ([SysTools.Option verb] ++ map SysTools.Option include_paths diff --git a/ghc/compiler/main/DriverState.hs b/ghc/compiler/main/DriverState.hs index 82447f16a4..4f953eb261 100644 --- a/ghc/compiler/main/DriverState.hs +++ b/ghc/compiler/main/DriverState.hs @@ -8,7 +8,6 @@ module DriverState where -#include "../includes/ghcconfig.h" #include "HsVersions.h" import CmdLineOpts @@ -128,14 +127,19 @@ GLOBAL_VAR(v_Split_info, ("",0), (String,Int)) can_split :: Bool -can_split = prefixMatch "i386" cTARGETPLATFORM - || prefixMatch "alpha" cTARGETPLATFORM - || prefixMatch "hppa" cTARGETPLATFORM - || prefixMatch "m68k" cTARGETPLATFORM - || prefixMatch "mips" cTARGETPLATFORM - || prefixMatch "powerpc" cTARGETPLATFORM - || prefixMatch "rs6000" cTARGETPLATFORM - || prefixMatch "sparc" cTARGETPLATFORM +can_split = +#if defined(i386_TARGET_ARCH) \ + || defined(alpha_TARGET_ARCH) \ + || defined(hppa_TARGET_ARCH) \ + || defined(m68k_TARGET_ARCH) \ + || defined(mips_TARGET_ARCH) \ + || defined(powerpc_TARGET_ARCH) \ + || defined(rs6000_TARGET_ARCH) \ + || defined(sparc_TARGET_ARCH) + True +#else + False +#endif ----------------------------------------------------------------------------- -- Compiler output options diff --git a/ghc/compiler/main/DriverUtil.hs b/ghc/compiler/main/DriverUtil.hs index 8a85670230..dab7eb68c2 100644 --- a/ghc/compiler/main/DriverUtil.hs +++ b/ghc/compiler/main/DriverUtil.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverUtil.hs,v 1.49 2005/01/11 16:21:53 simonmar Exp $ +-- $Id: DriverUtil.hs,v 1.50 2005/01/28 12:55:37 simonmar Exp $ -- -- Utils for the driver -- @@ -19,7 +19,6 @@ module DriverUtil ( replaceFilenameDirectory, remove_spaces, escapeSpaces, ) where -#include "../includes/ghcconfig.h" #include "HsVersions.h" import Util diff --git a/ghc/compiler/main/Main.hs b/ghc/compiler/main/Main.hs index 7a48726a18..a295b31a1a 100644 --- a/ghc/compiler/main/Main.hs +++ b/ghc/compiler/main/Main.hs @@ -1,7 +1,7 @@ {-# OPTIONS -fno-warn-incomplete-patterns -optc-DNON_POSIX_SOURCE #-} ----------------------------------------------------------------------------- --- $Id: Main.hs,v 1.143 2005/01/27 10:44:39 simonpj Exp $ +-- $Id: Main.hs,v 1.144 2005/01/28 12:55:38 simonmar Exp $ -- -- GHC Driver program -- @@ -9,14 +9,10 @@ -- ----------------------------------------------------------------------------- --- with path so that ghc -M can find config.h -#include "../includes/ghcconfig.h" - module Main (main) where #include "HsVersions.h" - #ifdef GHCI import InteractiveUI( ghciWelcomeMsg, interactiveUI ) #endif diff --git a/ghc/compiler/main/Packages.lhs b/ghc/compiler/main/Packages.lhs index 4b758b22fc..8a4009d89a 100644 --- a/ghc/compiler/main/Packages.lhs +++ b/ghc/compiler/main/Packages.lhs @@ -34,9 +34,6 @@ module Packages ( ) where -#include "../includes/ghcconfig.h" --- Needed for mingw32_TARGET_OS defn - #include "HsVersions.h" import PackageConfig @@ -44,7 +41,7 @@ import DriverState ( v_Build_tag, v_RTS_Build_tag, v_Static ) import SysTools ( getTopDir, getPackageConfigPath ) import ParsePkgConf ( loadPackageConfig ) import CmdLineOpts ( DynFlags(..), PackageFlag(..), opt_Static ) -import Config ( cTARGETARCH, cTARGETOS, cProjectVersion ) +import Config ( cProjectVersion ) import Name ( Name, nameModule_maybe ) import Module ( Module, mkModule ) import UniqFM @@ -206,7 +203,7 @@ readPackageConfigs dflags = do -- (GHC >= 6.3). appdir <- getAppUserDataDirectory "ghc" let - pkgconf = appdir ++ '/':cTARGETARCH ++ '-':cTARGETOS + pkgconf = appdir ++ '/':TARGET_ARCH ++ '-':TARGET_OS ++ '-':cProjectVersion ++ "/package.conf" -- exists <- doesFileExist pkgconf diff --git a/ghc/compiler/main/SysTools.lhs b/ghc/compiler/main/SysTools.lhs index 787222fe62..738e63f4c7 100644 --- a/ghc/compiler/main/SysTools.lhs +++ b/ghc/compiler/main/SysTools.lhs @@ -84,8 +84,6 @@ import IO ( try, catch, import Directory ( doesFileExist, removeFile ) import List ( partition ) -#include "../includes/ghcconfig.h" - -- GHC <= 4.08 didn't have rawSystem, and runs into problems with long command -- lines on mingw32, so we disallow it now. #if __GLASGOW_HASKELL__ < 500 diff --git a/ghc/compiler/nativeGen/MachInstrs.hs b/ghc/compiler/nativeGen/MachInstrs.hs index e48e1a9c0c..28e2578dc0 100644 --- a/ghc/compiler/nativeGen/MachInstrs.hs +++ b/ghc/compiler/nativeGen/MachInstrs.hs @@ -35,7 +35,6 @@ module MachInstrs ( ) where #include "HsVersions.h" -#include "../includes/ghcconfig.h" import MachRegs import Cmm diff --git a/ghc/compiler/nativeGen/NCG.h b/ghc/compiler/nativeGen/NCG.h index 48c1c79d1d..78db0c943f 100644 --- a/ghc/compiler/nativeGen/NCG.h +++ b/ghc/compiler/nativeGen/NCG.h @@ -9,7 +9,7 @@ #ifndef NCG_H #define NCG_H -#include "../includes/ghcconfig.h" +#include "ghc_boot_platform.h" #define COMMA , diff --git a/ghc/compiler/nativeGen/PositionIndependentCode.hs b/ghc/compiler/nativeGen/PositionIndependentCode.hs index a58d6ca95b..936b76afcb 100644 --- a/ghc/compiler/nativeGen/PositionIndependentCode.hs +++ b/ghc/compiler/nativeGen/PositionIndependentCode.hs @@ -1,5 +1,3 @@ -#include "../includes/ghcconfig.h" - module PositionIndependentCode ( cmmMakeDynamicReference, needImportedSymbols, diff --git a/ghc/compiler/nativeGen/RegisterAlloc.hs b/ghc/compiler/nativeGen/RegisterAlloc.hs index 2b3ed6e7a5..4f71fe1edb 100644 --- a/ghc/compiler/nativeGen/RegisterAlloc.hs +++ b/ghc/compiler/nativeGen/RegisterAlloc.hs @@ -85,7 +85,6 @@ module RegisterAlloc ( ) where #include "HsVersions.h" -#include "../includes/ghcconfig.h" import PprMach import MachRegs diff --git a/ghc/compiler/typecheck/TcForeign.lhs b/ghc/compiler/typecheck/TcForeign.lhs index 840da46ebb..04cff32ecd 100644 --- a/ghc/compiler/typecheck/TcForeign.lhs +++ b/ghc/compiler/typecheck/TcForeign.lhs @@ -17,7 +17,6 @@ module TcForeign , tcForeignExports ) where -#include "../includes/ghcconfig.h" #include "HsVersions.h" import HsSyn diff --git a/ghc/compiler/utils/Panic.lhs b/ghc/compiler/utils/Panic.lhs index 89976d3dae..6251d1baf4 100644 --- a/ghc/compiler/utils/Panic.lhs +++ b/ghc/compiler/utils/Panic.lhs @@ -21,7 +21,6 @@ module Panic ) where #include "HsVersions.h" -#include "../includes/ghcconfig.h" import Config import FastTypes diff --git a/ghc/compiler/utils/Util.lhs b/ghc/compiler/utils/Util.lhs index a23b2d748c..11d1b5e545 100644 --- a/ghc/compiler/utils/Util.lhs +++ b/ghc/compiler/utils/Util.lhs @@ -53,7 +53,6 @@ module Util ( readRational, ) where -#include "../includes/ghcconfig.h" #include "HsVersions.h" import Panic ( panic, trace ) diff --git a/ghc/docs/comm/rts-libs/coding-style.html b/ghc/docs/comm/rts-libs/coding-style.html index 39165917e6..58f5b4f9bb 100644 --- a/ghc/docs/comm/rts-libs/coding-style.html +++ b/ghc/docs/comm/rts-libs/coding-style.html @@ -160,7 +160,7 @@ co above). Avoid conditional code like this: <pre> - #ifdef solaris_HOST_OS + #ifdef solaris_host_OS // do something solaris specific #endif </pre> diff --git a/ghc/docs/comm/the-beast/coding-style.html b/ghc/docs/comm/the-beast/coding-style.html index 20aab896c1..41347c6902 100644 --- a/ghc/docs/comm/the-beast/coding-style.html +++ b/ghc/docs/comm/the-beast/coding-style.html @@ -70,17 +70,55 @@ </dl> - <p>More about what you're allowed to do in the way of CPP - directives later. + <h2>Platform tests</h2> + + <p>There are three platforms of interest to GHC: + + <ul> + <li>The <b>Build</b> platform. This is the platform on which we + are building GHC.</li> + <li>The <b>Host</b> platform. This is the platform on which we + are going to run this GHC binary, and associated tools.</li> + <li>The <b>Target</b> platform. This is the platform for which + this GHC binary will generate code.</li> + </ul> + + <p>At the moment, there is very limited support for having + different values for buil, host, and target. In particular:</p> + + <ul> + <li>The build platform is currently always the same as the host + platform. The build process needs to use some of the tools in + the source tree, for example <tt>ghc-pkg</tt> and + <tt>hsc2hs</tt>.</li> + + <li>If the target platform differs from the host platform, then + this is generally for the purpose of building <tt>.hc</tt> files + from Haskell source for porting GHC to the target platform. + Full cross-compilation isn't supported (yet).</li> + </ul> + + <p>In the compiler's source code, you may make use of the + following CPP symbols:</p> + + <ul> + <li><em>xxx</em><tt>_TARGET_ARCH</tt></li> + <li><em>xxx</em><tt>_TARGET_VENDOR</tt></li> + <li><em>xxx</em><tt>_TARGET_OS</tt></li> + <li><em>xxx</em><tt>_HOST_ARCH</tt></li> + <li><em>xxx</em><tt>_HOST_VENDOR</tt></li> + <li><em>xxx</em><tt>_HOST_OS</tt></li> + </ul> + + <p>where <em>xxx</em> is the appropriate value: + eg. <tt>i386_TARGET_ARCH</tt>. <h2>Compiler versions</h2> - <p>GHC must be compilable by every major version of GHC from 4.08 + <p>GHC must be compilable by every major version of GHC from 5.02 onwards, and itself. It isn't necessary for it to be compilable by every intermediate development version (that includes last - week's CVS sources), but we mustn't lose compatibility with 4.08 - for the time being, because that's the only version which can be - easily bootstrapped from .hc files. + week's CVS sources). <p>To maintain compatibility, use <tt>HsVersions.h</tt> (see below) where possible, and try to avoid using <tt>#ifdef</tt> in diff --git a/ghc/docs/users_guide/phases.xml b/ghc/docs/users_guide/phases.xml index 62d7b9ed9d..cd687a7f90 100644 --- a/ghc/docs/users_guide/phases.xml +++ b/ghc/docs/users_guide/phases.xml @@ -387,7 +387,7 @@ $ cat foo.hspp</screen> <varlistentry> <term> - <constant><replaceable>os</replaceable>_TARGET_OS=1</constant> + <constant><replaceable>os</replaceable>_OS=1</constant> </term> <listitem> <para>This define allows conditional compilation based on @@ -400,7 +400,7 @@ $ cat foo.hspp</screen> <varlistentry> <term> - <constant><replaceable>arch</replaceable>_TARGET_ARCH=1</constant> + <constant><replaceable>arch</replaceable>_ARCH=1</constant> </term> <listitem> <para>This define allows conditional compilation based on diff --git a/ghc/includes/MachRegs.h b/ghc/includes/MachRegs.h index 83a633ba4d..317e72a0cc 100644 --- a/ghc/includes/MachRegs.h +++ b/ghc/includes/MachRegs.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: MachRegs.h,v 1.20 2005/01/19 18:31:07 wolfgang Exp $ + * $Id: MachRegs.h,v 1.21 2005/01/28 12:55:51 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -27,6 +27,36 @@ */ #ifndef NO_REGS +/* NOTE: when testing the platform in this file we must test either + * *_HOST_ARCH and *_TARGET_ARCH, depending on whether COMPILING_GHC + * is set. This is because when we're compiling the RTS and HC code, + * the platform we're running on is the HOST, but when compiling GHC + * we want to know about the register mapping on the TARGET platform. + */ +#ifdef COMPILING_GHC +#define alpha_REGS alpha_TARGET_ARCH +#define hppa1_1_REGS hppa1_1_TARGET_ARCH +#define i386_REGS i386_TARGET_ARCH +#define x86_64_REGS x86_64_TARGET_ARCH +#define m68k_REGS m68k_TARGET_ARCH +#define mips_REGS (mipsel_TARGET_ARCH || mipseb_TARGET_ARCH) +#define powerpc_REGS (powerpc_TARGET_ARCH || powerpc64_TARGET_ARCH || rs6000_TARGET_ARCH) +#define ia64_REGS ia64_TARGET_ARCH +#define sparc_REGS sparc_TARGET_ARCH +#define darwin_REGS darwin_TARGET_OS +#else +#define alpha_REGS alpha_HOST_ARCH +#define hppa1_1_REGS hppa1_1_HOST_ARCH +#define i386_REGS i386_HOST_ARCH +#define x86_64_REGS x86_64_HOST_ARCH +#define m68k_REGS m68k_HOST_ARCH +#define mips_REGS (mipsel_HOST_ARCH || mipseb_HOST_ARCH) +#define powerpc_REGS (powerpc_HOST_ARCH || powerpc64_HOST_ARCH || rs6000_HOST_ARCH) +#define ia64_REGS ia64_HOST_ARCH +#define sparc_REGS sparc_HOST_ARCH +#define darwin_REGS darwin_HOST_OS +#endif + /* ---------------------------------------------------------------------------- Caller saves and callee-saves regs. @@ -82,7 +112,7 @@ t12 $27 NCG_reserved -------------------------------------------------------------------------- */ -#if defined(alpha_TARGET_ARCH) +#if alpha_REGS # define REG(x) __asm__("$" #x) # define CALLER_SAVES_R2 @@ -123,7 +153,7 @@ # define NCG_Reserved_F1 f29 # define NCG_Reserved_F2 f30 -#endif /* alpha_TARGET_ARCH */ +#endif /* alpha_REGS */ /* ----------------------------------------------------------------------------- The HP-PA register mapping @@ -146,7 +176,7 @@ \tr{%fr8}--\tr{%fr11} are some available caller-save fl-pt registers. -------------------------------------------------------------------------- */ -#if hppa1_1_TARGET_ARCH +#if hppa1_1_REGS #define REG(x) __asm__("%" #x) @@ -201,7 +231,7 @@ -------------------------------------------------------------------------- */ -#if i386_TARGET_ARCH +#if i386_REGS #define REG(x) __asm__("%" #x) @@ -251,7 +281,7 @@ %r15 YES --------------------------------------------------------------------------- */ -#if x86_64_TARGET_ARCH +#if x86_64_REGS #define REG(x) __asm__("%" #x) @@ -302,7 +332,7 @@ \end{tabular} -------------------------------------------------------------------------- */ -#if m68k_TARGET_ARCH +#if m68k_REGS #define REG(x) __asm__(#x) @@ -344,7 +374,7 @@ We can steal some, but we might have to save/restore around ccalls. -------------------------------------------------------------------------- */ -#if mipsel_TARGET_ARCH || mipseb_TARGET_ARCH +#if mips_REGS #define REG(x) __asm__("$" #x) @@ -414,7 +444,7 @@ We can do the Whole Business with callee-save registers only! -------------------------------------------------------------------------- */ -#if powerpc_TARGET_ARCH || powerpc64_TARGET_ARCH || rs6000_TARGET_ARCH +#if powerpc_REGS #define REG(x) __asm__(#x) @@ -427,7 +457,7 @@ #define REG_R7 r20 #define REG_R8 r21 -#ifdef darwin_TARGET_OS +#ifdef darwin_REGS #define REG_F1 f14 #define REG_F2 f15 @@ -471,7 +501,7 @@ \tr{f16-f32} are the callee-saved floating point registers. -------------------------------------------------------------------------- */ -#ifdef ia64_TARGET_ARCH +#if ia64_REGS #define REG(x) __asm__(#x) @@ -556,7 +586,7 @@ -------------------------------------------------------------------------- */ -#if sparc_TARGET_ARCH +#if sparc_REGS #define REG(x) __asm__("%" #x) diff --git a/ghc/includes/Makefile b/ghc/includes/Makefile index b32efa2ffe..df185230e3 100644 --- a/ghc/includes/Makefile +++ b/ghc/includes/Makefile @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# $Id: Makefile,v 1.25 2004/10/08 10:16:14 ross Exp $ +# $Id: Makefile,v 1.26 2005/01/28 12:55:51 simonmar Exp $ # TOP = .. @@ -20,11 +20,12 @@ endif # # Header file built from the configure script's findings # -H_CONFIG = ghcconfig.h +H_CONFIG = ghcautoconf.h +H_PLATFORM = ghcplatform.h boot :: gmp.h -all :: $(H_CONFIG) +all :: $(H_CONFIG) $(H_PLATFORM) # gmp.h is copied from the GMP directory gmp.h : $(FPTOOLS_TOP)/ghc/rts/gmp/gmp.h @@ -37,45 +38,56 @@ gmp.h : $(FPTOOLS_TOP)/ghc/rts/gmp/gmp.h $(H_CONFIG) : $(FPTOOLS_TOP)/mk/config.h $(FPTOOLS_TOP)/mk/config.mk -$(H_CONFIG) : +$(H_CONFIG) : Makefile + @echo "#ifndef __GHCAUTOCONF_H__" >$@ + @echo "#define __GHCAUTOCONF_H__" >>$@ +# Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'. + @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@ + @echo "#endif /* __GHCAUTOCONF_H__ */" >> $@ + @echo "Done." + +$(H_PLATFORM) : Makefile @echo "Creating $@..." @$(RM) $@ - @echo "#ifndef __GHCCONFIG_H__" >$@ - @echo "#define __GHCCONFIG_H__" >>$@ + @echo "#ifndef __GHCPLATFORM_H__" >$@ + @echo "#define __GHCPLATFORM_H__" >>$@ @echo >> $@ - @echo "#define HostPlatform_TYPE $(HostPlatform_CPP)" >> $@ - @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@ - @echo "#define BuildPlatform_TYPE $(BuildPlatform_CPP)" >> $@ + @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@ + @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@ @echo >> $@ - @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@ - @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@ - @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@ + @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@ + @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@ @echo >> $@ - @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@ - @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@ - @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@ - @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@ - @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@ - @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@ + @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@ + @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@ + @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@ + @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@ @echo >> $@ - @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@ - @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@ - @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@ - @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@ - @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@ - @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@ + @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@ + @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@ + @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@ + @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@ ifeq "$(HostOS_CPP)" "irix" - @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@ - @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@ - @echo "#endif " >> $@ + @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@ + @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@ + @echo "#endif" >> $@ endif @echo >> $@ - @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@ + @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@ + @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@ + @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@ + @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@ + @echo >> $@ + @echo "/* These TARGET macros are for backwards compatibily... DO NOT USE! */" >> $@ + @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@ + @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@ + @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@ + @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@ + @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@ + @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@ @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@ - @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@ -# Turn '#define PACKAGE_FOO "blah"' into '/* #undef PACKAGE_FOO */'. - @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$,\1/* #undef \2 */,' $(FPTOOLS_TOP)/mk/config.h >> $@ - @echo "#endif /* __GHCCONFIG_H__ */" >> $@ + @echo >> $@ + @echo "#endif /* __GHCPLATFORM_H__ */" >> $@ @echo "Done." # --------------------------------------------------------------------------- diff --git a/ghc/includes/Rts.h b/ghc/includes/Rts.h index 59c90c21b8..45bf815e83 100644 --- a/ghc/includes/Rts.h +++ b/ghc/includes/Rts.h @@ -34,7 +34,7 @@ extern "C" { #endif /* Fix for mingw stat problem (done here so it's early enough) */ -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS #define __MSVCRT__ 1 #endif diff --git a/ghc/includes/RtsConfig.h b/ghc/includes/RtsConfig.h index 6529c4b9e8..8c24208e76 100644 --- a/ghc/includes/RtsConfig.h +++ b/ghc/includes/RtsConfig.h @@ -54,7 +54,7 @@ * * UNDEFINING THIS WON'T WORK ON ITS OWN. You have been warned. */ -#if !defined(USE_MINIINTERPRETER) && !defined(ia64_TARGET_ARCH) && !defined (powerpc64_TARGET_ARCH) +#if !defined(USE_MINIINTERPRETER) && !defined(ia64_HOST_ARCH) && !defined (powerpc64_HOST_ARCH) #define TABLES_NEXT_TO_CODE #endif diff --git a/ghc/includes/SMP.h b/ghc/includes/SMP.h index 319f510220..a1f14e48c9 100644 --- a/ghc/includes/SMP.h +++ b/ghc/includes/SMP.h @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- - * $Id: SMP.h,v 1.4 2002/02/04 20:10:47 sof Exp $ + * $Id: SMP.h,v 1.5 2005/01/28 12:55:52 simonmar Exp $ * * (c) The GHC Team, 1999 * @@ -31,7 +31,7 @@ * (because another thread is altering it in parallel), we just jump * to the new entry point. */ -#if defined(i386_TARGET_ARCH) && defined(TABLES_NEXT_TO_CODE) +#if defined(i386_HOST_ARCH) && defined(TABLES_NEXT_TO_CODE) #define CMPXCHG(p, cmp, new) \ __asm__ __volatile__ ( \ "lock ; cmpxchg %1, %0\n" \ diff --git a/ghc/includes/Signals.h b/ghc/includes/Signals.h index f977ae8d62..bd24e5ae1e 100644 --- a/ghc/includes/Signals.h +++ b/ghc/includes/Signals.h @@ -15,7 +15,7 @@ #define STG_SIG_HAN (-4) #define STG_SIG_RST (-5) -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) extern int stg_InstallConsoleEvent(int action, StgStablePtr *handler); #else extern int stg_sig_install (int, int, StgStablePtr *, void *); diff --git a/ghc/includes/Stg.h b/ghc/includes/Stg.h index dcc66d8c70..1189b0e99b 100644 --- a/ghc/includes/Stg.h +++ b/ghc/includes/Stg.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Stg.h,v 1.65 2005/01/13 16:07:33 simonmar Exp $ + * $Id: Stg.h,v 1.66 2005/01/28 12:55:52 simonmar Exp $ * * (c) The GHC Team, 1998-2004 * @@ -195,7 +195,7 @@ INLINE_HEADER StgDouble PK_DBL (W_ p_src[]) { return *(StgDou * independently - unfortunately this code isn't writable in C, we * have to use inline assembler. */ -#if sparc_TARGET_ARCH +#if sparc_HOST_ARCH #define ASSIGN_DBL(dst0,src) \ { StgPtr dst = (StgPtr)(dst0); \ @@ -210,7 +210,7 @@ INLINE_HEADER StgDouble PK_DBL (W_ p_src[]) { return *(StgDou "m" (((P_)(src))[0]), "m" (((P_)(src))[1])); d; \ } ) -#else /* ! sparc_TARGET_ARCH */ +#else /* ! sparc_HOST_ARCH */ INLINE_HEADER void ASSIGN_DBL (W_ [], StgDouble); INLINE_HEADER StgDouble PK_DBL (W_ []); @@ -249,7 +249,7 @@ INLINE_HEADER StgDouble PK_DBL(W_ p_src[]) return(y.d); } -#endif /* ! sparc_TARGET_ARCH */ +#endif /* ! sparc_HOST_ARCH */ #endif /* ALIGNMENT_DOUBLE > ALIGNMENT_UNSIGNED_INT */ diff --git a/ghc/includes/StgMiscClosures.h b/ghc/includes/StgMiscClosures.h index 0eed70cc04..45ae06b3a6 100644 --- a/ghc/includes/StgMiscClosures.h +++ b/ghc/includes/StgMiscClosures.h @@ -461,7 +461,7 @@ RTS_FUN(stg_block_takemvar); RTS_ENTRY(stg_block_takemvar_ret); RTS_FUN(stg_block_putmvar); RTS_ENTRY(stg_block_putmvar_ret); -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS RTS_FUN(stg_block_async); RTS_FUN(stg_block_async_void); #endif @@ -537,7 +537,7 @@ RTS_FUN(tryPutMVarzh_fast); RTS_FUN(waitReadzh_fast); RTS_FUN(waitWritezh_fast); RTS_FUN(delayzh_fast); -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS RTS_FUN(asyncReadzh_fast); RTS_FUN(asyncWritezh_fast); RTS_FUN(asyncDoProczh_fast); diff --git a/ghc/includes/TSO.h b/ghc/includes/TSO.h index f68bf802c3..a0446b0417 100644 --- a/ghc/includes/TSO.h +++ b/ghc/includes/TSO.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: TSO.h,v 1.39 2004/11/18 09:56:22 tharris Exp $ + * $Id: TSO.h,v 1.40 2005/01/28 12:55:53 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -85,7 +85,7 @@ typedef StgWord32 StgThreadID; */ typedef unsigned int StgThreadReturnCode; -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) /* results from an async I/O request + it's ID. */ typedef struct { unsigned int reqID; @@ -98,7 +98,7 @@ typedef union { StgClosure *closure; struct StgTSO_ *tso; StgInt fd; // StgInt instead of int, so that it's the same size as the ptrs -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) StgAsyncIOResult* async_result; #endif StgWord target; diff --git a/ghc/includes/TailCalls.h b/ghc/includes/TailCalls.h index af248da1cd..13eea0e480 100644 --- a/ghc/includes/TailCalls.h +++ b/ghc/includes/TailCalls.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: TailCalls.h,v 1.17 2004/11/21 22:25:24 desrt Exp $ + * $Id: TailCalls.h,v 1.18 2005/01/28 12:55:54 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -28,7 +28,7 @@ extern void __DISCARD__(void); Tail calling on x86 -------------------------------------------------------------------------- */ -#if i386_TARGET_ARCH +#if i386_HOST_ARCH /* Note about discard: possibly there to fool GCC into clearing up before we do the jump eg. if there are some arguments left on the C @@ -57,13 +57,13 @@ extern void __DISCARD__(void); goto *__target; \ } -#endif /* i386_TARGET_ARCH */ +#endif /* i386_HOST_ARCH */ /* ----------------------------------------------------------------------------- Tail calling on x86_64 -------------------------------------------------------------------------- */ -#if x86_64_TARGET_ARCH +#if x86_64_HOST_ARCH #define JMP_(cont) \ { \ @@ -72,13 +72,13 @@ extern void __DISCARD__(void); goto *__target; \ } -#endif /* x86_64_TARGET_ARCH */ +#endif /* x86_64_HOST_ARCH */ /* ----------------------------------------------------------------------------- Tail calling on Sparc -------------------------------------------------------------------------- */ -#ifdef sparc_TARGET_ARCH +#ifdef sparc_HOST_ARCH #define JMP_(cont) ((F_) (cont))() /* Oh so happily, the above turns into a "call" instruction, @@ -90,13 +90,13 @@ extern void __DISCARD__(void); #define FB_ #define FE_ -#endif /* sparc_TARGET_ARCH */ +#endif /* sparc_HOST_ARCH */ /* ----------------------------------------------------------------------------- Tail calling on Alpha -------------------------------------------------------------------------- */ -#ifdef alpha_TARGET_ARCH +#ifdef alpha_HOST_ARCH #if IN_STG_CODE register void *_procedure __asm__("$27"); @@ -112,7 +112,7 @@ register void *_procedure __asm__("$27"); #define FB_ #define FE_ -#endif /* alpha_TARGET_ARCH */ +#endif /* alpha_HOST_ARCH */ /* ----------------------------------------------------------------------------- Tail calling on HP @@ -173,7 +173,7 @@ but uses $$dyncall if necessary to cope, just in case you aren't. Tail calling on PowerPC -------------------------------------------------------------------------- */ -#ifdef powerpc_TARGET_ARCH +#ifdef powerpc_HOST_ARCH #define JMP_(cont) \ { \ @@ -201,9 +201,9 @@ but uses $$dyncall if necessary to cope, just in case you aren't. #define JMP_(cont) ((F_) (cont))() */ -#endif /* powerpc_TARGET_ARCH */ +#endif /* powerpc_HOST_ARCH */ -#ifdef powerpc64_TARGET_ARCH +#ifdef powerpc64_HOST_ARCH #define JMP_(cont) ((F_) (cont))() #endif @@ -211,7 +211,7 @@ but uses $$dyncall if necessary to cope, just in case you aren't. Tail calling on IA64 -------------------------------------------------------------------------- */ -#ifdef ia64_TARGET_ARCH +#ifdef ia64_HOST_ARCH /* The compiler can more intelligently decide how to do this. We therefore * implement it as a call and optimise to a jump at mangle time. */ diff --git a/ghc/includes/mkDerivedConstants.c b/ghc/includes/mkDerivedConstants.c index 04993318f2..fbf236b8dd 100644 --- a/ghc/includes/mkDerivedConstants.c +++ b/ghc/includes/mkDerivedConstants.c @@ -375,7 +375,7 @@ main(int argc, char *argv[]) struct_field(snEntry,sn_obj); struct_field(snEntry,addr); -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS struct_size(StgAsyncIOResult); struct_field(StgAsyncIOResult, reqID); struct_field(StgAsyncIOResult, len); diff --git a/ghc/lib/compat/Compat/Directory.hs b/ghc/lib/compat/Compat/Directory.hs index a1e540a54b..ecd5a99685 100644 --- a/ghc/lib/compat/Compat/Directory.hs +++ b/ghc/lib/compat/Compat/Directory.hs @@ -21,9 +21,7 @@ module Compat.Directory ( createDirectoryIfMissing ) where -#if __GLASGOW_HASKELL__ < 603 -#include "config.h" -#endif +#include "../../includes/ghcconfig.h" import System.Environment (getEnv) import System.Directory.Internals @@ -37,7 +35,7 @@ import GHC.IOBase ( IOException(..) ) #else import System.IO ( try ) #endif -#if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS) +#if __GLASGOW_HASKELL__ && defined(mingw32_HOST_OS) import Foreign.Ptr import Foreign.C #endif @@ -45,7 +43,7 @@ import System.Directory(doesFileExist, doesDirectoryExist, getPermissions, setPe getAppUserDataDirectory :: String -> IO FilePath getAppUserDataDirectory appName = do -#if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS) +#if __GLASGOW_HASKELL__ && defined(mingw32_HOST_OS) allocaBytes long_path_size $ \pPath -> do r <- c_SHGetFolderPath nullPtr csidl_APPDATA nullPtr 0 pPath s <- peekCString pPath @@ -55,7 +53,7 @@ getAppUserDataDirectory appName = do return (path++'/':'.':appName) #endif -#if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS) +#if __GLASGOW_HASKELL__ && defined(mingw32_HOST_OS) foreign import stdcall unsafe "SHGetFolderPathA" c_SHGetFolderPath :: Ptr () -> CInt @@ -103,7 +101,7 @@ findExecutable binary = do path <- getEnv "PATH" search (parseSearchPath path) where -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS fileName = binary `joinFileExt` "exe" #else fileName = binary diff --git a/ghc/lib/compat/Compat/RawSystem.hs b/ghc/lib/compat/Compat/RawSystem.hs index 196201a8b2..f0f8aa3ac7 100644 --- a/ghc/lib/compat/Compat/RawSystem.hs +++ b/ghc/lib/compat/Compat/RawSystem.hs @@ -16,9 +16,7 @@ module Compat.RawSystem (rawSystem) where -#if __GLASGOW_HASKELL__ < 603 -#include "config.h" -#endif +#include "../../includes/ghcconfig.h" #if __GLASGOW_HASKELL__ >= 603 @@ -103,7 +101,7 @@ use lpCommandLine alone, which CreateProcess supports. ----------------------------------------------------------------------------- -} -#ifndef mingw32_TARGET_OS +#ifndef mingw32_HOST_OS rawSystem cmd args = withCString cmd $ \pcmd -> diff --git a/ghc/lib/compat/cbits/directory.c b/ghc/lib/compat/cbits/directory.c index af3810ca69..af09655965 100644 --- a/ghc/lib/compat/cbits/directory.c +++ b/ghc/lib/compat/cbits/directory.c @@ -1,8 +1,4 @@ -#if __GLASGOW_HASKELL__ < 603
-#include "config.h"
-#else
-#include "ghcconfig.h"
-#endif
+#include "../../../includes/ghcconfig.h"
#include "HsFFI.h"
@@ -29,7 +25,7 @@ INLINE HsInt __compat_long_path_size() { return PATH_MAX; } INLINE HsInt __compat_long_path_size() { return 4096; }
#endif
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
/* Make sure we've got the reqd CSIDL_ constants in scope;
* w32api header files are lagging a bit in defining the full set.
diff --git a/ghc/lib/compat/cbits/rawSystem.c b/ghc/lib/compat/cbits/rawSystem.c index 7af774790f..00b8c49cc1 100644 --- a/ghc/lib/compat/cbits/rawSystem.c +++ b/ghc/lib/compat/cbits/rawSystem.c @@ -12,16 +12,7 @@ /* The itimer stuff in this module is non-posix */ /* #include "PosixSource.h" */ -/* This ifdef is required because this source might be compiled by an - * external compiler. See ghc/utils/runghc/rawSystem.c for example. - */ -#ifdef __GLASGOW_HASKELL__ -#if __GLASGOW_HASKELL__ < 603 -#include "config.h" -#else -#include "ghcconfig.h" -#endif -#endif +#include "../../../includes/ghcconfig.h" #include <stdio.h> #include <stdlib.h> @@ -49,7 +40,7 @@ #include "HsFFI.h" -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) #include <windows.h> #endif @@ -61,7 +52,7 @@ #define fork vfork #endif -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) /* -------------------- WINDOWS VERSION --------------------- */ HsInt diff --git a/ghc/rts/Adjustor.c b/ghc/rts/Adjustor.c index 3d111b5d2e..59119bfd07 100644 --- a/ghc/rts/Adjustor.c +++ b/ghc/rts/Adjustor.c @@ -46,7 +46,7 @@ Haskell side. #include <windows.h> #endif -#if defined(openbsd_TARGET_OS) +#if defined(openbsd_HOST_OS) #include <unistd.h> #include <sys/types.h> #include <sys/mman.h> @@ -55,7 +55,7 @@ Haskell side. typedef unsigned long my_uintptr_t; #endif -#if defined(powerpc_TARGET_ARCH) && defined(linux_TARGET_OS) +#if defined(powerpc_HOST_ARCH) && defined(linux_HOST_OS) #include <string.h> #endif @@ -72,7 +72,7 @@ static void* mallocBytesRWX(int len) { void *addr = stgMallocBytes(len, "mallocBytesRWX"); -#if defined(i386_TARGET_ARCH) && defined(_WIN32) +#if defined(i386_HOST_ARCH) && defined(_WIN32) /* This could be necessary for processors which distinguish between READ and EXECUTE memory accesses, e.g. Itaniums. */ DWORD dwOldProtect = 0; @@ -80,7 +80,7 @@ mallocBytesRWX(int len) barf("mallocBytesRWX: failed to protect 0x%p; error=%lu; old protection: %lu\n", addr, (unsigned long)GetLastError(), (unsigned long)dwOldProtect); } -#elif defined(openbsd_TARGET_OS) +#elif defined(openbsd_HOST_OS) /* malloced memory isn't executable by default on OpenBSD */ my_uintptr_t pageSize = sysconf(_SC_PAGESIZE); my_uintptr_t mask = ~(pageSize - 1); @@ -94,20 +94,20 @@ mallocBytesRWX(int len) return addr; } -#if defined(i386_TARGET_ARCH) +#if defined(i386_HOST_ARCH) static unsigned char *obscure_ccall_ret_code; #endif -#if defined(alpha_TARGET_ARCH) +#if defined(alpha_HOST_ARCH) /* To get the definition of PAL_imb: */ -# if defined(linux_TARGET_OS) +# if defined(linux_HOST_OS) # include <asm/pal.h> # else # include <machine/pal.h> # endif #endif -#if defined(ia64_TARGET_ARCH) +#if defined(ia64_HOST_ARCH) #include "Storage.h" /* Layout of a function descriptor */ @@ -138,7 +138,7 @@ stgAllocStable(size_t size_in_bytes, StgStablePtr *stable) } #endif -#if defined(powerpc_TARGET_ARCH) && defined(linux_TARGET_OS) +#if defined(powerpc_HOST_ARCH) && defined(linux_HOST_OS) __asm__("obscure_ccall_ret_code:\n\t" "lwz 1,0(1)\n\t" "lwz 0,4(1)\n\t" @@ -147,8 +147,8 @@ __asm__("obscure_ccall_ret_code:\n\t" extern void obscure_ccall_ret_code(void); #endif -#if defined(powerpc_TARGET_ARCH) || defined(powerpc64_TARGET_ARCH) -#if !(defined(powerpc_TARGET_ARCH) && defined(linux_TARGET_OS)) +#if defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) +#if !(defined(powerpc_HOST_ARCH) && defined(linux_HOST_OS)) /* !!! !!! WARNING: !!! !!! * This structure is accessed from AdjustorAsm.s @@ -156,14 +156,14 @@ extern void obscure_ccall_ret_code(void); */ typedef struct AdjustorStub { -#if defined(powerpc_TARGET_ARCH) && defined(darwin_TARGET_OS) +#if defined(powerpc_HOST_ARCH) && defined(darwin_HOST_OS) unsigned lis; unsigned ori; unsigned lwz; unsigned mtctr; unsigned bctr; StgFunPtr code; -#elif defined(powerpc64_TARGET_ARCH) && defined(darwin_TARGET_OS) +#elif defined(powerpc64_HOST_ARCH) && defined(darwin_HOST_OS) /* powerpc64-darwin: just guessing that it won't use fundescs. */ unsigned lis; unsigned ori; @@ -195,7 +195,7 @@ void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr, char *typeString -#if !defined(powerpc_TARGET_ARCH) && !defined(powerpc64_TARGET_ARCH) +#if !defined(powerpc_HOST_ARCH) && !defined(powerpc64_HOST_ARCH) STG_UNUSED #endif ) @@ -205,7 +205,7 @@ createAdjustor(int cconv, StgStablePtr hptr, switch (cconv) { case 0: /* _stdcall */ -#if defined(i386_TARGET_ARCH) +#if defined(i386_HOST_ARCH) /* Magic constant computed by inspecting the code length of the following assembly language snippet (offset and machine code prefixed): @@ -238,7 +238,7 @@ createAdjustor(int cconv, StgStablePtr hptr, break; case 1: /* _ccall */ -#if defined(i386_TARGET_ARCH) +#if defined(i386_HOST_ARCH) /* Magic constant computed by inspecting the code length of the following assembly language snippet (offset and machine code prefixed): @@ -279,7 +279,7 @@ createAdjustor(int cconv, StgStablePtr hptr, adj_code[0x0f] = (unsigned char)0xff; /* jmp *%eax */ adj_code[0x10] = (unsigned char)0xe0; } -#elif defined(sparc_TARGET_ARCH) +#elif defined(sparc_HOST_ARCH) /* Magic constant computed by inspecting the code length of the following assembly language snippet (offset and machine code prefixed): @@ -344,7 +344,7 @@ createAdjustor(int cconv, StgStablePtr hptr, asm("nop"); asm("nop"); } -#elif defined(alpha_TARGET_ARCH) +#elif defined(alpha_HOST_ARCH) /* Magic constant computed by inspecting the code length of the following assembly language snippet (offset and machine code prefixed; note that the machine code @@ -367,7 +367,7 @@ createAdjustor(int cconv, StgStablePtr hptr, divided by 4, taking the lowest 14 bits. We only support passing 4 or fewer argument words, for the same - reason described under sparc_TARGET_ARCH above by JRS, 21 Aug 01. + reason described under sparc_HOST_ARCH above by JRS, 21 Aug 01. On the Alpha the first 6 integer arguments are in a0 through a5, and the rest on the stack. Hence we want to shuffle the original caller's arguments by two. @@ -402,7 +402,7 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for /* Ensure that instruction cache is consistent with our new code */ __asm__ volatile("call_pal %0" : : "i" (PAL_imb)); } -#elif defined(powerpc_TARGET_ARCH) && defined(linux_TARGET_OS) +#elif defined(powerpc_HOST_ARCH) && defined(linux_HOST_OS) #define OP_LO(op,lo) ((((unsigned)(op)) << 16) | (((unsigned)(lo)) & 0xFFFF)) #define OP_HI(op,hi) ((((unsigned)(op)) << 16) | (((unsigned)(hi)) >> 16)) @@ -611,7 +611,7 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for } } -#elif defined(powerpc_TARGET_ARCH) || defined(powerpc64_TARGET_ARCH) +#elif defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) #define OP_LO(op,lo) ((((unsigned)(op)) << 16) | (((unsigned)(lo)) & 0xFFFF)) #define OP_HI(op,hi) ((((unsigned)(op)) << 16) | (((unsigned)(hi)) >> 16)) @@ -664,7 +664,7 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for // no function descriptors :-( // We need to do things "by hand". -#if defined(powerpc_TARGET_ARCH) +#if defined(powerpc_HOST_ARCH) // lis r2, hi(adjustorStub) adjustorStub->lis = OP_HI(0x3c40, adjustorStub); // ori r2, r2, lo(adjustorStub) @@ -701,7 +701,7 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for switch(t) { -#if defined(powerpc_TARGET_ARCH) +#if defined(powerpc_HOST_ARCH) // on 32-bit platforms, Double and Int64 occupy two words. case 'd': case 'l': @@ -739,7 +739,7 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for adjustorStub->extrawords_plus_one = extra_sz + 1; } -#elif defined(ia64_TARGET_ARCH) +#elif defined(ia64_HOST_ARCH) /* Up to 8 inputs are passed in registers. We flush the last two inputs to the stack, initially into the 16-byte scratch region left by the caller. @@ -836,7 +836,7 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for void freeHaskellFunctionPtr(void* ptr) { -#if defined(i386_TARGET_ARCH) +#if defined(i386_HOST_ARCH) if ( *(unsigned char*)ptr != 0x68 && *(unsigned char*)ptr != 0x58 ) { errorBelch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr); @@ -849,7 +849,7 @@ freeHaskellFunctionPtr(void* ptr) } else { freeStablePtr(*((StgStablePtr*)((unsigned char*)ptr + 0x02))); } -#elif defined(sparc_TARGET_ARCH) +#elif defined(sparc_HOST_ARCH) if ( *(unsigned long*)ptr != 0x9C23A008UL ) { errorBelch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr); return; @@ -857,7 +857,7 @@ freeHaskellFunctionPtr(void* ptr) /* Free the stable pointer first..*/ freeStablePtr(*((StgStablePtr*)((unsigned long*)ptr + 11))); -#elif defined(alpha_TARGET_ARCH) +#elif defined(alpha_HOST_ARCH) if ( *(StgWord64*)ptr != 0xa77b0018a61b0010L ) { errorBelch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr); return; @@ -865,20 +865,20 @@ freeHaskellFunctionPtr(void* ptr) /* Free the stable pointer first..*/ freeStablePtr(*((StgStablePtr*)((unsigned char*)ptr + 0x10))); -#elif defined(powerpc_TARGET_ARCH) && defined(linux_TARGET_OS) +#elif defined(powerpc_HOST_ARCH) && defined(linux_HOST_OS) if ( *(StgWord*)ptr != 0x48000008 ) { errorBelch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr); return; } freeStablePtr(((StgStablePtr*)ptr)[1]); -#elif defined(powerpc_TARGET_ARCH) || defined(powerpc64_TARGET_ARCH) +#elif defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) extern void* adjustorCode; if ( ((AdjustorStub*)ptr)->code != (StgFunPtr) &adjustorCode ) { errorBelch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr); return; } freeStablePtr(((AdjustorStub*)ptr)->hptr); -#elif defined(ia64_TARGET_ARCH) +#elif defined(ia64_HOST_ARCH) IA64FunDesc *fdesc = (IA64FunDesc *)ptr; StgWord64 *code = (StgWord64 *)(fdesc+1); @@ -906,7 +906,7 @@ freeHaskellFunctionPtr(void* ptr) void initAdjustor(void) { -#if defined(i386_TARGET_ARCH) +#if defined(i386_HOST_ARCH) /* Now here's something obscure for you: When generating an adjustor thunk that uses the C calling diff --git a/ghc/rts/AdjustorAsm.S b/ghc/rts/AdjustorAsm.S index fc56beb517..3927843830 100644 --- a/ghc/rts/AdjustorAsm.S +++ b/ghc/rts/AdjustorAsm.S @@ -1,7 +1,7 @@ #include "../includes/ghcconfig.h" -#if defined(powerpc_TARGET_ARCH) || defined(powerpc64_TARGET_ARCH) -#if !(defined(powerpc_TARGET_ARCH) && defined(linux_TARGET_OS)) +#if defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) +#if !(defined(powerpc_HOST_ARCH) && defined(linux_HOST_OS)) /* The following code applies, with some differences, to all powerpc platforms except for powerpc32-linux, whose calling convention is annoyingly complex. @@ -11,7 +11,7 @@ /* The code is "almost" the same for 32-bit and for 64-bit */ -#if defined(powerpc64_TARGET_ARCH) +#if defined(powerpc64_HOST_ARCH) #define WS 8 #define LOAD ld #define STORE std @@ -28,9 +28,9 @@ /* The following defines mirror struct AdjustorStub from Adjustor.c. Make sure to keep these in sync. */ -#if defined(powerpc_TARGET_ARCH) && defined(darwin_TARGET_OS) +#if defined(powerpc_HOST_ARCH) && defined(darwin_HOST_OS) #define HEADER_WORDS 6 -#elif defined(powerpc64_TARGET_ARCH) && defined(darwin_TARGET_OS) +#elif defined(powerpc64_HOST_ARCH) && defined(darwin_HOST_OS) #else #define HEADER_WORDS 3 #endif @@ -42,7 +42,7 @@ /* Darwin insists on register names, everyone else prefers to use numbers. */ -#if !defined(darwin_TARGET_OS) +#if !defined(darwin_HOST_OS) #define r0 0 #define r1 1 #define r2 2 @@ -82,7 +82,7 @@ adjustorCode: /* set up stack frame */ LOAD r12, FRAMESIZE_OFF(r2) -#ifdef powerpc64_TARGET_ARCH +#ifdef powerpc64_HOST_ARCH stdux r1, r1, r12 #else stwux r1, r1, r12 @@ -125,7 +125,7 @@ adjustorCode: LOAD r3, HPTR_OFF(r2) LOAD r12, WPTR_OFF(r2) -#if defined(darwin_TARGET_OS) +#if defined(darwin_HOST_OS) mtctr r12 #else LOAD r0, 0(r12) diff --git a/ghc/rts/Exception.h b/ghc/rts/Exception.h index 083faaf230..890c5165ad 100644 --- a/ghc/rts/Exception.h +++ b/ghc/rts/Exception.h @@ -21,7 +21,7 @@ interruptible(StgTSO *t) case BlockedOnException: case BlockedOnRead: case BlockedOnWrite: -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) case BlockedOnDoProc: #endif case BlockedOnDelay: diff --git a/ghc/rts/HeapStackCheck.cmm b/ghc/rts/HeapStackCheck.cmm index a0322cbb3d..c41b9b5d1a 100644 --- a/ghc/rts/HeapStackCheck.cmm +++ b/ghc/rts/HeapStackCheck.cmm @@ -860,7 +860,7 @@ stg_block_putmvar BLOCK_GENERIC; } -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS INFO_TABLE_RET( stg_block_async, 0/*framesize*/, 0/*bitmap*/, RET_SMALL ) { W_ ares; diff --git a/ghc/rts/Linker.c b/ghc/rts/Linker.c index 3cd337fca9..09a30a4d72 100644 --- a/ghc/rts/Linker.c +++ b/ghc/rts/Linker.c @@ -42,7 +42,7 @@ #include <dlfcn.h> #endif -#if defined(cygwin32_TARGET_OS) +#if defined(cygwin32_HOST_OS) #ifdef HAVE_DIRENT_H #include <dirent.h> #endif @@ -58,12 +58,12 @@ #include <sys/wait.h> #endif -#if defined(ia64_TARGET_ARCH) || defined(openbsd_TARGET_OS) || defined(linux_TARGET_OS) +#if defined(ia64_HOST_ARCH) || defined(openbsd_HOST_OS) || defined(linux_HOST_OS) #define USE_MMAP #include <fcntl.h> #include <sys/mman.h> -#if defined(openbsd_TARGET_OS) || defined(linux_TARGET_OS) +#if defined(openbsd_HOST_OS) || defined(linux_HOST_OS) #ifdef HAVE_UNISTD_H #include <unistd.h> #endif @@ -71,13 +71,13 @@ #endif -#if defined(linux_TARGET_OS) || defined(solaris2_TARGET_OS) || defined(freebsd_TARGET_OS) || defined(netbsd_TARGET_OS) || defined(openbsd_TARGET_OS) +#if defined(linux_HOST_OS) || defined(solaris2_HOST_OS) || defined(freebsd_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS) # define OBJFORMAT_ELF -#elif defined(cygwin32_TARGET_OS) || defined (mingw32_TARGET_OS) +#elif defined(cygwin32_HOST_OS) || defined (mingw32_HOST_OS) # define OBJFORMAT_PEi386 # include <windows.h> # include <math.h> -#elif defined(darwin_TARGET_OS) +#elif defined(darwin_HOST_OS) # include <mach-o/ppc/reloc.h> # define OBJFORMAT_MACHO # include <mach-o/loader.h> @@ -96,7 +96,7 @@ ObjectCode *objects = NULL; /* initially empty */ static int ocVerifyImage_ELF ( ObjectCode* oc ); static int ocGetNames_ELF ( ObjectCode* oc ); static int ocResolve_ELF ( ObjectCode* oc ); -#if defined(powerpc_TARGET_ARCH) +#if defined(powerpc_HOST_ARCH) static int ocAllocateJumpIslands_ELF ( ObjectCode* oc ); #endif #elif defined(OBJFORMAT_PEi386) @@ -134,13 +134,13 @@ typedef struct _RtsSymbolVal { #define Maybe_Stable_Names #endif -#if !defined (mingw32_TARGET_OS) +#if !defined (mingw32_HOST_OS) #define RTS_POSIX_ONLY_SYMBOLS \ SymX(stg_sig_install) \ Sym(nocldstop) #endif -#if defined (cygwin32_TARGET_OS) +#if defined (cygwin32_HOST_OS) #define RTS_MINGW_ONLY_SYMBOLS /**/ /* Don't have the ability to read import libs / archives, so * we have to stupidly list a lot of what libcygwin.a @@ -224,10 +224,10 @@ typedef struct _RtsSymbolVal { SymX(utime) \ SymX(waitpid) -#elif !defined(mingw32_TARGET_OS) +#elif !defined(mingw32_HOST_OS) #define RTS_MINGW_ONLY_SYMBOLS /**/ #define RTS_CYGWIN_ONLY_SYMBOLS /**/ -#else /* defined(mingw32_TARGET_OS) */ +#else /* defined(mingw32_HOST_OS) */ #define RTS_POSIX_ONLY_SYMBOLS /**/ #define RTS_CYGWIN_ONLY_SYMBOLS /**/ @@ -602,7 +602,7 @@ typedef struct _RtsSymbolVal { Sym(__ashrdi3) \ Sym(__lshrdi3) \ Sym(__eprintf) -#elif defined(ia64_TARGET_ARCH) +#elif defined(ia64_HOST_ARCH) #define RTS_LIBGCC_SYMBOLS \ Sym(__divdi3) \ Sym(__udivdi3) \ @@ -614,7 +614,7 @@ typedef struct _RtsSymbolVal { #define RTS_LIBGCC_SYMBOLS #endif -#ifdef darwin_TARGET_OS +#ifdef darwin_HOST_OS // Symbols that don't have a leading underscore // on Mac OS X. They have to receive special treatment, // see machoInitSymbolsWithoutUnderscore() @@ -711,7 +711,7 @@ static void *dl_prog_handle; #endif /* dlopen(NULL,..) doesn't work so we grab libc explicitly */ -#if defined(openbsd_TARGET_OS) +#if defined(openbsd_HOST_OS) static void *dl_libc_handle; #endif @@ -743,7 +743,7 @@ initLinker( void ) dl_prog_handle = RTLD_DEFAULT; # else dl_prog_handle = dlopen(NULL, RTLD_LAZY); -# if defined(openbsd_TARGET_OS) +# if defined(openbsd_HOST_OS) dl_libc_handle = dlopen("libc.so", RTLD_LAZY); # endif # endif // RTLD_DEFAULT @@ -876,7 +876,7 @@ lookupSymbol( char *lbl ) if (val == NULL) { # if defined(OBJFORMAT_ELF) -# if defined(openbsd_TARGET_OS) +# if defined(openbsd_HOST_OS) val = dlsym(dl_prog_handle, lbl); return (val != NULL) ? val : dlsym(dl_libc_handle,lbl); # else /* not openbsd */ @@ -979,7 +979,7 @@ void ghci_enquire ( char* addr ) } #endif -#ifdef ia64_TARGET_ARCH +#ifdef ia64_HOST_ARCH static unsigned int PLTSize(void); #endif @@ -1062,7 +1062,7 @@ loadObj( char *path ) /* On many architectures malloc'd memory isn't executable, so we need to use mmap. */ -#if defined(openbsd_TARGET_OS) +#if defined(openbsd_HOST_OS) fd = open(path, O_RDONLY, S_IRUSR); #else fd = open(path, O_RDONLY); @@ -1072,7 +1072,7 @@ loadObj( char *path ) pagesize = getpagesize(); -#ifdef ia64_TARGET_ARCH +#ifdef ia64_HOST_ARCH /* The PLT needs to be right before the object */ n = ROUND_UP(PLTSize(), pagesize); oc->plt = mmap(NULL, n, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); @@ -1110,7 +1110,7 @@ loadObj( char *path ) # if defined(OBJFORMAT_MACHO) r = ocAllocateJumpIslands_MachO ( oc ); if (!r) { return r; } -# elif defined(OBJFORMAT_ELF) && defined(powerpc_TARGET_ARCH) +# elif defined(OBJFORMAT_ELF) && defined(powerpc_HOST_ARCH) r = ocAllocateJumpIslands_ELF ( oc ); if (!r) { return r; } #endif @@ -1284,7 +1284,7 @@ static void addSection ( ObjectCode* oc, SectionKind kind, * PowerPC specifics (jump islands) * ------------------------------------------------------------------------*/ -#if defined(powerpc_TARGET_ARCH) +#if defined(powerpc_HOST_ARCH) /* ocAllocateJumpIslands @@ -2188,14 +2188,14 @@ ocResolve_PEi386 ( ObjectCode* oc ) #define FALSE 0 #define TRUE 1 -#if defined(sparc_TARGET_ARCH) +#if defined(sparc_HOST_ARCH) # define ELF_TARGET_SPARC /* Used inside <elf.h> */ -#elif defined(i386_TARGET_ARCH) +#elif defined(i386_HOST_ARCH) # define ELF_TARGET_386 /* Used inside <elf.h> */ -#elif defined(x86_64_TARGET_ARCH) +#elif defined(x86_64_HOST_ARCH) # define ELF_TARGET_X64_64 # define ELF_64BIT -#elif defined (ia64_TARGET_ARCH) +#elif defined (ia64_HOST_ARCH) # define ELF_TARGET_IA64 /* Used inside <elf.h> */ # define ELF_64BIT # define ELF_FUNCTION_DESC /* calling convention uses function descriptors */ @@ -2203,7 +2203,7 @@ ocResolve_PEi386 ( ObjectCode* oc ) # define ELF_NEED_PLT /* needs Procedure Linkage Tables */ #endif -#if !defined(openbsd_TARGET_OS) +#if !defined(openbsd_HOST_OS) #include <elf.h> #else /* openbsd elf has things in different places, with diff names */ @@ -2325,7 +2325,7 @@ copyFunctionDesc(Elf_Addr target) #endif #ifdef ELF_NEED_PLT -#ifdef ia64_TARGET_ARCH +#ifdef ia64_HOST_ARCH static void ia64_reloc_gprel22(Elf_Addr target, Elf_Addr value); static void ia64_reloc_pcrel21(Elf_Addr target, Elf_Addr value, ObjectCode *oc); @@ -2406,7 +2406,7 @@ findElfSection ( void* objImage, Elf_Word sh_type ) return ptr; } -#if defined(ia64_TARGET_ARCH) +#if defined(ia64_HOST_ARCH) static Elf_Addr findElfSegment ( void* objImage, Elf_Addr vaddr ) { @@ -2852,7 +2852,7 @@ do_Elf_Rel_relocations ( ObjectCode* oc, char* ehdrC, value = S + A; switch (ELF_R_TYPE(info)) { -# ifdef i386_TARGET_ARCH +# ifdef i386_HOST_ARCH case R_386_32: *pP = value; break; case R_386_PC32: *pP = value - P; break; # endif @@ -2887,7 +2887,7 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC, target_shndx, symtab_shndx )); for (j = 0; j < nent; j++) { -#if defined(DEBUG) || defined(sparc_TARGET_ARCH) || defined(ia64_TARGET_ARCH) || defined(powerpc_TARGET_ARCH) +#if defined(DEBUG) || defined(sparc_HOST_ARCH) || defined(ia64_HOST_ARCH) || defined(powerpc_HOST_ARCH) /* This #ifdef only serves to avoid unused-var warnings. */ Elf_Addr offset = rtab[j].r_offset; Elf_Addr P = targ + offset; @@ -2897,13 +2897,13 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC, Elf_Addr S; void* S_tmp; Elf_Addr value; -# if defined(sparc_TARGET_ARCH) +# if defined(sparc_HOST_ARCH) Elf_Word* pP = (Elf_Word*)P; Elf_Word w1, w2; -# elif defined(ia64_TARGET_ARCH) +# elif defined(ia64_HOST_ARCH) Elf64_Xword *pP = (Elf64_Xword *)P; Elf_Addr addr; -# elif defined(powerpc_TARGET_ARCH) +# elif defined(powerpc_HOST_ARCH) Elf_Sword delta; # endif @@ -2957,7 +2957,7 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC, value = S + A; switch (ELF_R_TYPE(info)) { -# if defined(sparc_TARGET_ARCH) +# if defined(sparc_HOST_ARCH) case R_SPARC_WDISP30: w1 = *pP & 0xC0000000; w2 = (Elf_Word)((value - P) >> 2); @@ -2994,7 +2994,7 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC, w2 = (Elf_Word)value; *pP = w2; break; -# elif defined(ia64_TARGET_ARCH) +# elif defined(ia64_HOST_ARCH) case R_IA64_DIR64LSB: case R_IA64_FPTR64LSB: *pP = value; @@ -3022,7 +3022,7 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC, /* This goes with R_IA64_LTOFF22X and points to the load to * convert into a move. We don't implement relaxation. */ break; -# elif defined(powerpc_TARGET_ARCH) +# elif defined(powerpc_HOST_ARCH) case R_PPC_ADDR16_LO: *(Elf32_Half*) P = value; break; @@ -3113,7 +3113,7 @@ ocResolve_ELF ( ObjectCode* oc ) freeHashTable(oc->lochash, NULL); oc->lochash = NULL; -#if defined(powerpc_TARGET_ARCH) +#if defined(powerpc_HOST_ARCH) ocFlushInstructionCache( oc ); #endif @@ -3127,7 +3127,7 @@ ocResolve_ELF ( ObjectCode* oc ) * take care of the most common relocations. */ -#ifdef ia64_TARGET_ARCH +#ifdef ia64_HOST_ARCH static Elf64_Xword ia64_extract_instruction(Elf64_Xword *target) @@ -3216,7 +3216,7 @@ ia64_reloc_pcrel21(Elf_Addr target, Elf_Addr value, ObjectCode *oc) * PowerPC ELF specifics */ -#ifdef powerpc_TARGET_ARCH +#ifdef powerpc_HOST_ARCH static int ocAllocateJumpIslands_ELF( ObjectCode *oc ) { @@ -3829,7 +3829,7 @@ static int ocResolve_MachO(ObjectCode* oc) freeHashTable(oc->lochash, NULL); oc->lochash = NULL; -#if defined (powerpc_TARGET_ARCH) +#if defined (powerpc_HOST_ARCH) ocFlushInstructionCache( oc ); #endif diff --git a/ghc/rts/LinkerInternals.h b/ghc/rts/LinkerInternals.h index 2ce7fbc7b1..f1e2677851 100644 --- a/ghc/rts/LinkerInternals.h +++ b/ghc/rts/LinkerInternals.h @@ -39,7 +39,7 @@ typedef /* Jump Islands are sniplets of machine code required for relative * address relocations on the PowerPC. */ -#ifdef powerpc_TARGET_ARCH +#ifdef powerpc_HOST_ARCH typedef struct { short lis_r12, hi_addr; short ori_r12_r12, lo_addr; @@ -82,13 +82,13 @@ typedef struct _ObjectCode { outside one of these is an error in the linker. */ ProddableBlock* proddables; -#ifdef ia64_TARGET_ARCH +#ifdef ia64_HOST_ARCH /* Procedure Linkage Table for this object */ void *plt; unsigned int pltIndex; #endif -#ifdef powerpc_TARGET_ARCH +#ifdef powerpc_HOST_ARCH ppcJumpIsland *jump_islands; unsigned long island_start_symbol; unsigned long n_islands; diff --git a/ghc/rts/MBlock.c b/ghc/rts/MBlock.c index b97f67b12a..0ce1e762a9 100644 --- a/ghc/rts/MBlock.c +++ b/ghc/rts/MBlock.c @@ -29,7 +29,7 @@ #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#ifndef mingw32_TARGET_OS +#ifndef mingw32_HOST_OS # ifdef HAVE_SYS_MMAN_H # include <sys/mman.h> # endif @@ -40,7 +40,7 @@ #if HAVE_WINDOWS_H #include <windows.h> #endif -#if darwin_TARGET_OS +#if darwin_HOST_OS #include <mach/vm_map.h> #endif @@ -136,7 +136,7 @@ getMBlock(void) again using the general method. -------------------------------------------------------------------------- */ -#if !defined(mingw32_TARGET_OS) && !defined(cygwin32_TARGET_OS) +#if !defined(mingw32_HOST_OS) && !defined(cygwin32_HOST_OS) // A wrapper around mmap(), to abstract away from OS differences in // the mmap() interface. @@ -146,16 +146,16 @@ my_mmap (void *addr, lnat size) { void *ret; -#if defined(solaris2_TARGET_OS) || defined(irix_TARGET_OS) +#if defined(solaris2_HOST_OS) || defined(irix_HOST_OS) { int fd = open("/dev/zero",O_RDONLY); ret = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); close(fd); } -#elif hpux_TARGET_OS +#elif hpux_HOST_OS ret = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); -#elif darwin_TARGET_OS +#elif darwin_HOST_OS // Without MAP_FIXED, Apple's mmap ignores addr. // With MAP_FIXED, it overwrites already mapped regions, whic // mmap(0, ... MAP_FIXED ...) is worst of all: It unmaps the program text @@ -285,7 +285,7 @@ getMBlocks(nat n) return ret; } -#else /* defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS) */ +#else /* defined(mingw32_HOST_OS) || defined(cygwin32_HOST_OS) */ /* On Win32 platforms we make use of the two-phased virtual memory API diff --git a/ghc/rts/MBlock.h b/ghc/rts/MBlock.h index 8d2a9792be..07c40a05de 100644 --- a/ghc/rts/MBlock.h +++ b/ghc/rts/MBlock.h @@ -14,7 +14,7 @@ extern lnat RTS_VAR(mblocks_allocated); extern void * getMBlock(void); extern void * getMBlocks(nat n); -#if osf3_TARGET_OS +#if osf3_HOST_OS /* ToDo: Perhaps by adjusting this value we can make linking without * -static work (i.e., not generate a core-dumping executable)? */ #if SIZEOF_VOID_P == 8 diff --git a/ghc/rts/PrimOps.cmm b/ghc/rts/PrimOps.cmm index c647b48b0a..a7ba08ae71 100644 --- a/ghc/rts/PrimOps.cmm +++ b/ghc/rts/PrimOps.cmm @@ -1816,7 +1816,7 @@ waitWritezh_fast STRING(stg_delayzh_malloc_str, "delayzh_fast") delayzh_fast { -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS W_ ares; CInt reqID; #else @@ -1831,7 +1831,7 @@ delayzh_fast ASSERT(StgTSO_why_blocked(CurrentTSO) == NotBlocked::I16); StgTSO_why_blocked(CurrentTSO) = BlockedOnDelay::I16; -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS /* could probably allocate this on the heap instead */ "ptr" ares = foreign "C" stgMallocBytes(SIZEOF_StgAsyncIOResult, @@ -1878,7 +1878,7 @@ while: } -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS STRING(stg_asyncReadzh_malloc_str, "asyncReadzh_fast") asyncReadzh_fast { diff --git a/ghc/rts/RtsFlags.c b/ghc/rts/RtsFlags.c index 2f01d5e219..85c31db112 100644 --- a/ghc/rts/RtsFlags.c +++ b/ghc/rts/RtsFlags.c @@ -503,7 +503,7 @@ setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]) /* Remove directory from argv[0] -- default files in current directory */ if ((last_slash = (char *) strrchr(argv[0], -#if !defined(mingw32_TARGET_OS) +#if !defined(mingw32_HOST_OS) '/') #else '\\') diff --git a/ghc/rts/RtsStartup.c b/ghc/rts/RtsStartup.c index 69ae2272eb..c5fa744c83 100644 --- a/ghc/rts/RtsStartup.c +++ b/ghc/rts/RtsStartup.c @@ -49,7 +49,7 @@ # include "LLC.h" #endif -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) #include "win32/AsyncIO.h" #endif @@ -216,7 +216,7 @@ hs_init(int *argc, char **argv[]) initDefaultHandlers(); #endif -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) startupAsyncIO(); #endif @@ -439,7 +439,7 @@ hs_exit(void) if (RtsFlags.TickyFlags.showTickyStats) PrintTickyInfo(); #endif -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) shutdownAsyncIO(); #endif } diff --git a/ghc/rts/RtsUtils.c b/ghc/rts/RtsUtils.c index 09154da45a..ce1c0a2493 100644 --- a/ghc/rts/RtsUtils.c +++ b/ghc/rts/RtsUtils.c @@ -36,7 +36,7 @@ #include <signal.h> #endif -#if defined(THREADED_RTS) && defined(openbsd_TARGET_OS) && defined(HAVE_PTHREAD_H) +#if defined(THREADED_RTS) && defined(openbsd_HOST_OS) && defined(HAVE_PTHREAD_H) #include <pthread.h> #endif @@ -191,7 +191,7 @@ time_str(void) * clean up for us. * -------------------------------------------------------------------------- */ -#if !defined(mingw32_TARGET_OS) +#if !defined(mingw32_HOST_OS) void resetNonBlockingFd(int fd) { @@ -230,7 +230,7 @@ static ullong startTime = 0; ullong msTime(void) { -# if defined(HAVE_GETCLOCK) && !defined(alpha_TARGET_ARCH) && !defined(hppa1_1_TARGET_ARCH) +# if defined(HAVE_GETCLOCK) && !defined(alpha_HOST_ARCH) && !defined(hppa1_1_HOST_ARCH) struct timespec tv; if (getclock(TIMEOFDAY, &tv) != 0) { @@ -239,7 +239,7 @@ msTime(void) stg_exit(EXIT_FAILURE); } return tv.tv_sec * LL(1000) + tv.tv_nsec / LL(1000000) - startTime; -# elif HAVE_GETTIMEOFDAY && !defined(alpha_TARGET_ARCH) +# elif HAVE_GETTIMEOFDAY && !defined(alpha_HOST_ARCH) struct timeval tv; if (gettimeofday(&tv, NULL) != 0) { @@ -304,7 +304,7 @@ heapCheckFail( void ) * genericRaise(), rather than raise(3). */ int genericRaise(int sig) { -#if defined(THREADED_RTS) && (defined(openbsd_TARGET_OS) || defined(freebsd_TARGET_OS)) +#if defined(THREADED_RTS) && (defined(openbsd_HOST_OS) || defined(freebsd_HOST_OS)) return pthread_kill(pthread_self(), sig); #else return raise(sig); diff --git a/ghc/rts/Sanity.c b/ghc/rts/Sanity.c index 5941329965..f1d43bdad3 100644 --- a/ghc/rts/Sanity.c +++ b/ghc/rts/Sanity.c @@ -652,7 +652,7 @@ checkTSO(StgTSO *tso) case BlockedOnRead: case BlockedOnWrite: case BlockedOnDelay: -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) case BlockedOnDoProc: #endif /* isOnBQ(blocked_queue) */ diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index 76fec45737..ecd47aa41b 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -542,7 +542,7 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS, // ToDo: add deadlock detection in GUM (similar to SMP) -- HWL #endif -#if defined(RTS_SUPPORTS_THREADS) || defined(mingw32_TARGET_OS) +#if defined(RTS_SUPPORTS_THREADS) || defined(mingw32_HOST_OS) /* win32: might be back here due to awaitEvent() being abandoned * as a result of a console event having been delivered. */ @@ -1424,7 +1424,7 @@ isThreadBound(StgTSO* tso USED_IN_THREADED_RTS) * Singleton fork(). Do not copy any running threads. * ------------------------------------------------------------------------- */ -#ifndef mingw32_TARGET_OS +#ifndef mingw32_HOST_OS #define FORKPROCESS_PRIMOP_SUPPORTED #endif @@ -2762,7 +2762,7 @@ unblockThread(StgTSO *tso) case BlockedOnRead: case BlockedOnWrite: -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) case BlockedOnDoProc: #endif { @@ -2900,7 +2900,7 @@ unblockThread(StgTSO *tso) case BlockedOnRead: case BlockedOnWrite: -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) case BlockedOnDoProc: #endif { @@ -3430,7 +3430,7 @@ printThreadBlockage(StgTSO *tso) case BlockedOnWrite: debugBelch("is blocked on write to fd %d", tso->block_info.fd); break; -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) case BlockedOnDoProc: debugBelch("is blocked on proc (request: %d)", tso->block_info.async_result->reqID); break; diff --git a/ghc/rts/Signals.c b/ghc/rts/Signals.c index ac6d26674d..67fbf42ab4 100644 --- a/ghc/rts/Signals.c +++ b/ghc/rts/Signals.c @@ -16,8 +16,8 @@ #include "RtsUtils.h" #include "RtsFlags.h" -#ifdef alpha_TARGET_ARCH -# if defined(linux_TARGET_OS) +#ifdef alpha_HOST_ARCH +# if defined(linux_HOST_OS) # include <asm/fpu.h> # else # include <machine/fpu.h> @@ -472,7 +472,7 @@ initDefaultHandlers() } #endif -#ifdef alpha_TARGET_ARCH +#ifdef alpha_HOST_ARCH ieee_set_fp_control(0); #endif } diff --git a/ghc/rts/Signals.h b/ghc/rts/Signals.h index 09ecec0814..ffcac5562d 100644 --- a/ghc/rts/Signals.h +++ b/ghc/rts/Signals.h @@ -6,7 +6,7 @@ * * ---------------------------------------------------------------------------*/ -#if !defined(PAR) && !defined(mingw32_TARGET_OS) +#if !defined(PAR) && !defined(mingw32_HOST_OS) #define RTS_USER_SIGNALS 1 extern StgPtr pending_handler_buf[]; @@ -30,7 +30,7 @@ extern void initDefaultHandlers(void); extern void handleSignalsInThisThread(void); extern void handleSignalsInPrevThread(void); -#elif defined(mingw32_TARGET_OS) +#elif defined(mingw32_HOST_OS) #define RTS_USER_SIGNALS 1 #include "win32/ConsoleHandler.h" diff --git a/ghc/rts/Stats.c b/ghc/rts/Stats.c index 35d1c9f245..7c1dbaf946 100644 --- a/ghc/rts/Stats.c +++ b/ghc/rts/Stats.c @@ -24,7 +24,7 @@ #include <unistd.h> #endif -#ifndef mingw32_TARGET_OS +#ifndef mingw32_HOST_OS # ifdef HAVE_SYS_TIMES_H # include <sys/times.h> # endif @@ -40,7 +40,7 @@ # endif #endif -#if ! irix_TARGET_OS && ! defined(mingw32_TARGET_OS) +#if ! irix_HOST_OS && ! defined(mingw32_HOST_OS) # if defined(HAVE_SYS_RESOURCE_H) # include <sys/resource.h> # endif @@ -58,7 +58,7 @@ #include <windows.h> #endif -#if defined(PAR) || !(!defined(HAVE_GETRUSAGE) || irix_TARGET_OS || defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS)) +#if defined(PAR) || !(!defined(HAVE_GETRUSAGE) || irix_HOST_OS || defined(mingw32_HOST_OS) || defined(cygwin32_HOST_OS)) #include <sys/resource.h> #endif @@ -127,7 +127,7 @@ static void statsClose( void ); /* elapsedtime() -- The current elapsed time in seconds */ -#if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS) +#if defined(mingw32_HOST_OS) || defined(cygwin32_HOST_OS) #define HNS_PER_SEC 10000000LL /* FILETIMES are in units of 100ns */ /* Convert FILETIMEs into secs */ #define FT2longlong(ll,ft) \ @@ -137,7 +137,7 @@ static void statsClose( void ); (ll) /= (unsigned long long) (HNS_PER_SEC / CLOCKS_PER_SEC) #endif -#if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS) +#if defined(mingw32_HOST_OS) || defined(cygwin32_HOST_OS) /* cygwin32 or mingw32 version */ static void getTimes(void) @@ -264,7 +264,7 @@ pageFaults(void) { /* ToDo (on NT): better, get this via the performance data that's stored in the registry. */ -# if !defined(HAVE_GETRUSAGE) || irix_TARGET_OS || defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS) +# if !defined(HAVE_GETRUSAGE) || irix_HOST_OS || defined(mingw32_HOST_OS) || defined(cygwin32_HOST_OS) return 0; # else struct rusage t; diff --git a/ghc/rts/StgCRun.c b/ghc/rts/StgCRun.c index dc29597f9a..cf210d204f 100644 --- a/ghc/rts/StgCRun.c +++ b/ghc/rts/StgCRun.c @@ -50,7 +50,7 @@ * in libc.a clobbers $s6. */ #include "ghcconfig.h" -#ifdef alpha_TARGET_ARCH +#ifdef alpha_HOST_ARCH #define alpha_EXTRA_CAREFUL register long fake_ra __asm__("$26"); register long fake_gp __asm__("$29"); @@ -112,7 +112,7 @@ StgFunPtr StgReturn(void) x86 architecture -------------------------------------------------------------------------- */ -#ifdef i386_TARGET_ARCH +#ifdef i386_HOST_ARCH StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg) { @@ -175,7 +175,7 @@ StgRun(StgFunPtr f, StgRegTable *basereg) { ------------------------------------------------------------------------- */ -#ifdef x86_64_TARGET_ARCH +#ifdef x86_64_HOST_ARCH extern StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg); @@ -261,7 +261,7 @@ static void StgRunIsImplementedInAssembler(void) Updated info (GHC 4.08.2): not saving %i7 any more (see below). -------------------------------------------------------------------------- */ -#ifdef sparc_TARGET_ARCH +#ifdef sparc_HOST_ARCH StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg) { @@ -329,7 +329,7 @@ StgRun(StgFunPtr f, StgRegTable *basereg) { tru64unix.compaq.com/docs/base_doc/DOCUMENTATION/V51_PDF/ARH9MBTE.PDF -------------------------------------------------------------------------- */ -#ifdef alpha_TARGET_ARCH +#ifdef alpha_HOST_ARCH StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg) @@ -425,13 +425,13 @@ StgRun(StgFunPtr f, StgRegTable *basereg) return ret; } -#endif /* alpha_TARGET_ARCH */ +#endif /* alpha_HOST_ARCH */ /* ----------------------------------------------------------------------------- HP-PA architecture -------------------------------------------------------------------------- */ -#ifdef hppa1_1_TARGET_ARCH +#ifdef hppa1_1_HOST_ARCH StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg) @@ -518,7 +518,7 @@ StgRun(StgFunPtr f, StgRegTable *basereg) return ret; } -#endif /* hppa1_1_TARGET_ARCH */ +#endif /* hppa1_1_HOST_ARCH */ /* ----------------------------------------------------------------------------- PowerPC architecture @@ -527,11 +527,11 @@ StgRun(StgFunPtr f, StgRegTable *basereg) -------------------------------------------------------------------------- */ -#ifdef powerpc_TARGET_ARCH +#ifdef powerpc_HOST_ARCH extern StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg); -#ifdef darwin_TARGET_OS +#ifdef darwin_HOST_OS static void StgRunIsImplementedInAssembler(void) { #if HAVE_SUBSECTIONS_VIA_SYMBOLS @@ -644,9 +644,9 @@ static void StgRunIsImplementedInAssembler(void) -------------------------------------------------------------------------- */ -#ifdef powerpc64_TARGET_ARCH +#ifdef powerpc64_HOST_ARCH -#ifdef linux_TARGET_OS +#ifdef linux_HOST_OS extern StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg); static void StgRunIsImplementedInAssembler(void) @@ -767,7 +767,7 @@ static void StgRunIsImplementedInAssembler(void) "\tblr\n" : : "i"(RESERVED_C_STACK_BYTES+304 /*stack frame size*/)); } -#else // linux_TARGET_OS +#else // linux_HOST_OS #error Only linux support for power64 right now. #endif @@ -786,7 +786,7 @@ static void StgRunIsImplementedInAssembler(void) loc31: saved gp (gcc 3.3 uses this slot) -------------------------------------------------------------------------- */ -#ifdef ia64_TARGET_ARCH +#ifdef ia64_HOST_ARCH /* the memory stack is rarely used, so 16K is excessive */ #undef RESERVED_C_STACK_BYTES diff --git a/ghc/rts/Timer.c b/ghc/rts/Timer.c index 013fd06594..147b4d1855 100644 --- a/ghc/rts/Timer.c +++ b/ghc/rts/Timer.c @@ -20,7 +20,7 @@ #include "Schedule.h" #include "Timer.h" -#if !defined(mingw32_TARGET_OS) +#if !defined(mingw32_HOST_OS) #include "Itimer.h" #else #include "win32/Ticker.h" diff --git a/ghc/rts/package.conf.in b/ghc/rts/package.conf.in index 24b3df9045..bd26627ea2 100644 --- a/ghc/rts/package.conf.in +++ b/ghc/rts/package.conf.in @@ -16,7 +16,7 @@ import-dirs: #ifdef INSTALLING library-dirs: LIB_DIR -# ifdef mingw32_TARGET_OS +# ifdef mingw32_HOST_OS , LIB_DIR"/gcc-lib" /* force the dist-provided gcc-lib/ into scope. */ # endif @@ -36,7 +36,7 @@ extra-libs: "m" /* for ldexp() */ , "dl" #endif #endif -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS ,"wsock32" /* for the linker */ #endif #ifdef WANT_DOTNET_SUPPORT @@ -53,7 +53,7 @@ extra-libs: "m" /* for ldexp() */ #ifdef INSTALLING include-dirs: INCLUDE_DIR -# ifdef mingw32_TARGET_OS +# ifdef mingw32_HOST_OS , INCLUDE_DIR"/mingw" # endif #else /* !INSTALLING */ diff --git a/ghc/rts/parallel/ParTicky.c b/ghc/rts/parallel/ParTicky.c index 97f8d696f9..347c2b8bca 100644 --- a/ghc/rts/parallel/ParTicky.c +++ b/ghc/rts/parallel/ParTicky.c @@ -65,7 +65,7 @@ static double start_unpack = 0.0; void par_ticky_Par_start (void) { -# if !defined(HAVE_GETRUSAGE) || irix_TARGET_OS || defined(_WIN32) +# if !defined(HAVE_GETRUSAGE) || irix_HOST_OS || defined(_WIN32) fprintf(stderr, "|| sorry don't have RUSAGE\n"); return ; # else diff --git a/ghc/utils/ghc-pkg/Main.hs b/ghc/utils/ghc-pkg/Main.hs index 189ca99495..1b5f8f75dd 100644 --- a/ghc/utils/ghc-pkg/Main.hs +++ b/ghc/utils/ghc-pkg/Main.hs @@ -28,9 +28,7 @@ import qualified Control.Exception as Exception import Prelude -#if __GLASGOW_HASKELL__ < 603 -#include "config.h" -#endif +#include "../../includes/ghcconfig.h" #if __GLASGOW_HASKELL__ >= 504 import System.Console.GetOpt @@ -51,7 +49,7 @@ import System ( getArgs, getProgName, import System.IO import Data.List ( isPrefixOf, isSuffixOf, intersperse ) -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS import Foreign #if __GLASGOW_HASKELL__ >= 504 @@ -605,7 +603,7 @@ autoBuildGHCiLib dir batch_file ghci_file = do let ghci_lib_file = dir ++ '/':ghci_file batch_lib_file = dir ++ '/':batch_file hPutStr stderr ("building GHCi library " ++ ghci_lib_file ++ "...") -#if defined(darwin_TARGET_OS) +#if defined(darwin_HOST_OS) r <- rawSystem "ld" ["-r","-x","-o",ghci_lib_file,"-all_load",batch_lib_file] #elif defined(mingw32_HOST_OS) execDir <- getExecDir "/bin/ghc-pkg.exe" @@ -915,7 +913,7 @@ dieOrForce force s ----------------------------------------- -- Cut and pasted from ghc/compiler/SysTools -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) subst a b ls = map (\ x -> if x == a then b else x) ls unDosifyPath xs = subst '\\' '/' xs @@ -977,7 +975,7 @@ isPathSeparator ch = ch == pathSeparator || ch == '/' -- separator is a slash (@\"\/\"@) on Unix and Macintosh, and a backslash -- (@\"\\\"@) on the Windows operating system. pathSeparator :: Char -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS pathSeparator = '\\' #else pathSeparator = '/' diff --git a/ghc/utils/hsc2hs/Main.hs b/ghc/utils/hsc2hs/Main.hs index 770b1562fc..f6f8ecb9ef 100644 --- a/ghc/utils/hsc2hs/Main.hs +++ b/ghc/utils/hsc2hs/Main.hs @@ -1,7 +1,7 @@ {-# OPTIONS -fffi -cpp #-} ------------------------------------------------------------------------ --- $Id: Main.hs,v 1.68 2005/01/27 12:38:49 ross Exp $ +-- $Id: Main.hs,v 1.69 2005/01/28 12:56:26 simonmar Exp $ -- -- Program for converting .hsc files to .hs files, by converting the -- file into a C program which is run to generate the Haskell source. @@ -11,6 +11,10 @@ -- -- See the documentation in the Users' Guide for more details. +#if defined(__GLASGOW_HASKELL__) && !defined(BUILD_NHC) +#include "../../includes/ghcconfig.h" +#endif + #if __GLASGOW_HASKELL__ >= 504 || __NHC__ >= 114 || __HUGS__ import System.Console.GetOpt #else diff --git a/ghc/utils/hsc2hs/Makefile b/ghc/utils/hsc2hs/Makefile index 3ec18d8e4f..f107167940 100644 --- a/ghc/utils/hsc2hs/Makefile +++ b/ghc/utils/hsc2hs/Makefile @@ -29,9 +29,6 @@ endif # for calling the C preprocessor via GHC has changed a few times, making a # clean solution impossible. So we revert to a hack in Main.hs... SRC_HC_OPTS += -Wall -ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" -SRC_HC_OPTS += -Dmingw32_HOST_OS=1 -endif ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32" INSTALLED_SCRIPT_PROG = hsc2hs |