1 /* -----------------------------------------------------------------------------
2 * $Id: Stg.h,v 1.52 2003/05/29 14:39:30 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 * 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
81 /* TABLES_NEXT_TO_CODE says whether to assume that info tables are
82 * assumed to reside just before the code for a function.
84 * UNDEFINING THIS WON'T WORK ON ITS OWN. You have been warned.
86 #if !defined(USE_MINIINTERPRETER) && !defined(ia64_TARGET_ARCH)
87 #define TABLES_NEXT_TO_CODE
92 #define BITS_PER_BYTE 8
93 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
95 /* -----------------------------------------------------------------------------
96 Assertions and Debuggery
97 -------------------------------------------------------------------------- */
100 #define ASSERT(predicate) /* nothing */
103 void _stgAssert (char *, unsigned int);
105 #define ASSERT(predicate) \
109 _stgAssert(__FILE__, __LINE__)
113 * Use this on the RHS of macros which expand to nothing
114 * to make sure that the macro can be used in a context which
115 * demands a non-empty statement.
118 #define doNothing() do { } while (0)
120 /* -----------------------------------------------------------------------------
121 Global type definitions
122 -------------------------------------------------------------------------- */
124 #include "StgTypes.h"
125 #include "RtsTypes.h"
127 /* -----------------------------------------------------------------------------
129 -------------------------------------------------------------------------- */
137 typedef const StgWord* D_;
138 typedef StgFunPtr F_;
139 typedef StgByteArray B_;
140 typedef StgClosurePtr L_;
142 typedef StgInt64 LI_;
143 typedef StgWord64 LW_;
146 * We often want to know the size of something in units of an
147 * StgWord... (rounded up, of course!)
150 #define sizeofW(t) ((sizeof(t)+sizeof(W_)-1)/sizeof(W_))
153 * It's nice to be able to grep for casts
156 #define stgCast(ty,e) ((ty)(e))
158 /* -----------------------------------------------------------------------------
159 Include everything STG-ish
160 -------------------------------------------------------------------------- */
162 /* Global constaints */
163 #include "Constants.h"
165 /* Profiling information */
167 #include "StgLdvProf.h"
169 /* Storage format definitions */
171 #include "Closures.h"
172 #include "ClosureTypes.h"
173 #include "InfoTables.h"
176 /* Simulated-parallel information */
179 /* Parallel information */
180 #include "Parallel.h"
182 /* STG/Optimised-C related stuff */
184 #include "MachRegs.h"
186 #include "TailCalls.h"
189 /* RTS public interface */
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 */
222 /* Misc stuff without a home */
223 DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */
224 DLL_IMPORT_RTS extern int prog_argc;
226 extern void stackOverflow(void);
228 #if defined(WANT_DOTNET_SUPPORT)
229 #include "DNInvoke.h"
232 /* Creating and destroying an adjustor thunk.
233 I cannot make myself create a separate .h file
237 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
238 extern void freeHaskellFunctionPtr(void* ptr);