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