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