1 /* -----------------------------------------------------------------------------
2 * $Id: Stg.h,v 1.35 2001/02/09 13:09:17 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 */
41 /* Some macros to handle DLLing (Win32 only at the moment). */
44 /* Turn lazy blackholing and eager blackholing on/off.
46 * Using eager blackholing makes things easier to debug because
47 * the blackholes are more predictable - but it's slower and less sexy.
49 * For now, do lazy and not eager.
52 /* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of
53 * single-entry thunks.
55 * SMP needs EAGER_BLACKHOLING because it has to lock thunks
56 * synchronously, in case another thread is trying to evaluate the
57 * same thunk simultaneously.
59 #if defined(SMP) || defined(TICKY_TICKY)
60 # define EAGER_BLACKHOLING
62 # define LAZY_BLACKHOLING
68 /* TABLES_NEXT_TO_CODE says whether to assume that info tables are
69 * assumed to reside just before the code for a function.
71 * UNDEFINING THIS WON'T WORK ON ITS OWN. You have been warned.
73 #ifndef USE_MINIINTERPRETER
74 #define TABLES_NEXT_TO_CODE
79 #define BITS_PER_BYTE 8
80 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
82 /* -----------------------------------------------------------------------------
83 Assertions and Debuggery
84 -------------------------------------------------------------------------- */
87 #define ASSERT(predicate) /* nothing */
90 void _stgAssert (char *, unsigned int);
92 #define ASSERT(predicate) \
96 _stgAssert(__FILE__, __LINE__)
99 /* -----------------------------------------------------------------------------
100 Global type definitions
101 -------------------------------------------------------------------------- */
103 #include "StgTypes.h"
104 #include "RtsTypes.h"
106 /* -----------------------------------------------------------------------------
108 -------------------------------------------------------------------------- */
116 typedef const StgWord* D_;
117 typedef StgFunPtr F_;
118 typedef StgByteArray B_;
119 typedef StgClosurePtr L_;
121 typedef StgInt64 LI_;
122 typedef StgWord64 LW_;
125 * We often want to know the size of something in units of an
126 * StgWord... (rounded up, of course!)
129 #define sizeofW(t) ((sizeof(t)+sizeof(W_)-1)/sizeof(W_))
132 * It's nice to be able to grep for casts
135 #define stgCast(ty,e) ((ty)(e))
137 /* -----------------------------------------------------------------------------
138 Include everything STG-ish
139 -------------------------------------------------------------------------- */
141 /* Global constaints */
142 #include "Constants.h"
144 /* Profiling information */
147 /* Storage format definitions */
148 #include "Closures.h"
149 #include "ClosureTypes.h"
150 #include "InfoTables.h"
153 /* Simulated-parallel information */
156 /* Parallel information */
157 #include "Parallel.h"
159 /* STG/Optimised-C related stuff */
161 #include "MachRegs.h"
163 #include "TailCalls.h"
166 /* RTS public interface */
169 /* these are all ANSI C headers */
192 /* Storage Manager */
193 #include "StgStorage.h"
195 /* Macros for STG/C code */
196 #include "ClosureMacros.h"
197 #include "InfoMacros.h"
198 #include "StgMacros.h"
201 #include "StgTicky.h"
205 /* Built-in entry points */
206 #include "StgMiscClosures.h"
208 /* Runtime-system hooks */
213 /* Misc stuff without a home */
214 DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */
215 DLL_IMPORT_RTS extern int prog_argc;
217 extern char **environ;
219 extern void stackOverflow(void);
221 /* Creating and destroying an adjustor thunk.
222 I cannot make myself create a separate .h file
226 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
227 extern void freeHaskellFunctionPtr(void* ptr);