1 /* -----------------------------------------------------------------------------
2 * $Id: Stg.h,v 1.44 2001/12/06 10:00:01 sewardj Exp $
4 * (c) The GHC Team, 1998-1999
6 * Top-level include file for everything STG-ish.
8 * This file is included *automatically* by all .hc files.
10 * ---------------------------------------------------------------------------*/
16 /* If we include "Stg.h" directly, we're in STG code, and we therefore
17 * get all the global register variables, macros etc. that go along
18 * with that. If "Stg.h" is included via "Rts.h", we're assumed to
22 # define IN_STG_CODE 1
27 # define NO_REGS /* don't define fixed registers */
35 /* Assume that a flexible array member at the end of a struct
36 * can be defined thus: T arr[]; */
37 #define FLEXIBLE_ARRAY
39 /* Assume that it must be defined thus: T arr[0]; */
40 #define FLEXIBLE_ARRAY 0
43 /* Some macros to handle DLLing (Win32 only at the moment). */
46 /* Fix for mingw stat problem (done here so it's early enough) */
47 #ifdef mingw32_TARGET_OS
51 /* Turn lazy blackholing and eager blackholing on/off.
53 * Using eager blackholing makes things easier to debug because
54 * the blackholes are more predictable - but it's slower and less sexy.
56 * For now, do lazy and not eager.
59 /* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of
60 * single-entry thunks.
62 * SMP needs EAGER_BLACKHOLING because it has to lock thunks
63 * synchronously, in case another thread is trying to evaluate the
64 * same thunk simultaneously.
66 #if defined(SMP) || defined(TICKY_TICKY)
67 # define EAGER_BLACKHOLING
69 # define LAZY_BLACKHOLING
75 /* TABLES_NEXT_TO_CODE says whether to assume that info tables are
76 * assumed to reside just before the code for a function.
78 * UNDEFINING THIS WON'T WORK ON ITS OWN. You have been warned.
80 #ifndef USE_MINIINTERPRETER
81 #define TABLES_NEXT_TO_CODE
86 #define BITS_PER_BYTE 8
87 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
89 /* -----------------------------------------------------------------------------
90 Assertions and Debuggery
91 -------------------------------------------------------------------------- */
94 #define ASSERT(predicate) /* nothing */
97 void _stgAssert (char *, unsigned int);
99 #define ASSERT(predicate) \
103 _stgAssert(__FILE__, __LINE__)
107 * Use this on the RHS of macros which expand to nothing
108 * to make sure that the macro can be used in a context which
109 * demands a non-empty statement.
112 #define doNothing() do { } while (0)
114 /* -----------------------------------------------------------------------------
115 Global type definitions
116 -------------------------------------------------------------------------- */
118 #include "StgTypes.h"
119 #include "RtsTypes.h"
121 /* -----------------------------------------------------------------------------
123 -------------------------------------------------------------------------- */
131 typedef const StgWord* D_;
132 typedef StgFunPtr F_;
133 typedef StgByteArray B_;
134 typedef StgClosurePtr L_;
136 typedef StgInt64 LI_;
137 typedef StgWord64 LW_;
140 * We often want to know the size of something in units of an
141 * StgWord... (rounded up, of course!)
144 #define sizeofW(t) ((sizeof(t)+sizeof(W_)-1)/sizeof(W_))
147 * It's nice to be able to grep for casts
150 #define stgCast(ty,e) ((ty)(e))
152 /* -----------------------------------------------------------------------------
153 Include everything STG-ish
154 -------------------------------------------------------------------------- */
156 /* Global constaints */
157 #include "Constants.h"
159 /* Profiling information */
161 #include "StgLdvProf.h"
163 /* Storage format definitions */
164 #include "Closures.h"
165 #include "ClosureTypes.h"
166 #include "InfoTables.h"
169 /* Simulated-parallel information */
172 /* Parallel information */
173 #include "Parallel.h"
175 /* STG/Optimised-C related stuff */
177 #include "MachRegs.h"
179 #include "TailCalls.h"
182 /* RTS public interface */
185 /* these are all ANSI C headers */
208 /* Storage Manager */
209 #include "StgStorage.h"
211 /* Macros for STG/C code */
212 #include "ClosureMacros.h"
213 #include "InfoMacros.h"
214 #include "StgMacros.h"
217 #include "StgTicky.h"
221 /* Built-in entry points */
222 #include "StgMiscClosures.h"
224 /* Runtime-system hooks */
229 /* Misc stuff without a home */
230 DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */
231 DLL_IMPORT_RTS extern int prog_argc;
233 extern void stackOverflow(void);
235 /* Creating and destroying an adjustor thunk.
236 I cannot make myself create a separate .h file
240 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
241 extern void freeHaskellFunctionPtr(void* ptr);