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