1 /* -----------------------------------------------------------------------------
2 * $Id: Stg.h,v 1.45 2002/02/13 07:48:19 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 #if defined(SMP) || defined(THREADED_RTS)
44 #define RTS_SUPPORTS_THREADS 1
47 /* Some macros to handle DLLing (Win32 only at the moment). */
50 /* Fix for mingw stat problem (done here so it's early enough) */
51 #ifdef mingw32_TARGET_OS
55 /* Turn lazy blackholing and eager blackholing on/off.
57 * Using eager blackholing makes things easier to debug because
58 * the blackholes are more predictable - but it's slower and less sexy.
60 * For now, do lazy and not eager.
63 /* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of
64 * single-entry thunks.
66 * SMP needs EAGER_BLACKHOLING because it has to lock thunks
67 * synchronously, in case another thread is trying to evaluate the
68 * same thunk simultaneously.
70 #if defined(SMP) || defined(TICKY_TICKY)
71 # define EAGER_BLACKHOLING
73 # define LAZY_BLACKHOLING
79 /* TABLES_NEXT_TO_CODE says whether to assume that info tables are
80 * assumed to reside just before the code for a function.
82 * UNDEFINING THIS WON'T WORK ON ITS OWN. You have been warned.
84 #ifndef USE_MINIINTERPRETER
85 #define TABLES_NEXT_TO_CODE
90 #define BITS_PER_BYTE 8
91 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
93 /* -----------------------------------------------------------------------------
94 Assertions and Debuggery
95 -------------------------------------------------------------------------- */
98 #define ASSERT(predicate) /* nothing */
101 void _stgAssert (char *, unsigned int);
103 #define ASSERT(predicate) \
107 _stgAssert(__FILE__, __LINE__)
111 * Use this on the RHS of macros which expand to nothing
112 * to make sure that the macro can be used in a context which
113 * demands a non-empty statement.
116 #define doNothing() do { } while (0)
118 /* -----------------------------------------------------------------------------
119 Global type definitions
120 -------------------------------------------------------------------------- */
122 #include "StgTypes.h"
123 #include "RtsTypes.h"
125 /* -----------------------------------------------------------------------------
127 -------------------------------------------------------------------------- */
135 typedef const StgWord* D_;
136 typedef StgFunPtr F_;
137 typedef StgByteArray B_;
138 typedef StgClosurePtr L_;
140 typedef StgInt64 LI_;
141 typedef StgWord64 LW_;
144 * We often want to know the size of something in units of an
145 * StgWord... (rounded up, of course!)
148 #define sizeofW(t) ((sizeof(t)+sizeof(W_)-1)/sizeof(W_))
151 * It's nice to be able to grep for casts
154 #define stgCast(ty,e) ((ty)(e))
156 /* -----------------------------------------------------------------------------
157 Include everything STG-ish
158 -------------------------------------------------------------------------- */
160 /* Global constaints */
161 #include "Constants.h"
163 /* Profiling information */
165 #include "StgLdvProf.h"
167 /* Storage format definitions */
168 #include "Closures.h"
169 #include "ClosureTypes.h"
170 #include "InfoTables.h"
173 /* Simulated-parallel information */
176 /* Parallel information */
177 #include "Parallel.h"
179 /* STG/Optimised-C related stuff */
181 #include "MachRegs.h"
183 #include "TailCalls.h"
186 /* RTS public interface */
189 /* these are all ANSI C headers */
212 /* Storage Manager */
213 #include "StgStorage.h"
215 /* Macros for STG/C code */
216 #include "ClosureMacros.h"
217 #include "InfoMacros.h"
218 #include "StgMacros.h"
221 #include "StgTicky.h"
225 /* Built-in entry points */
226 #include "StgMiscClosures.h"
228 /* Runtime-system hooks */
233 /* Misc stuff without a home */
234 DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */
235 DLL_IMPORT_RTS extern int prog_argc;
237 extern void stackOverflow(void);
239 /* Creating and destroying an adjustor thunk.
240 I cannot make myself create a separate .h file
244 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
245 extern void freeHaskellFunctionPtr(void* ptr);