1 /* -----------------------------------------------------------------------------
2 * $Id: Stg.h,v 1.34 2000/12/04 12:31:20 simonmar 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 * ---------------------------------------------------------------------------*/
15 #ifndef NON_POSIX_SOURCE
16 #define _POSIX_SOURCE 1
17 #define _POSIX_C_SOURCE 199309L
18 #define _ISOC9X_SOURCE
21 /* Let's be ISO C9X too... */
23 /* If we include "Stg.h" directly, we're in STG code, and we therefore
24 * get all the global register variables, macros etc. that go along
25 * with that. If "Stg.h" is included via "Rts.h", we're assumed to
29 # define IN_STG_CODE 1
34 # define NO_REGS /* don't define fixed registers */
40 #ifdef __HUGS__ /* vile hack till the GHC folks come on board */
44 /* Some macros to handle DLLing (Win32 only at the moment). */
47 /* Turn lazy blackholing and eager blackholing on/off.
49 * Using eager blackholing makes things easier to debug because
50 * the blackholes are more predictable - but it's slower and less sexy.
52 * For now, do lazy and not eager.
55 /* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of
56 * single-entry thunks.
58 * SMP needs EAGER_BLACKHOLING because it has to lock thunks
59 * synchronously, in case another thread is trying to evaluate the
60 * same thunk simultaneously.
62 #if defined(SMP) || defined(TICKY_TICKY)
63 # define EAGER_BLACKHOLING
65 # define LAZY_BLACKHOLING
68 /* ToDo: Set this flag properly: COMPILER and INTERPRETER should not be mutually exclusive. */
73 /* TABLES_NEXT_TO_CODE says whether to assume that info tables are
74 * assumed to reside just before the code for a function.
76 * UNDEFINING THIS WON'T WORK ON ITS OWN. You have been warned.
78 #ifndef USE_MINIINTERPRETER
79 #define TABLES_NEXT_TO_CODE
84 #define BITS_PER_BYTE 8
85 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
87 /* -----------------------------------------------------------------------------
88 Assertions and Debuggery
89 -------------------------------------------------------------------------- */
92 #define ASSERT(predicate) /* nothing */
95 void _stgAssert (char *, unsigned int);
97 #define ASSERT(predicate) \
101 _stgAssert(__FILE__, __LINE__)
104 /* -----------------------------------------------------------------------------
105 Global type definitions
106 -------------------------------------------------------------------------- */
108 #include "StgTypes.h"
109 #include "RtsTypes.h"
111 /* -----------------------------------------------------------------------------
113 -------------------------------------------------------------------------- */
121 typedef const StgWord* D_;
122 typedef StgFunPtr F_;
123 typedef StgByteArray B_;
124 typedef StgClosurePtr L_;
126 typedef StgInt64 LI_;
127 typedef StgWord64 LW_;
130 * We often want to know the size of something in units of an
131 * StgWord... (rounded up, of course!)
134 #define sizeofW(t) ((sizeof(t)+sizeof(W_)-1)/sizeof(W_))
137 * It's nice to be able to grep for casts
140 #define stgCast(ty,e) ((ty)(e))
142 /* -----------------------------------------------------------------------------
143 Include everything STG-ish
144 -------------------------------------------------------------------------- */
146 /* Global constaints */
147 #include "Constants.h"
149 /* Profiling information */
152 /* Storage format definitions */
153 #include "Closures.h"
154 #include "ClosureTypes.h"
155 #include "InfoTables.h"
158 /* Simulated-parallel information */
161 /* Parallel information */
162 #include "Parallel.h"
164 /* STG/Optimised-C related stuff */
166 #include "MachRegs.h"
168 #include "TailCalls.h"
171 /* RTS public interface */
174 /* these are all ANSI C headers */
197 /* Storage Manager */
198 #include "StgStorage.h"
200 /* Macros for STG/C code */
201 #include "ClosureMacros.h"
202 #include "InfoMacros.h"
203 #include "StgMacros.h"
206 #include "StgTicky.h"
210 /* Built-in entry points */
211 #include "StgMiscClosures.h"
213 /* Runtime-system hooks */
218 /* Misc stuff without a home */
219 DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */
220 DLL_IMPORT_RTS extern int prog_argc;
222 extern char **environ;
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);