Rationalise the BUILD,HOST,TARGET defines.
Recall that:
- build is the platform we're building on
- host is the platform we're running on
- target is the platform we're generating code for
The change is that now we take these definitions as applying from the
point of view of the particular source code being built, rather than
the point of view of the whole build tree.
For example, in RTS and library code, we were previously testing the
TARGET platform. But under the new rule, the platform on which this
code is going to run is the HOST platform. TARGET only makes sense in
the compiler sources.
In practical terms, this means that the values of BUILD, HOST & TARGET
may vary depending on which part of the build tree we are in.
Actual changes:
- new file: includes/ghcplatform.h contains platform defines for
the RTS and library code.
- new file: includes/ghcautoconf.h contains the autoconf settings
only (HAVE_BLAH). This is so that we can get hold of these
settings independently of the platform defines when necessary
(eg. in GHC).
- ghcconfig.h now #includes both ghcplatform.h and ghcautoconf.h.
- MachRegs.h, which is included into both the compiler and the RTS,
now has to cope with the fact that it might need to test either
_TARGET_ or _HOST_ depending on the context.
- the compiler's Makefile now generates
stage{1,2,3}/ghc_boot_platform.h
which contains platform defines for the compiler. These differ
depending on the stage, of course: in stage2, the HOST is the
TARGET of stage1. This was wrong before.
- The compiler doesn't get platform info from Config.hs any more.
Previously it did (sometimes), but unless we want to generate
a new Config.hs for each stage we can't do this.
- GHC now helpfully defines *_{BUILD,HOST}_{OS,ARCH} automatically
in CPP'd Haskell source.
- ghcplatform.h defines *_TARGET_* for backwards compatibility
(ghcplatform.h is included by ghcconfig.h, which is included by
config.h, so code which still #includes config.h will get the TARGET
settings as before).
- The Users's Guide is updated to mention *_HOST_* rather than
*_TARGET_*.
- coding-style.html in the commentary now contains a section on
platform defines. There are further doc updates to come.
Thanks to Wolfgang Thaller for pointing me in the right direction.
#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
@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)
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
#include "HsVersions.h"
-#include "../includes/ghcconfig.h"
import CmdLineOpts ( DynFlags, opt_Static, opt_DoTickyProfiling )
import Packages ( isHomeModule, isDllName )
) where
#include "HsVersions.h"
-#include "../includes/ghcconfig.h"
import Constants
import Outputable
) 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
import DATA_BITS
import Maybe ( isNothing )
-#include "../includes/ghcconfig.h"
- -- For WORDS_BIGENDIAN
-
-------------------------------------------------------------------------
--
-- Random small functions
{-# 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
--
ghciWelcomeMsg
) where
-#include "../includes/ghcconfig.h"
#include "HsVersions.h"
import CompManager
linkPackages,
) where
-#include "../includes/ghcconfig.h"
#include "HsVersions.h"
import ObjLink ( loadDLL, loadObj, unloadObj, resolveObjs, initObjLinker )
| 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 = [],
-- be in trouble.
#include "HsVersions.h"
-#include "../includes/ghcconfig.h"
#include "../includes/MachRegs.h"
#include "../includes/Constants.h"
#include "../includes/MachDeps.h"
) where
#include "HsVersions.h"
-#include "../includes/ghcconfig.h"
import MkIface ( showIface )
import DriverState
-- )
machdepCCOpts dflags
- | prefixMatch "alpha" cTARGETPLATFORM
+#if alpha_TARGET_ARCH
= return ( ["-w", "-mieee"
#ifdef HAVE_THREADED_RTS_SUPPORT
, "-D_REENTRANT"
-- 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!
-- 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
"-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
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
-----------------------------------------------------------------------------
--- $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
--
--
-----------------------------------------------------------------------------
-#include "../includes/ghcconfig.h"
-
module DriverPhases (
HscSource(..), isHsBoot, hscSourceString,
HscTarget(..), Phase(..),
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
| 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
module DriverState where
-#include "../includes/ghcconfig.h"
#include "HsVersions.h"
import CmdLineOpts
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
-----------------------------------------------------------------------------
--- $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
--
replaceFilenameDirectory, remove_spaces, escapeSpaces,
) where
-#include "../includes/ghcconfig.h"
#include "HsVersions.h"
import Util
{-# 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
--
--
-----------------------------------------------------------------------------
--- 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
)
where
-#include "../includes/ghcconfig.h"
--- Needed for mingw32_TARGET_OS defn
-
#include "HsVersions.h"
import PackageConfig
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
-- (GHC >= 6.3).
appdir <- getAppUserDataDirectory "ghc"
let
- pkgconf = appdir ++ '/':cTARGETARCH ++ '-':cTARGETOS
+ pkgconf = appdir ++ '/':TARGET_ARCH ++ '-':TARGET_OS
++ '-':cProjectVersion ++ "/package.conf"
--
exists <- doesFileExist pkgconf
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
) where
#include "HsVersions.h"
-#include "../includes/ghcconfig.h"
import MachRegs
import Cmm
#ifndef NCG_H
#define NCG_H
-#include "../includes/ghcconfig.h"
+#include "ghc_boot_platform.h"
#define COMMA ,
-#include "../includes/ghcconfig.h"
-
module PositionIndependentCode (
cmmMakeDynamicReference,
needImportedSymbols,
) where
#include "HsVersions.h"
-#include "../includes/ghcconfig.h"
import PprMach
import MachRegs
, tcForeignExports
) where
-#include "../includes/ghcconfig.h"
#include "HsVersions.h"
import HsSyn
) where
#include "HsVersions.h"
-#include "../includes/ghcconfig.h"
import Config
import FastTypes
readRational,
) where
-#include "../includes/ghcconfig.h"
#include "HsVersions.h"
import Panic ( panic, trace )
Avoid conditional code like this:
<pre>
- #ifdef solaris_HOST_OS
+ #ifdef solaris_host_OS
// do something solaris specific
#endif
</pre>
</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
<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
<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
/* -----------------------------------------------------------------------------
- * $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
*
*/
#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.
t12 $27 NCG_reserved
-------------------------------------------------------------------------- */
-#if defined(alpha_TARGET_ARCH)
+#if alpha_REGS
# define REG(x) __asm__("$" #x)
# define CALLER_SAVES_R2
# define NCG_Reserved_F1 f29
# define NCG_Reserved_F2 f30
-#endif /* alpha_TARGET_ARCH */
+#endif /* alpha_REGS */
/* -----------------------------------------------------------------------------
The HP-PA register mapping
\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)
-------------------------------------------------------------------------- */
-#if i386_TARGET_ARCH
+#if i386_REGS
#define REG(x) __asm__("%" #x)
%r15 YES
--------------------------------------------------------------------------- */
-#if x86_64_TARGET_ARCH
+#if x86_64_REGS
#define REG(x) __asm__("%" #x)
\end{tabular}
-------------------------------------------------------------------------- */
-#if m68k_TARGET_ARCH
+#if m68k_REGS
#define REG(x) __asm__(#x)
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)
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)
#define REG_R7 r20
#define REG_R8 r21
-#ifdef darwin_TARGET_OS
+#ifdef darwin_REGS
#define REG_F1 f14
#define REG_F2 f15
\tr{f16-f32} are the callee-saved floating point registers.
-------------------------------------------------------------------------- */
-#ifdef ia64_TARGET_ARCH
+#if ia64_REGS
#define REG(x) __asm__(#x)
-------------------------------------------------------------------------- */
-#if sparc_TARGET_ARCH
+#if sparc_REGS
#define REG(x) __asm__("%" #x)
# -----------------------------------------------------------------------------
-# $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 = ..
#
# 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
$(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."
# ---------------------------------------------------------------------------
#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
*
* 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
/* ----------------------------------------------------------------------------
- * $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
*
* (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" \
#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 *);
/* -----------------------------------------------------------------------------
- * $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
*
* 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); \
"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_ []);
return(y.d);
}
-#endif /* ! sparc_TARGET_ARCH */
+#endif /* ! sparc_HOST_ARCH */
#endif /* ALIGNMENT_DOUBLE > ALIGNMENT_UNSIGNED_INT */
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
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);
/* -----------------------------------------------------------------------------
- * $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
*
*/
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;
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;
/* -----------------------------------------------------------------------------
- * $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
*
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
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) \
{ \
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,
#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");
#define FB_
#define FE_
-#endif /* alpha_TARGET_ARCH */
+#endif /* alpha_HOST_ARCH */
/* -----------------------------------------------------------------------------
Tail calling on HP
Tail calling on PowerPC
-------------------------------------------------------------------------- */
-#ifdef powerpc_TARGET_ARCH
+#ifdef powerpc_HOST_ARCH
#define JMP_(cont) \
{ \
#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
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. */
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);
createDirectoryIfMissing
) where
-#if __GLASGOW_HASKELL__ < 603
-#include "config.h"
-#endif
+#include "../../includes/ghcconfig.h"
import System.Environment (getEnv)
import System.Directory.Internals
#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
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
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
path <- getEnv "PATH"
search (parseSearchPath path)
where
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
fileName = binary `joinFileExt` "exe"
#else
fileName = binary
module Compat.RawSystem (rawSystem) where
-#if __GLASGOW_HASKELL__ < 603
-#include "config.h"
-#endif
+#include "../../includes/ghcconfig.h"
#if __GLASGOW_HASKELL__ >= 603
----------------------------------------------------------------------------- -}
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
rawSystem cmd args =
withCString cmd $ \pcmd ->
-#if __GLASGOW_HASKELL__ < 603\r
-#include "config.h"\r
-#else\r
-#include "ghcconfig.h"\r
-#endif\r
+#include "../../../includes/ghcconfig.h"\r
\r
#include "HsFFI.h"\r
\r
INLINE HsInt __compat_long_path_size() { return 4096; }\r
#endif\r
\r
-#if defined(mingw32_TARGET_OS)\r
+#if defined(mingw32_HOST_OS)\r
\r
/* Make sure we've got the reqd CSIDL_ constants in scope;\r
* w32api header files are lagging a bit in defining the full set.\r
/* 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>
#include "HsFFI.h"
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
#include <windows.h>
#endif
#define fork vfork
#endif
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
/* -------------------- WINDOWS VERSION --------------------- */
HsInt
#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>
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
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;
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);
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 */
}
#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"
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
*/
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;
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
)
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):
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):
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):
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
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.
/* 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))
}
}
-#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))
// 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)
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':
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.
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);
} 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;
/* 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;
/* 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);
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
#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.
/* 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
/* 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
/* 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
/* 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
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)
case BlockedOnException:
case BlockedOnRead:
case BlockedOnWrite:
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
case BlockedOnDoProc:
#endif
case BlockedOnDelay:
BLOCK_GENERIC;
}
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
INFO_TABLE_RET( stg_block_async, 0/*framesize*/, 0/*bitmap*/, RET_SMALL )
{
W_ ares;
#include <dlfcn.h>
#endif
-#if defined(cygwin32_TARGET_OS)
+#if defined(cygwin32_HOST_OS)
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#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
#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>
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)
#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
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 /**/
Sym(__ashrdi3) \
Sym(__lshrdi3) \
Sym(__eprintf)
-#elif defined(ia64_TARGET_ARCH)
+#elif defined(ia64_HOST_ARCH)
#define RTS_LIBGCC_SYMBOLS \
Sym(__divdi3) \
Sym(__udivdi3) \
#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()
#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
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
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 */
}
#endif
-#ifdef ia64_TARGET_ARCH
+#ifdef ia64_HOST_ARCH
static unsigned int PLTSize(void);
#endif
/* 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);
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);
# 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
* PowerPC specifics (jump islands)
* ------------------------------------------------------------------------*/
-#if defined(powerpc_TARGET_ARCH)
+#if defined(powerpc_HOST_ARCH)
/*
ocAllocateJumpIslands
#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 */
# 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 */
#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);
return ptr;
}
-#if defined(ia64_TARGET_ARCH)
+#if defined(ia64_HOST_ARCH)
static Elf_Addr
findElfSegment ( void* objImage, Elf_Addr vaddr )
{
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
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;
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
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);
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;
/* 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;
freeHashTable(oc->lochash, NULL);
oc->lochash = NULL;
-#if defined(powerpc_TARGET_ARCH)
+#if defined(powerpc_HOST_ARCH)
ocFlushInstructionCache( oc );
#endif
* take care of the most common relocations.
*/
-#ifdef ia64_TARGET_ARCH
+#ifdef ia64_HOST_ARCH
static Elf64_Xword
ia64_extract_instruction(Elf64_Xword *target)
* PowerPC ELF specifics
*/
-#ifdef powerpc_TARGET_ARCH
+#ifdef powerpc_HOST_ARCH
static int ocAllocateJumpIslands_ELF( ObjectCode *oc )
{
freeHashTable(oc->lochash, NULL);
oc->lochash = NULL;
-#if defined (powerpc_TARGET_ARCH)
+#if defined (powerpc_HOST_ARCH)
ocFlushInstructionCache( oc );
#endif
/* 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;
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;
#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
#if HAVE_WINDOWS_H
#include <windows.h>
#endif
-#if darwin_TARGET_OS
+#if darwin_HOST_OS
#include <mach/vm_map.h>
#endif
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.
{
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
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
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
STRING(stg_delayzh_malloc_str, "delayzh_fast")
delayzh_fast
{
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
W_ ares;
CInt reqID;
#else
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,
}
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
STRING(stg_asyncReadzh_malloc_str, "asyncReadzh_fast")
asyncReadzh_fast
{
/* 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
'\\')
# include "LLC.h"
#endif
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
#include "win32/AsyncIO.h"
#endif
initDefaultHandlers();
#endif
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
startupAsyncIO();
#endif
if (RtsFlags.TickyFlags.showTickyStats) PrintTickyInfo();
#endif
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
shutdownAsyncIO();
#endif
}
#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
* clean up for us.
* -------------------------------------------------------------------------- */
-#if !defined(mingw32_TARGET_OS)
+#if !defined(mingw32_HOST_OS)
void
resetNonBlockingFd(int fd)
{
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) {
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) {
* 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);
case BlockedOnRead:
case BlockedOnWrite:
case BlockedOnDelay:
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
case BlockedOnDoProc:
#endif
/* isOnBQ(blocked_queue) */
// 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.
*/
* Singleton fork(). Do not copy any running threads.
* ------------------------------------------------------------------------- */
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
#define FORKPROCESS_PRIMOP_SUPPORTED
#endif
case BlockedOnRead:
case BlockedOnWrite:
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
case BlockedOnDoProc:
#endif
{
case BlockedOnRead:
case BlockedOnWrite:
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
case BlockedOnDoProc:
#endif
{
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;
#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>
}
#endif
-#ifdef alpha_TARGET_ARCH
+#ifdef alpha_HOST_ARCH
ieee_set_fp_control(0);
#endif
}
*
* ---------------------------------------------------------------------------*/
-#if !defined(PAR) && !defined(mingw32_TARGET_OS)
+#if !defined(PAR) && !defined(mingw32_HOST_OS)
#define RTS_USER_SIGNALS 1
extern StgPtr pending_handler_buf[];
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"
#include <unistd.h>
#endif
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
# ifdef HAVE_SYS_TIMES_H
# include <sys/times.h>
# endif
# 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
#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
/* 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) \
(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)
{
/* 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;
* 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");
x86 architecture
-------------------------------------------------------------------------- */
-#ifdef i386_TARGET_ARCH
+#ifdef i386_HOST_ARCH
StgThreadReturnCode
StgRun(StgFunPtr f, StgRegTable *basereg) {
------------------------------------------------------------------------- */
-#ifdef x86_64_TARGET_ARCH
+#ifdef x86_64_HOST_ARCH
extern StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg);
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) {
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)
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)
return ret;
}
-#endif /* hppa1_1_TARGET_ARCH */
+#endif /* hppa1_1_HOST_ARCH */
/* -----------------------------------------------------------------------------
PowerPC architecture
-------------------------------------------------------------------------- */
-#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
-------------------------------------------------------------------------- */
-#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)
"\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
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
#include "Schedule.h"
#include "Timer.h"
-#if !defined(mingw32_TARGET_OS)
+#if !defined(mingw32_HOST_OS)
#include "Itimer.h"
#else
#include "win32/Ticker.h"
#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
, "dl"
#endif
#endif
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
,"wsock32" /* for the linker */
#endif
#ifdef WANT_DOTNET_SUPPORT
#ifdef INSTALLING
include-dirs: INCLUDE_DIR
-# ifdef mingw32_TARGET_OS
+# ifdef mingw32_HOST_OS
, INCLUDE_DIR"/mingw"
# endif
#else /* !INSTALLING */
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
import Prelude
-#if __GLASGOW_HASKELL__ < 603
-#include "config.h"
-#endif
+#include "../../includes/ghcconfig.h"
#if __GLASGOW_HASKELL__ >= 504
import System.Console.GetOpt
import System.IO
import Data.List ( isPrefixOf, isSuffixOf, intersperse )
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
import Foreign
#if __GLASGOW_HASKELL__ >= 504
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"
-----------------------------------------
-- 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
-- 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 = '/'
{-# 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.
--
-- 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
# 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