1 /* -----------------------------------------------------------------------------
2 * $Id: Stg.h,v 1.49 2002/09/06 14:34:14 simonmar 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 * NOTE: always include Stg.h *before* any other headers, because we
11 * define some register variables which must be done before any inline
12 * functions are defined (some system headers have been known to
13 * define the odd inline function).
15 * ---------------------------------------------------------------------------*/
21 /* If we include "Stg.h" directly, we're in STG code, and we therefore
22 * get all the global register variables, macros etc. that go along
23 * with that. If "Stg.h" is included via "Rts.h", we're assumed to
27 # define IN_STG_CODE 1
32 # define NO_REGS /* don't define fixed registers */
40 /* Assume that a flexible array member at the end of a struct
41 * can be defined thus: T arr[]; */
42 #define FLEXIBLE_ARRAY
44 /* Assume that it must be defined thus: T arr[0]; */
45 #define FLEXIBLE_ARRAY 0
48 #if defined(SMP) || defined(THREADED_RTS)
49 #define RTS_SUPPORTS_THREADS 1
52 /* Some macros to handle DLLing (Win32 only at the moment). */
55 /* Fix for mingw stat problem (done here so it's early enough) */
56 #ifdef mingw32_TARGET_OS
60 /* Turn lazy blackholing and eager blackholing on/off.
62 * Using eager blackholing makes things easier to debug because
63 * the blackholes are more predictable - but it's slower and less sexy.
65 * For now, do lazy and not eager.
68 /* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of
69 * single-entry thunks.
71 * SMP needs EAGER_BLACKHOLING because it has to lock thunks
72 * synchronously, in case another thread is trying to evaluate the
73 * same thunk simultaneously.
75 #if defined(SMP) || defined(TICKY_TICKY)
76 # define EAGER_BLACKHOLING
78 # define LAZY_BLACKHOLING
84 /* TABLES_NEXT_TO_CODE says whether to assume that info tables are
85 * assumed to reside just before the code for a function.
87 * UNDEFINING THIS WON'T WORK ON ITS OWN. You have been warned.
89 #if !defined(USE_MINIINTERPRETER) && !defined(ia64_TARGET_ARCH)
90 #define TABLES_NEXT_TO_CODE
95 #define BITS_PER_BYTE 8
96 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
98 /* -----------------------------------------------------------------------------
99 Assertions and Debuggery
100 -------------------------------------------------------------------------- */
103 #define ASSERT(predicate) /* nothing */
106 void _stgAssert (char *, unsigned int);
108 #define ASSERT(predicate) \
112 _stgAssert(__FILE__, __LINE__)
116 * Use this on the RHS of macros which expand to nothing
117 * to make sure that the macro can be used in a context which
118 * demands a non-empty statement.
121 #define doNothing() do { } while (0)
123 /* -----------------------------------------------------------------------------
124 Global type definitions
125 -------------------------------------------------------------------------- */
127 #include "StgTypes.h"
128 #include "RtsTypes.h"
130 /* -----------------------------------------------------------------------------
132 -------------------------------------------------------------------------- */
140 typedef const StgWord* D_;
141 typedef StgFunPtr F_;
142 typedef StgByteArray B_;
143 typedef StgClosurePtr L_;
145 typedef StgInt64 LI_;
146 typedef StgWord64 LW_;
149 * We often want to know the size of something in units of an
150 * StgWord... (rounded up, of course!)
153 #define sizeofW(t) ((sizeof(t)+sizeof(W_)-1)/sizeof(W_))
156 * It's nice to be able to grep for casts
159 #define stgCast(ty,e) ((ty)(e))
161 /* -----------------------------------------------------------------------------
162 Include everything STG-ish
163 -------------------------------------------------------------------------- */
165 /* Global constaints */
166 #include "Constants.h"
168 /* Profiling information */
170 #include "StgLdvProf.h"
172 /* Storage format definitions */
173 #include "Closures.h"
174 #include "ClosureTypes.h"
175 #include "InfoTables.h"
178 /* Simulated-parallel information */
181 /* Parallel information */
182 #include "Parallel.h"
184 /* STG/Optimised-C related stuff */
186 #include "MachRegs.h"
188 #include "TailCalls.h"
191 /* RTS public interface */
201 /* Storage Manager */
202 #include "StgStorage.h"
204 /* Macros for STG/C code */
205 #include "ClosureMacros.h"
206 #include "InfoMacros.h"
207 #include "StgMacros.h"
210 #include "StgTicky.h"
214 /* Built-in entry points */
215 #include "StgMiscClosures.h"
217 /* Runtime-system hooks */
224 /* Misc stuff without a home */
225 DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */
226 DLL_IMPORT_RTS extern int prog_argc;
228 extern void stackOverflow(void);
230 /* Creating and destroying an adjustor thunk.
231 I cannot make myself create a separate .h file
235 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
236 extern void freeHaskellFunctionPtr(void* ptr);