[project @ 1999-03-02 19:44:07 by sof]
[ghc-hetmet.git] / ghc / includes / Stg.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Stg.h,v 1.7 1999/03/02 19:44:17 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 /* 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 /* ToDo: Set this flag properly: COMPILER and INTERPRETER should not be mutually exclusive. */
26 #ifndef INTERPRETER
27 #define COMPILER 1
28 #endif
29
30 /* This is a feature test - doesn't belong here. FixMe. */
31 #ifdef __MINGW32__
32 #define HAVE_WIN32_DLL_SUPPORT
33 #endif
34
35 #ifdef HAVE_WIN32_DLL_SUPPORT
36 # if __GNUC__ && !defined(__declspec)
37 #  define DLLIMPORT
38 # else
39 #  define DLLIMPORT __declspec(dllimport)
40 #  define DLLIMPORT_DATA(x) _imp__##x
41 # endif
42 #else
43 # define DLLIMPORT
44 #endif
45
46 #ifdef COMPILING_RTS
47 #define DLL_IMPORT DLLIMPORT
48 #define DLL_IMPORT_RTS
49 #define DLL_IMPORT_DATA
50 #define DLL_IMPORT_DATA_VAR(x) x
51 #else
52 #define DLL_IMPORT
53 #define DLL_IMPORT_RTS DLLIMPORT
54 #define DLL_IMPORT_DATA DLLIMPORT
55 #define DLL_IMPORT_DATA_VAR(x) _imp__##x
56 #endif
57
58 /* bit macros
59  */
60 #define BITS_PER_BYTE 8
61 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
62
63 /* -----------------------------------------------------------------------------
64    Assertions and Debuggery
65    -------------------------------------------------------------------------- */
66
67 #ifndef DEBUG
68 #define ASSERT(predicate) /* nothing */
69 #else
70
71 void _stgAssert (char *, unsigned int);
72
73 #define ASSERT(predicate)                       \
74         if (predicate)                          \
75             /*null*/;                           \
76         else                                    \
77             _stgAssert(__FILE__, __LINE__)
78 #endif /* DEBUG */
79
80 /* -----------------------------------------------------------------------------
81    Include everything STG-ish
82    -------------------------------------------------------------------------- */
83
84 /* Global type definitions*/
85 #include "StgTypes.h"
86
87 /* Global constaints */
88 #include "Constants.h"
89
90 /* Profiling information */
91 #include "Profiling.h"
92
93 /* Storage format definitions */
94 #include "Closures.h"
95 #include "InfoTables.h"
96 #include "TSO.h"
97
98 /* STG/Optimised-C related stuff */
99 #include "MachRegs.h"
100 #include "Regs.h"
101 #include "TailCalls.h"
102
103 /**
104  * Added by Ian McDonald 7/5/98 
105  * XXX The position of this code is very
106  * important - it must come after the 
107  * Regs.h include
108  **/
109 #ifdef nemesis_TARGET_OS
110 #define _NEMESIS_OS_
111 #ifndef __LANGUAGE_C
112 #define __LANGUAGE_C
113 #endif
114 #include <nemesis.h>
115 #endif
116
117 /* these are all ANSI C headers */
118 #include <stdlib.h>
119 #include <string.h>
120 #include <math.h>
121 #include <assert.h>
122 #include <errno.h>
123 #include <stdio.h>
124
125 #ifdef HAVE_SIGNAL_H
126 #include <signal.h>
127 #endif
128
129 #ifdef HAVE_UNISTD_H
130 #include <unistd.h>
131 #endif
132
133 /* GNU mp library */
134 #include "gmp.h"
135
136 /* Wired-in Prelude identifiers */
137 #include "Prelude.h"
138
139 /* Storage Manager */
140 #include "StgStorage.h"
141
142 /* Macros for STG/C code */
143 #include "ClosureMacros.h"
144 #include "InfoMacros.h"
145 #include "StgMacros.h"
146 #include "StgProf.h"
147 #include "PrimOps.h"
148 #include "Updates.h"
149 #include "StgTicky.h"
150 #include "CCall.h"
151 #include "Stable.h"
152
153 /* Built-in entry points */
154 #include "StgMiscClosures.h"
155
156 /* Runtime-system hooks */
157 #include "Hooks.h"
158
159 /* Misc stuff without a home */
160 #ifdef BUILDING_RTS_DLL
161 extern DLLIMPORT char **prog_argv;      /* so we can get at these from Haskell */
162 extern DLLIMPORT int    prog_argc;
163 #else
164 extern char **prog_argv;        /* so we can get at these from Haskell */
165 extern int    prog_argc;
166 #endif
167
168 extern char **environ;
169
170 /* Creating and destroying an adjustor thunk.
171    I cannot make myself create a separate .h file
172    for these two (sof.)
173 */
174 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
175 extern void  freeHaskellFunctionPtr(void* ptr);
176
177 #endif /* STG_H */