1 /* -----------------------------------------------------------------------------
2 * $Id: Stg.h,v 1.37 2001/08/14 13:40:08 sewardj 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 */
34 /* Some macros to handle DLLing (Win32 only at the moment). */
37 /* Fix for mingw stat problem (done here so it's early enough) */
38 #ifdef mingw32_TARGET_OS
42 /* Turn lazy blackholing and eager blackholing on/off.
44 * Using eager blackholing makes things easier to debug because
45 * the blackholes are more predictable - but it's slower and less sexy.
47 * For now, do lazy and not eager.
50 /* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of
51 * single-entry thunks.
53 * SMP needs EAGER_BLACKHOLING because it has to lock thunks
54 * synchronously, in case another thread is trying to evaluate the
55 * same thunk simultaneously.
57 #if defined(SMP) || defined(TICKY_TICKY)
58 # define EAGER_BLACKHOLING
60 # define LAZY_BLACKHOLING
66 /* TABLES_NEXT_TO_CODE says whether to assume that info tables are
67 * assumed to reside just before the code for a function.
69 * UNDEFINING THIS WON'T WORK ON ITS OWN. You have been warned.
71 #ifndef USE_MINIINTERPRETER
72 #define TABLES_NEXT_TO_CODE
77 #define BITS_PER_BYTE 8
78 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
80 /* -----------------------------------------------------------------------------
81 Assertions and Debuggery
82 -------------------------------------------------------------------------- */
85 #define ASSERT(predicate) /* nothing */
88 void _stgAssert (char *, unsigned int);
90 #define ASSERT(predicate) \
94 _stgAssert(__FILE__, __LINE__)
97 /* -----------------------------------------------------------------------------
98 Global type definitions
99 -------------------------------------------------------------------------- */
101 #include "StgTypes.h"
102 #include "RtsTypes.h"
104 /* -----------------------------------------------------------------------------
106 -------------------------------------------------------------------------- */
114 typedef const StgWord* D_;
115 typedef StgFunPtr F_;
116 typedef StgByteArray B_;
117 typedef StgClosurePtr L_;
119 typedef StgInt64 LI_;
120 typedef StgWord64 LW_;
123 * We often want to know the size of something in units of an
124 * StgWord... (rounded up, of course!)
127 #define sizeofW(t) ((sizeof(t)+sizeof(W_)-1)/sizeof(W_))
130 * It's nice to be able to grep for casts
133 #define stgCast(ty,e) ((ty)(e))
135 /* -----------------------------------------------------------------------------
136 Include everything STG-ish
137 -------------------------------------------------------------------------- */
139 /* Global constaints */
140 #include "Constants.h"
142 /* Profiling information */
145 /* Storage format definitions */
146 #include "Closures.h"
147 #include "ClosureTypes.h"
148 #include "InfoTables.h"
151 /* Simulated-parallel information */
154 /* Parallel information */
155 #include "Parallel.h"
157 /* STG/Optimised-C related stuff */
159 #include "MachRegs.h"
161 #include "TailCalls.h"
164 /* RTS public interface */
167 /* these are all ANSI C headers */
190 /* Storage Manager */
191 #include "StgStorage.h"
193 /* Macros for STG/C code */
194 #include "ClosureMacros.h"
195 #include "InfoMacros.h"
196 #include "StgMacros.h"
199 #include "StgTicky.h"
203 /* Built-in entry points */
204 #include "StgMiscClosures.h"
206 /* Runtime-system hooks */
211 /* Misc stuff without a home */
212 DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */
213 DLL_IMPORT_RTS extern int prog_argc;
215 extern char **environ;
217 extern void stackOverflow(void);
219 /* Creating and destroying an adjustor thunk.
220 I cannot make myself create a separate .h file
224 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
225 extern void freeHaskellFunctionPtr(void* ptr);