1 /* -----------------------------------------------------------------------------
2 * $Id: Stg.h,v 1.56 2003/09/21 13:22:01 igloo 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 */
39 /* This needs to be up near the top as the register line on alpha needs
40 * to be before all procedures */
41 #include "TailCalls.h"
44 /* Assume that a flexible array member at the end of a struct
45 * can be defined thus: T arr[]; */
46 #define FLEXIBLE_ARRAY
48 /* Assume that it must be defined thus: T arr[0]; */
49 #define FLEXIBLE_ARRAY 0
52 #if defined(SMP) || defined(THREADED_RTS)
53 #define RTS_SUPPORTS_THREADS 1
56 /* Some macros to handle DLLing (Win32 only at the moment). */
59 /* Fix for mingw stat problem (done here so it's early enough) */
60 #ifdef mingw32_TARGET_OS
64 /* Turn lazy blackholing and eager blackholing on/off.
66 * Using eager blackholing makes things easier to debug because
67 * the blackholes are more predictable - but it's slower and less sexy.
69 * For now, do lazy and not eager.
72 /* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of
73 * single-entry thunks.
75 * SMP needs EAGER_BLACKHOLING because it has to lock thunks
76 * synchronously, in case another thread is trying to evaluate the
77 * same thunk simultaneously.
79 #if defined(SMP) || defined(TICKY_TICKY)
80 # define EAGER_BLACKHOLING
82 # define LAZY_BLACKHOLING
85 /* TABLES_NEXT_TO_CODE says whether to assume that info tables are
86 * assumed to reside just before the code for a function.
88 * UNDEFINING THIS WON'T WORK ON ITS OWN. You have been warned.
90 #if !defined(USE_MINIINTERPRETER) && !defined(ia64_TARGET_ARCH)
91 #define TABLES_NEXT_TO_CODE
96 #define BITS_PER_BYTE 8
97 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
99 /* -----------------------------------------------------------------------------
100 Assertions and Debuggery
101 -------------------------------------------------------------------------- */
104 #define ASSERT(predicate) /* nothing */
107 void _stgAssert (char *, unsigned int);
109 #define ASSERT(predicate) \
113 _stgAssert(__FILE__, __LINE__)
117 * Use this on the RHS of macros which expand to nothing
118 * to make sure that the macro can be used in a context which
119 * demands a non-empty statement.
122 #define doNothing() do { } while (0)
124 /* -----------------------------------------------------------------------------
125 Global type definitions
126 -------------------------------------------------------------------------- */
128 #include "StgTypes.h"
129 #include "RtsTypes.h"
131 /* -----------------------------------------------------------------------------
133 -------------------------------------------------------------------------- */
141 typedef const StgWord* D_;
142 typedef StgFunPtr F_;
143 typedef StgByteArray B_;
144 typedef StgClosurePtr L_;
146 typedef StgInt64 LI_;
147 typedef StgWord64 LW_;
150 * We often want to know the size of something in units of an
151 * StgWord... (rounded up, of course!)
154 #define sizeofW(t) ((sizeof(t)+sizeof(W_)-1)/sizeof(W_))
157 * It's nice to be able to grep for casts
160 #define stgCast(ty,e) ((ty)(e))
162 /* -----------------------------------------------------------------------------
163 Include everything STG-ish
164 -------------------------------------------------------------------------- */
166 /* Global constaints */
167 #include "Constants.h"
169 /* Profiling information */
171 #include "StgLdvProf.h"
173 /* Storage format definitions */
175 #include "Closures.h"
176 #include "ClosureTypes.h"
177 #include "InfoTables.h"
180 /* Simulated-parallel information */
183 /* Parallel information */
184 #include "Parallel.h"
186 /* STG/Optimised-C related stuff */
188 #include "MachRegs.h"
192 /* RTS public interface */
195 /* System headers: stdlib.h is eeded so that we can use NULL. It must
196 * come after MachRegs.h, because stdlib.h might define some inline
197 * functions which may only be defined after register variables have
209 /* Storage Manager */
210 #include "StgStorage.h"
212 /* Macros for STG/C code */
213 #include "ClosureMacros.h"
214 #include "InfoMacros.h"
215 #include "StgMacros.h"
218 #include "StgTicky.h"
222 /* Built-in entry points */
223 #include "StgMiscClosures.h"
225 /* Runtime-system hooks */
232 /* Misc stuff without a home */
233 DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */
234 DLL_IMPORT_RTS extern int prog_argc;
235 DLL_IMPORT_RTS extern char *prog_name;
237 extern void stackOverflow(void);
239 #if defined(WANT_DOTNET_SUPPORT)
240 #include "DNInvoke.h"
243 /* Creating and destroying an adjustor thunk.
244 I cannot make myself create a separate .h file
248 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
249 extern void freeHaskellFunctionPtr(void* ptr);