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