Commit a2a67cd5 authored by Simon Marlow's avatar Simon Marlow

RTS tidyup sweep, first phase

The first phase of this tidyup is focussed on the header files, and in
particular making sure we are exposinng publicly exactly what we need
to, and no more.

 - Rts.h now includes everything that the RTS exposes publicly,
   rather than a random subset of it.

 - Most of the public header files have moved into subdirectories, and
   many of them have been renamed.  But clients should not need to
   include any of the other headers directly, just #include the main
   public headers: Rts.h, HsFFI.h, RtsAPI.h.

 - All the headers needed for via-C compilation have moved into the
   stg subdirectory, which is self-contained.  Most of the headers for
   the rest of the RTS APIs have moved into the rts subdirectory.

 - I left MachDeps.h where it is, because it is so widely used in
   Haskell code.
 
 - I left a deprecated stub for RtsFlags.h in place.  The flag
   structures are now exposed by Rts.h.

 - Various internal APIs are no longer exposed by public header files.

 - Various bits of dead code and declarations have been removed

 - More gcc warnings are turned on, and the RTS code is more
   warning-clean.

 - More source files #include "PosixSource.h", and hence only use
   standard POSIX (1003.1c-1995) interfaces.

There is a lot more tidying up still to do, this is just the first
pass.  I also intend to standardise the names for external RTS APIs
(e.g use the rts_ prefix consistently), and declare the internal APIs
as hidden for shared libraries.
parent 5d379cbe
...@@ -58,7 +58,7 @@ cmmToRawCmm cmm = do ...@@ -58,7 +58,7 @@ cmmToRawCmm cmm = do
-- <normal forward rest of StgInfoTable> -- <normal forward rest of StgInfoTable>
-- <forward variable part> -- <forward variable part>
-- --
-- See includes/InfoTables.h -- See includes/rts/storage/InfoTables.h
-- --
-- For return-points these are as follows -- For return-points these are as follows
-- --
......
...@@ -56,7 +56,7 @@ import Data.Maybe ...@@ -56,7 +56,7 @@ import Data.Maybe
-- Temp Jan08 -- Temp Jan08
import SMRep import SMRep
import ClosureInfo import ClosureInfo
#include "../includes/StgFun.h" #include "../includes/rts/storage/FunTypes.h"
pprCmms :: (Outputable info, Outputable g) => [GenCmm CmmStatic info g] -> SDoc pprCmms :: (Outputable info, Outputable g) => [GenCmm CmmStatic info g] -> SDoc
......
...@@ -64,7 +64,7 @@ import Data.Bits ...@@ -64,7 +64,7 @@ import Data.Bits
------------------------------------------------------------------------- -------------------------------------------------------------------------
-- bring in ARG_P, ARG_N, etc. -- bring in ARG_P, ARG_N, etc.
#include "../includes/StgFun.h" #include "../includes/rts/storage/FunTypes.h"
------------------------- -------------------------
argDescrType :: ArgDescr -> StgHalfWord argDescrType :: ArgDescr -> StgHalfWord
......
...@@ -24,9 +24,9 @@ module CgProf ( ...@@ -24,9 +24,9 @@ module CgProf (
) where ) where
#include "HsVersions.h" #include "HsVersions.h"
#include "MachDeps.h" #include "../includes/MachDeps.h"
-- For WORD_SIZE_IN_BITS only. -- For WORD_SIZE_IN_BITS only.
#include "../includes/Constants.h" #include "../includes/rts/Constants.h"
-- For LDV_CREATE_MASK, LDV_STATE_USE -- For LDV_CREATE_MASK, LDV_STATE_USE
-- which are StgWords -- which are StgWords
#include "../includes/DerivedConstants.h" #include "../includes/DerivedConstants.h"
......
...@@ -50,7 +50,7 @@ module CgUtils ( ...@@ -50,7 +50,7 @@ module CgUtils (
) where ) where
#include "HsVersions.h" #include "HsVersions.h"
#include "../includes/MachRegs.h" #include "../includes/stg/MachRegs.h"
import BlockId import BlockId
import CgMonad import CgMonad
......
...@@ -246,7 +246,7 @@ data SMRep ...@@ -246,7 +246,7 @@ data SMRep
| BlackHoleRep | BlackHoleRep
data ClosureType -- Corresponds 1-1 with the varieties of closures data ClosureType -- Corresponds 1-1 with the varieties of closures
-- implemented by the RTS. Compare with ghc/includes/ClosureTypes.h -- implemented by the RTS. Compare with includes/rts/storage/ClosureTypes.h
= Constr = Constr
| ConstrNoCaf | ConstrNoCaf
| Fun | Fun
...@@ -284,7 +284,7 @@ isStaticRep BlackHoleRep = False ...@@ -284,7 +284,7 @@ isStaticRep BlackHoleRep = False
\end{code} \end{code}
\begin{code} \begin{code}
#include "../includes/ClosureTypes.h" #include "../includes/rts/storage/ClosureTypes.h"
-- Defines CONSTR, CONSTR_1_0 etc -- Defines CONSTR, CONSTR_1_0 etc
-- krc: only called by tickyDynAlloc in CgTicky; return -- krc: only called by tickyDynAlloc in CgTicky; return
......
...@@ -313,7 +313,7 @@ mkVirtHeapOffsets is_thunk things ...@@ -313,7 +313,7 @@ mkVirtHeapOffsets is_thunk things
------------------------------------------------------------------------- -------------------------------------------------------------------------
-- bring in ARG_P, ARG_N, etc. -- bring in ARG_P, ARG_N, etc.
#include "../includes/StgFun.h" #include "../includes/rts/storage/FunTypes.h"
------------------------- -------------------------
-- argDescrType :: ArgDescr -> StgHalfWord -- argDescrType :: ArgDescr -> StgHalfWord
......
...@@ -25,9 +25,9 @@ module StgCmmProf ( ...@@ -25,9 +25,9 @@ module StgCmmProf (
) where ) where
#include "HsVersions.h" #include "HsVersions.h"
#include "MachDeps.h" #include "../includes/MachDeps.h"
-- For WORD_SIZE_IN_BITS only. -- For WORD_SIZE_IN_BITS only.
#include "../includes/Constants.h" #include "../includes/rts/Constants.h"
-- For LDV_CREATE_MASK, LDV_STATE_USE -- For LDV_CREATE_MASK, LDV_STATE_USE
-- which are StgWords -- which are StgWords
#include "../includes/DerivedConstants.h" #include "../includes/DerivedConstants.h"
......
...@@ -44,7 +44,7 @@ module StgCmmUtils ( ...@@ -44,7 +44,7 @@ module StgCmmUtils (
) where ) where
#include "HsVersions.h" #include "HsVersions.h"
#include "MachRegs.h" #include "../includes/stg/MachRegs.h"
import StgCmmMonad import StgCmmMonad
import StgCmmClosure import StgCmmClosure
......
...@@ -208,7 +208,7 @@ sizeSS16 :: SizedSeq a -> Word16 ...@@ -208,7 +208,7 @@ sizeSS16 :: SizedSeq a -> Word16
sizeSS16 (SizedSeq n _) = fromIntegral n sizeSS16 (SizedSeq n _) = fromIntegral n
-- Bring in all the bci_ bytecode constants. -- Bring in all the bci_ bytecode constants.
#include "Bytecodes.h" #include "rts/Bytecodes.h"
largeArgInstr :: Word16 -> Word16 largeArgInstr :: Word16 -> Word16
largeArgInstr bci = bci_FLAG_LARGE_ARGS .|. bci largeArgInstr bci = bci_FLAG_LARGE_ARGS .|. bci
......
...@@ -84,7 +84,7 @@ mkITbl tc ...@@ -84,7 +84,7 @@ mkITbl tc
dcs = tyConDataCons tc dcs = tyConDataCons tc
n = tyConFamilySize tc n = tyConFamilySize tc
#include "../includes/ClosureTypes.h" #include "../includes/rts/storage/ClosureTypes.h"
cONSTR :: Int -- Defined in ClosureTypes.h cONSTR :: Int -- Defined in ClosureTypes.h
cONSTR = CONSTR cONSTR = CONSTR
...@@ -151,7 +151,7 @@ ptrToInt (Ptr a#) = I# (addr2Int# a#) ...@@ -151,7 +151,7 @@ ptrToInt (Ptr a#) = I# (addr2Int# a#)
#if sparc_TARGET_ARCH #if sparc_TARGET_ARCH
-- After some consideration, we'll try this, where -- After some consideration, we'll try this, where
-- 0x55555555 stands in for the address to jump to. -- 0x55555555 stands in for the address to jump to.
-- According to ghc/includes/MachRegs.h, %g3 is very -- According to includes/rts/MachRegs.h, %g3 is very
-- likely indeed to be baggable. -- likely indeed to be baggable.
-- --
-- 0000 07155555 sethi %hi(0x55555555), %g3 -- 0000 07155555 sethi %hi(0x55555555), %g3
......
...@@ -165,7 +165,7 @@ data Closure = Closure { tipe :: ClosureType ...@@ -165,7 +165,7 @@ data Closure = Closure { tipe :: ClosureType
instance Outputable ClosureType where instance Outputable ClosureType where
ppr = text . show ppr = text . show
#include "../includes/ClosureTypes.h" #include "../includes/rts/storage/ClosureTypes.h"
aP_CODE, pAP_CODE :: Int aP_CODE, pAP_CODE :: Int
aP_CODE = AP aP_CODE = AP
......
...@@ -206,7 +206,7 @@ initBinMemSize :: Int ...@@ -206,7 +206,7 @@ initBinMemSize :: Int
initBinMemSize = 1024 * 1024 initBinMemSize = 1024 * 1024
-- The *host* architecture version: -- The *host* architecture version:
#include "MachDeps.h" #include "../includes/MachDeps.h"
binaryInterfaceMagic :: Word32 binaryInterfaceMagic :: Word32
#if WORD_SIZE_IN_BITS == 32 #if WORD_SIZE_IN_BITS == 32
......
...@@ -14,8 +14,8 @@ import Data.Bits (shiftL) ...@@ -14,8 +14,8 @@ import Data.Bits (shiftL)
-- be in trouble. -- be in trouble.
#include "HsVersions.h" #include "HsVersions.h"
#include "../includes/MachRegs.h" #include "../includes/stg/MachRegs.h"
#include "../includes/Constants.h" #include "../includes/rts/Constants.h"
#include "../includes/MachDeps.h" #include "../includes/MachDeps.h"
#include "../includes/DerivedConstants.h" #include "../includes/DerivedConstants.h"
......
...@@ -275,7 +275,7 @@ opt_Unregisterised = lookUp (fsLit "-funregisterised") ...@@ -275,7 +275,7 @@ opt_Unregisterised = lookUp (fsLit "-funregisterised")
-- Derived, not a real option. Determines whether we will be compiling -- Derived, not a real option. Determines whether we will be compiling
-- info tables that reside just before the entry code, or with an -- info tables that reside just before the entry code, or with an
-- indirection to the entry code. See TABLES_NEXT_TO_CODE in -- indirection to the entry code. See TABLES_NEXT_TO_CODE in
-- includes/InfoTables.h. -- includes/rts/storage/InfoTables.h.
tablesNextToCode :: Bool tablesNextToCode :: Bool
tablesNextToCode = not opt_Unregisterised tablesNextToCode = not opt_Unregisterised
&& cGhcEnableTablesNextToCode == "YES" && cGhcEnableTablesNextToCode == "YES"
......
...@@ -21,7 +21,7 @@ where ...@@ -21,7 +21,7 @@ where
{- {-
#include "nativeGen/NCG.h" #include "nativeGen/NCG.h"
#include "HsVersions.h" #include "HsVersions.h"
#include "../includes/MachRegs.h" #include "../includes/stg/MachRegs.h"
import RegsBase import RegsBase
......
...@@ -22,7 +22,7 @@ where ...@@ -22,7 +22,7 @@ where
#include "HsVersions.h" #include "HsVersions.h"
#include "nativeGen/NCG.h" #include "nativeGen/NCG.h"
#include "MachDeps.h" #include "../includes/MachDeps.h"
-- NCG stuff: -- NCG stuff:
import PPC.Instr import PPC.Instr
......
...@@ -49,7 +49,7 @@ where ...@@ -49,7 +49,7 @@ where
#include "nativeGen/NCG.h" #include "nativeGen/NCG.h"
#include "HsVersions.h" #include "HsVersions.h"
#include "../includes/MachRegs.h" #include "../includes/stg/MachRegs.h"
import Reg import Reg
import RegClass import RegClass
......
...@@ -43,7 +43,7 @@ import FastTypes ...@@ -43,7 +43,7 @@ import FastTypes
-- There is an allocatableRegsInClass :: RegClass -> Int, but doing the unboxing -- There is an allocatableRegsInClass :: RegClass -> Int, but doing the unboxing
-- is too slow for us here. -- is too slow for us here.
-- --
-- Look at includes/MachRegs.h to get these numbers. -- Look at includes/stg/MachRegs.h to get these numbers.
-- --
#if i386_TARGET_ARCH #if i386_TARGET_ARCH
......
...@@ -115,7 +115,7 @@ import Data.Maybe ...@@ -115,7 +115,7 @@ import Data.Maybe
import Data.List import Data.List
import Control.Monad import Control.Monad
#include "../includes/MachRegs.h" #include "../includes/stg/MachRegs.h"
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
......
...@@ -15,7 +15,7 @@ where ...@@ -15,7 +15,7 @@ where
#include "HsVersions.h" #include "HsVersions.h"
#include "nativeGen/NCG.h" #include "nativeGen/NCG.h"
#include "MachDeps.h" #include "../includes/MachDeps.h"
-- NCG stuff: -- NCG stuff:
import SPARC.CodeGen.Sanity import SPARC.CodeGen.Sanity
......
...@@ -93,7 +93,7 @@ import FastBool ...@@ -93,7 +93,7 @@ import FastBool
#define f31 63 #define f31 63
#include "../includes/MachRegs.h" #include "../includes/stg/MachRegs.h"
-- | Check whether a machine register is free for allocation. -- | Check whether a machine register is free for allocation.
freeReg :: RegNo -> FastBool freeReg :: RegNo -> FastBool
......
...@@ -54,7 +54,7 @@ import FastBool ...@@ -54,7 +54,7 @@ import FastBool
prepared for any eventuality. prepared for any eventuality.
The whole fp-register pairing thing on sparcs is a huge nuisance. See The whole fp-register pairing thing on sparcs is a huge nuisance. See
fptools/ghc/includes/MachRegs.h for a description of what's going on includes/stg/MachRegs.h for a description of what's going on
here. here.
-} -}
...@@ -290,11 +290,13 @@ regDotColor reg ...@@ -290,11 +290,13 @@ regDotColor reg
-- Hard coded freeReg / globalRegMaybe ----------------------------------------- -- Hard coded freeReg / globalRegMaybe -----------------------------------------
-- This isn't being used at the moment because we're generating -- This isn't being used at the moment because we're generating
-- these functions from the information in includes/MachRegs.hs via RegPlate.hs -- these functions from the information in
-- includes/stg/MachRegs.hs via RegPlate.hs
-- | Check whether a machine register is free for allocation. -- | Check whether a machine register is free for allocation.
-- This needs to match the info in includes/MachRegs.h otherwise modules -- This needs to match the info in includes/stg/MachRegs.h
-- compiled with the NCG won't be compatible with via-C ones. -- otherwise modules compiled with the NCG won't be compatible
-- with via-C ones.
-- --
{- {-
freeReg :: RegNo -> FastBool freeReg :: RegNo -> FastBool
......
...@@ -27,7 +27,7 @@ where ...@@ -27,7 +27,7 @@ where
#include "HsVersions.h" #include "HsVersions.h"
#include "nativeGen/NCG.h" #include "nativeGen/NCG.h"
#include "MachDeps.h" #include "../includes/MachDeps.h"
-- NCG stuff: -- NCG stuff:
import X86.Instr import X86.Instr
......
...@@ -466,7 +466,7 @@ pprDataItem lit ...@@ -466,7 +466,7 @@ pprDataItem lit
-- all such offsets will fit into 32 bits, so we have to stick -- all such offsets will fit into 32 bits, so we have to stick
-- to 32-bit offset fields and modify the RTS appropriately -- to 32-bit offset fields and modify the RTS appropriately
-- --
-- See Note [x86-64-relative] in includes/InfoTables.h -- See Note [x86-64-relative] in includes/rts/storage/InfoTables.h
-- --
ppr_item II64 x ppr_item II64 x
| isRelativeReloc x = | isRelativeReloc x =
......
...@@ -54,7 +54,7 @@ where ...@@ -54,7 +54,7 @@ where
-- HACK: go for the max -- HACK: go for the max
#endif #endif
#include "../includes/MachRegs.h" #include "../includes/stg/MachRegs.h"
import Reg import Reg
import RegClass import RegClass
......
...@@ -4,7 +4,9 @@ places in the GHC library. ...@@ -4,7 +4,9 @@ places in the GHC library.
*/ */
#include "Rts.h" #include "Rts.h"
#if __GLASGOW_HASKELL__ <= 610
#include "RtsFlags.h" #include "RtsFlags.h"
#endif
#include "HsFFI.h" #include "HsFFI.h"
...@@ -20,19 +22,19 @@ and causes gcc to require too many registers on x84 ...@@ -20,19 +22,19 @@ and causes gcc to require too many registers on x84
*/ */
HsInt HsInt
ghc_strlen( HsAddr a ) ghc_strlen( HsPtr a )
{ {
return (strlen((char *)a)); return (strlen((char *)a));
} }
HsInt HsInt
ghc_memcmp( HsAddr a1, HsAddr a2, HsInt len ) ghc_memcmp( HsPtr a1, HsPtr a2, HsInt len )
{ {
return (memcmp((char *)a1, a2, len)); return (memcmp((char *)a1, a2, len));
} }
HsInt HsInt
ghc_memcmp_off( HsAddr a1, HsInt i, HsAddr a2, HsInt len ) ghc_memcmp_off( HsPtr a1, HsInt i, HsPtr a2, HsInt len )
{ {
return (memcmp((char *)a1 + i, a2, len)); return (memcmp((char *)a1 + i, a2, len));
} }
......
...@@ -59,7 +59,7 @@ module Binary ...@@ -59,7 +59,7 @@ module Binary
#include "HsVersions.h" #include "HsVersions.h"
-- The *host* architecture version: -- The *host* architecture version:
#include "MachDeps.h" #include "../includes/MachDeps.h"
import {-# SOURCE #-} Name (Name) import {-# SOURCE #-} Name (Name)
import FastString import FastString
......
...@@ -19,7 +19,7 @@ module FastMutInt( ...@@ -19,7 +19,7 @@ module FastMutInt(
#ifdef __GLASGOW_HASKELL__ #ifdef __GLASGOW_HASKELL__
#include "MachDeps.h" #include "../includes/MachDeps.h"
#ifndef SIZEOF_HSINT #ifndef SIZEOF_HSINT
#define SIZEOF_HSINT INT_SIZE_IN_BYTES #define SIZEOF_HSINT INT_SIZE_IN_BYTES
#endif #endif
......
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
#define CMINUSMINUS 1 #define CMINUSMINUS 1
#include "ghcconfig.h" #include "ghcconfig.h"
#include "RtsConfig.h"
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Types Types
...@@ -144,6 +143,18 @@ ...@@ -144,6 +143,18 @@
name : bits8[] str; \ name : bits8[] str; \
} \ } \
#ifdef TABLES_NEXT_TO_CODE
#define RET_LBL(f) f##_info
#else
#define RET_LBL(f) f##_ret
#endif
#ifdef TABLES_NEXT_TO_CODE
#define ENTRY_LBL(f) f##_info
#else
#define ENTRY_LBL(f) f##_entry
#endif
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Byte/word macros Byte/word macros
...@@ -320,26 +331,26 @@ ...@@ -320,26 +331,26 @@
Constants. Constants.
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#include "Constants.h" #include "rts/Constants.h"
#include "DerivedConstants.h" #include "DerivedConstants.h"
#include "ClosureTypes.h" #include "rts/storage/ClosureTypes.h"
#include "StgFun.h" #include "rts/storage/FunTypes.h"
#include "OSThreads.h" #include "rts/storage/SMPClosureOps.h"
#include "SMPClosureOps.h" #include "rts/OSThreads.h"
/* /*
* Need MachRegs, because some of the RTS code is conditionally * Need MachRegs, because some of the RTS code is conditionally
* compiled based on REG_R1, REG_R2, etc. * compiled based on REG_R1, REG_R2, etc.
*/ */
#define STOLEN_X86_REGS 4 #define STOLEN_X86_REGS 4
#include "MachRegs.h" #include "stg/MachRegs.h"
#include "Liveness.h" #include "rts/storage/Liveness.h"
#include "StgLdvProf.h" #include "rts/prof/LDV.h"
#undef BLOCK_SIZE #undef BLOCK_SIZE
#undef MBLOCK_SIZE #undef MBLOCK_SIZE
#include "Block.h" /* For Bdescr() */ #include "rts/storage/Block.h" /* For Bdescr() */
#define MyCapability() (BaseReg - OFFSET_Capability_r) #define MyCapability() (BaseReg - OFFSET_Capability_r)
......
This diff is collapsed.
...@@ -18,8 +18,7 @@ extern "C" { ...@@ -18,8 +18,7 @@ extern "C" {
/* get types from GHC's runtime system */ /* get types from GHC's runtime system */
#include "ghcconfig.h" #include "ghcconfig.h"
#include "RtsConfig.h" #include "stg/Types.h"
#include "StgTypes.h"
/* get limits for integral types */ /* get limits for integral types */
#ifdef HAVE_STDINT_H #ifdef HAVE_STDINT_H
...@@ -84,10 +83,7 @@ typedef StgDouble HsDouble; ...@@ -84,10 +83,7 @@ typedef StgDouble HsDouble;
typedef StgInt HsBool; typedef StgInt HsBool;
typedef void* HsPtr; /* this should better match StgAddr */ typedef void* HsPtr; /* this should better match StgAddr */
typedef void (*HsFunPtr)(void); /* this should better match StgAddr */ typedef void (*HsFunPtr)(void); /* this should better match StgAddr */
typedef void* HsForeignPtr; /* ... and this StgForeignPtr */
typedef void* HsStablePtr; typedef void* HsStablePtr;
typedef void* HsAddr; /* DEPRECATED */
typedef void* HsForeignObj; /* DEPRECATED */
/* this should correspond to the type of StgChar in StgTypes.h */ /* this should correspond to the type of StgChar in StgTypes.h */
#define HS_CHAR_MIN 0 #define HS_CHAR_MIN 0
......
...@@ -58,9 +58,6 @@ ...@@ -58,9 +58,6 @@
#define SIZEOF_HSFUNPTR SIZEOF_VOID_P #define SIZEOF_HSFUNPTR SIZEOF_VOID_P
#define ALIGNMENT_HSFUNPTR ALIGNMENT_VOID_P #define ALIGNMENT_HSFUNPTR ALIGNMENT_VOID_P
#define SIZEOF_HSFOREIGNPTR SIZEOF_VOID_P
#define ALIGNMENT_HSFOREIGNPTR ALIGNMENT_VOID_P
#define SIZEOF_HSSTABLEPTR SIZEOF_VOID_P #define SIZEOF_HSSTABLEPTR SIZEOF_VOID_P
#define ALIGNMENT_HSSTABLEPTR ALIGNMENT_VOID_P #define ALIGNMENT_HSSTABLEPTR ALIGNMENT_VOID_P
......
This diff is collapsed.
...@@ -83,17 +83,14 @@ Rts.h ...@@ -83,17 +83,14 @@ Rts.h
SpinLock.h SpinLock.h
TSO.h TSO.h
Updates.h /* macros for performing updates */ Updates.h /* macros for performing updates */
GranSim.h
Parallel.h Parallel.h
Block.h Block.h
Stable.h Stable.h
Hooks.h Hooks.h
Signals.h Signals.h
DNInvoke.h Adjustor.h /* foreign import "wrapper", aka adjustors */
Dotnet.h StgPrimFloat.h /* primitive floating-point operations */
RtsExternal.h /* decls for RTS things required by .hc code */ Hpc.h
(RtsAPI.h)
(HsFFI.h)
Cmm.h /* included into .cmm source only */ Cmm.h /* included into .cmm source only */
DerivedConstants.h /* generated by mkDerivedConstants.c from other */ DerivedConstants.h /* generated by mkDerivedConstants.c from other */
...