[project @ 1999-03-22 11:26:03 by simonm]
[ghc-hetmet.git] / ghc / includes / Stg.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Stg.h,v 1.9 1999/03/15 16:30:25 simonm 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 "ClosureTypes.h"
100 #include "InfoTables.h"
101 #include "TSO.h"
102
103 /* STG/Optimised-C related stuff */
104 #include "MachRegs.h"
105 #include "Regs.h"
106 #include "TailCalls.h"
107
108 /* these are all ANSI C headers */
109 #include <stdlib.h>
110 #include <string.h>
111 #include <math.h>
112 #include <assert.h>
113 #include <errno.h>
114 #include <stdio.h>
115
116 #ifdef HAVE_SIGNAL_H
117 #include <signal.h>
118 #endif
119
120 #ifdef HAVE_UNISTD_H
121 #include <unistd.h>
122 #endif
123
124 /* GNU mp library */
125 #include "gmp.h"
126
127 /* Wired-in Prelude identifiers */
128 #include "Prelude.h"
129
130 /* Storage Manager */
131 #include "StgStorage.h"
132
133 /* Macros for STG/C code */
134 #include "ClosureMacros.h"
135 #include "InfoMacros.h"
136 #include "StgMacros.h"
137 #include "StgProf.h"
138 #include "PrimOps.h"
139 #include "Updates.h"
140 #include "StgTicky.h"
141 #include "CCall.h"
142 #include "Stable.h"
143
144 /* Built-in entry points */
145 #include "StgMiscClosures.h"
146
147 /* Runtime-system hooks */
148 #include "Hooks.h"
149
150 /* Misc stuff without a home */
151 #ifdef BUILDING_RTS_DLL
152 extern DLLIMPORT char **prog_argv;      /* so we can get at these from Haskell */
153 extern DLLIMPORT int    prog_argc;
154 #else
155 extern char **prog_argv;        /* so we can get at these from Haskell */
156 extern int    prog_argc;
157 #endif
158
159 extern char **environ;
160
161 /* Creating and destroying an adjustor thunk.
162    I cannot make myself create a separate .h file
163    for these two (sof.)
164 */
165 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
166 extern void  freeHaskellFunctionPtr(void* ptr);
167
168 #endif /* STG_H */