[project @ 2000-05-26 10:14:33 by sewardj]
[ghc-hetmet.git] / ghc / includes / Stg.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Stg.h,v 1.31 2000/05/26 10:14:33 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 #ifndef NON_POSIX_SOURCE
16 #define _POSIX_SOURCE   1
17 #define _POSIX_C_SOURCE 199309L
18 #define _ISOC9X_SOURCE
19 #endif
20
21 /* Let's be ISO C9X too... */
22
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
26  * be in vanilla C.
27  */
28 #ifndef IN_STG_CODE
29 # define IN_STG_CODE 1
30 #endif
31
32 #if IN_STG_CODE == 0
33 # ifndef NO_REGS
34 #  define NO_REGS                       /* don't define fixed registers */
35 # endif
36 #endif
37
38 /* Configuration */
39 #include "config.h"
40 #ifdef __HUGS__ /* vile hack till the GHC folks come on board */
41 #include "options.h"
42 #endif
43
44 /* Some macros to handle DLLing (Win32 only at the moment). */
45 #include "StgDLL.h"
46
47 /* Turn lazy blackholing and eager blackholing on/off.
48  *
49  * Using eager blackholing makes things easier to debug because
50  * the blackholes are more predictable - but it's slower and less sexy.
51  *
52  * For now, do lazy and not eager.
53  */
54
55 /* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of
56  * single-entry thunks.
57  *
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.
61  */
62 #if defined(SMP) || defined(TICKY_TICKY)
63 #  define EAGER_BLACKHOLING
64 #else
65 #  define LAZY_BLACKHOLING
66 #endif
67
68 /* ToDo: Set this flag properly: COMPILER and INTERPRETER should not be mutually exclusive. */
69 #ifndef INTERPRETER
70 #define COMPILER 1
71 #endif
72
73 /* TABLES_NEXT_TO_CODE says whether to assume that info tables are
74  * assumed to reside just before the code for a function.
75  *
76  * UNDEFINING THIS WON'T WORK ON ITS OWN.  You have been warned.
77  */
78 #ifndef USE_MINIINTERPRETER
79 #define TABLES_NEXT_TO_CODE
80 #endif
81
82 /* bit macros
83  */
84 #define BITS_PER_BYTE 8
85 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
86
87 /* -----------------------------------------------------------------------------
88    Assertions and Debuggery
89    -------------------------------------------------------------------------- */
90
91 #ifndef DEBUG
92 #define ASSERT(predicate) /* nothing */
93 #else
94
95 void _stgAssert (char *, unsigned int);
96
97 #define ASSERT(predicate)                       \
98         if (predicate)                          \
99             /*null*/;                           \
100         else                                    \
101             _stgAssert(__FILE__, __LINE__)
102 #endif /* DEBUG */
103
104 /* -----------------------------------------------------------------------------
105    Include everything STG-ish
106    -------------------------------------------------------------------------- */
107
108 /* Global type definitions*/
109 #include "StgTypes.h"
110 #include "RtsTypes.h"
111
112 /* Global constaints */
113 #include "Constants.h"
114
115 /* Profiling information */
116 #include "StgProf.h"
117
118 /* Storage format definitions */
119 #include "Closures.h"
120 #include "ClosureTypes.h"
121 #include "InfoTables.h"
122 #include "TSO.h"
123
124 /* Simulated-parallel information */
125 #include "GranSim.h"
126
127 /* Parallel information */
128 #include "Parallel.h"
129
130 /* STG/Optimised-C related stuff */
131 #include "SMP.h"
132 #include "MachRegs.h"
133 #include "Regs.h"
134 #include "TailCalls.h"
135 #include "Block.h"
136
137 /* RTS public interface */
138 #include "RtsAPI.h"
139
140 /* these are all ANSI C headers */
141 #include <stdlib.h>
142 #include <string.h>
143 #include <math.h>
144 #include <assert.h>
145 #include <errno.h>
146 #include <stdio.h>
147
148 #ifdef HAVE_SIGNAL_H
149 #include <signal.h>
150 #endif
151
152 #ifdef HAVE_UNISTD_H
153 #include <unistd.h>
154 #endif
155
156 #ifdef SMP
157 #include <pthread.h>
158 #endif
159
160 /* GNU mp library */
161 #include "gmp.h"
162
163 /* Storage Manager */
164 #include "StgStorage.h"
165
166 /* Macros for STG/C code */
167 #include "ClosureMacros.h"
168 #include "InfoMacros.h"
169 #include "StgMacros.h"
170 #include "PrimOps.h"
171 #include "Updates.h"
172 #include "StgTicky.h"
173 #include "CCall.h"
174 #include "Stable.h"
175
176 /* Built-in entry points */
177 #include "StgMiscClosures.h"
178
179 /* Runtime-system hooks */
180 #include "Hooks.h"
181
182 /* Misc stuff without a home */
183 DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */
184 DLL_IMPORT_RTS extern int    prog_argc;
185
186 extern char **envyron;
187
188 extern void stackOverflow(void);
189
190 /* Creating and destroying an adjustor thunk.
191    I cannot make myself create a separate .h file
192    for these two (sof.) 
193    
194 */
195 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
196 extern void  freeHaskellFunctionPtr(void* ptr);
197
198 #endif /* STG_H */