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