[project @ 2001-08-14 13:40:07 by sewardj]
[ghc-hetmet.git] / ghc / includes / Stg.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Stg.h,v 1.37 2001/08/14 13:40:08 sewardj Exp $
3  *
4  * (c) The GHC Team, 1998-1999
5  *
6  * Top-level include file for everything STG-ish.  
7  *
8  * This file is included *automatically* by all .hc files.
9  *
10  * ---------------------------------------------------------------------------*/
11
12 #ifndef STG_H
13 #define STG_H
14
15
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
19  * be in vanilla C.
20  */
21 #ifndef IN_STG_CODE
22 # define IN_STG_CODE 1
23 #endif
24
25 #if IN_STG_CODE == 0
26 # ifndef NO_REGS
27 #  define NO_REGS                       /* don't define fixed registers */
28 # endif
29 #endif
30
31 /* Configuration */
32 #include "config.h"
33
34 /* Some macros to handle DLLing (Win32 only at the moment). */
35 #include "StgDLL.h"
36
37 /* Fix for mingw stat problem (done here so it's early enough) */
38 #ifdef mingw32_TARGET_OS
39 #define __MSVCRT__ 1
40 #endif
41
42 /* Turn lazy blackholing and eager blackholing on/off.
43  *
44  * Using eager blackholing makes things easier to debug because
45  * the blackholes are more predictable - but it's slower and less sexy.
46  *
47  * For now, do lazy and not eager.
48  */
49
50 /* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of
51  * single-entry thunks.
52  *
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.
56  */
57 #if defined(SMP) || defined(TICKY_TICKY)
58 #  define EAGER_BLACKHOLING
59 #else
60 #  define LAZY_BLACKHOLING
61 #endif
62
63 /* ToDo: remove */
64 #define COMPILER 1
65
66 /* TABLES_NEXT_TO_CODE says whether to assume that info tables are
67  * assumed to reside just before the code for a function.
68  *
69  * UNDEFINING THIS WON'T WORK ON ITS OWN.  You have been warned.
70  */
71 #ifndef USE_MINIINTERPRETER
72 #define TABLES_NEXT_TO_CODE
73 #endif
74
75 /* bit macros
76  */
77 #define BITS_PER_BYTE 8
78 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
79
80 /* -----------------------------------------------------------------------------
81    Assertions and Debuggery
82    -------------------------------------------------------------------------- */
83
84 #ifndef DEBUG
85 #define ASSERT(predicate) /* nothing */
86 #else
87
88 void _stgAssert (char *, unsigned int);
89
90 #define ASSERT(predicate)                       \
91         if (predicate)                          \
92             /*null*/;                           \
93         else                                    \
94             _stgAssert(__FILE__, __LINE__)
95 #endif /* DEBUG */
96
97 /* -----------------------------------------------------------------------------
98    Global type definitions
99    -------------------------------------------------------------------------- */
100
101 #include "StgTypes.h"
102 #include "RtsTypes.h"
103
104 /* -----------------------------------------------------------------------------
105    Shorthand forms
106    -------------------------------------------------------------------------- */
107
108 typedef StgChar         C_;
109 typedef StgWord         W_;
110 typedef StgWord*        P_;
111 typedef P_*             PP_;
112 typedef StgInt          I_;
113 typedef StgAddr         A_;
114 typedef const StgWord*  D_;
115 typedef StgFunPtr       F_;
116 typedef StgByteArray    B_;
117 typedef StgClosurePtr   L_;
118
119 typedef StgInt64        LI_;
120 typedef StgWord64       LW_;
121
122 /*
123  * We often want to know the size of something in units of an
124  * StgWord... (rounded up, of course!)
125  */
126
127 #define sizeofW(t) ((sizeof(t)+sizeof(W_)-1)/sizeof(W_))
128
129 /* 
130  * It's nice to be able to grep for casts
131  */
132
133 #define stgCast(ty,e) ((ty)(e))
134
135 /* -----------------------------------------------------------------------------
136    Include everything STG-ish
137    -------------------------------------------------------------------------- */
138
139 /* Global constaints */
140 #include "Constants.h"
141
142 /* Profiling information */
143 #include "StgProf.h"
144
145 /* Storage format definitions */
146 #include "Closures.h"
147 #include "ClosureTypes.h"
148 #include "InfoTables.h"
149 #include "TSO.h"
150
151 /* Simulated-parallel information */
152 #include "GranSim.h"
153
154 /* Parallel information */
155 #include "Parallel.h"
156
157 /* STG/Optimised-C related stuff */
158 #include "SMP.h"
159 #include "MachRegs.h"
160 #include "Regs.h"
161 #include "TailCalls.h"
162 #include "Block.h"
163
164 /* RTS public interface */
165 #include "RtsAPI.h"
166
167 /* these are all ANSI C headers */
168 #include <stdlib.h>
169 #include <string.h>
170 #include <math.h>
171 #include <assert.h>
172 #include <errno.h>
173 #include <stdio.h>
174
175 #ifdef HAVE_SIGNAL_H
176 #include <signal.h>
177 #endif
178
179 #ifdef HAVE_UNISTD_H
180 #include <unistd.h>
181 #endif
182
183 #ifdef SMP
184 #include <pthread.h>
185 #endif
186
187 /* GNU mp library */
188 #include "gmp.h"
189
190 /* Storage Manager */
191 #include "StgStorage.h"
192
193 /* Macros for STG/C code */
194 #include "ClosureMacros.h"
195 #include "InfoMacros.h"
196 #include "StgMacros.h"
197 #include "PrimOps.h"
198 #include "Updates.h"
199 #include "StgTicky.h"
200 #include "CCall.h"
201 #include "Stable.h"
202
203 /* Built-in entry points */
204 #include "StgMiscClosures.h"
205
206 /* Runtime-system hooks */
207 #include "Hooks.h"
208
209 #include "HsFFI.h"
210
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;
214
215 extern char **environ;
216
217 extern void stackOverflow(void);
218
219 /* Creating and destroying an adjustor thunk.
220    I cannot make myself create a separate .h file
221    for these two (sof.) 
222    
223 */
224 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
225 extern void  freeHaskellFunctionPtr(void* ptr);
226
227 #endif /* STG_H */