1 /* -----------------------------------------------------------------------------
2 * $Id: Stg.h,v 1.39 2001/10/27 21:44:54 sof 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__)
106 /* -----------------------------------------------------------------------------
107 Global type definitions
108 -------------------------------------------------------------------------- */
110 #include "StgTypes.h"
111 #include "RtsTypes.h"
113 /* -----------------------------------------------------------------------------
115 -------------------------------------------------------------------------- */
123 typedef const StgWord* D_;
124 typedef StgFunPtr F_;
125 typedef StgByteArray B_;
126 typedef StgClosurePtr L_;
128 typedef StgInt64 LI_;
129 typedef StgWord64 LW_;
132 * We often want to know the size of something in units of an
133 * StgWord... (rounded up, of course!)
136 #define sizeofW(t) ((sizeof(t)+sizeof(W_)-1)/sizeof(W_))
139 * It's nice to be able to grep for casts
142 #define stgCast(ty,e) ((ty)(e))
144 /* -----------------------------------------------------------------------------
145 Include everything STG-ish
146 -------------------------------------------------------------------------- */
148 /* Global constaints */
149 #include "Constants.h"
151 /* Profiling information */
154 /* Storage format definitions */
155 #include "Closures.h"
156 #include "ClosureTypes.h"
157 #include "InfoTables.h"
160 /* Simulated-parallel information */
163 /* Parallel information */
164 #include "Parallel.h"
166 /* STG/Optimised-C related stuff */
168 #include "MachRegs.h"
170 #include "TailCalls.h"
173 /* RTS public interface */
176 /* these are all ANSI C headers */
199 /* Storage Manager */
200 #include "StgStorage.h"
202 /* Macros for STG/C code */
203 #include "ClosureMacros.h"
204 #include "InfoMacros.h"
205 #include "StgMacros.h"
208 #include "StgTicky.h"
212 /* Built-in entry points */
213 #include "StgMiscClosures.h"
215 /* Runtime-system hooks */
220 /* Misc stuff without a home */
221 DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */
222 DLL_IMPORT_RTS extern int prog_argc;
224 extern void stackOverflow(void);
226 /* Creating and destroying an adjustor thunk.
227 I cannot make myself create a separate .h file
231 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
232 extern void freeHaskellFunctionPtr(void* ptr);