1 /* these are the definitions included at the beginning
2 * of every compiled-to-C module
7 /* machine/compiler/system dependencies :-( Must be first! */
8 /* OLD: #include "platform.h" generated by configure */
9 #include "config.h" /* generated by configure */
11 #include "StgMachDeps.h"
15 /* our own ASSERT macro (for C) */
17 #define NDEBUG 1 /* for assert.h */
18 #define ASSERT(predicate) /*nothing*/
21 #undef NDEBUG /* for assert.h */
23 void _stgAssert PROTO((char *, unsigned int));
25 #define ASSERT(predicate) \
29 _stgAssert(__FILE__, __LINE__)
33 #define NON_POSIX_SOURCE
36 /* If _NEXT_SOURCE is defined, certain header files make more
37 * constants visible to us.
38 * Perhaps it would have been wise, also to define NON_POSIX_SOURCE.
39 * Things seemed to work better without it however, so I have not
40 * done it. Nevertheless we do the signal stuff in a NON_POSIX way,
44 #ifdef nextstep3_TARGET_OS
48 #ifdef NON_POSIX_SOURCE
50 #undef _POSIX_C_SOURCE
52 #define _POSIX_SOURCE 1
53 #define _POSIX_C_SOURCE 199301L
54 /* Alphas set _POSIX_VERSION (unistd.h) */
55 /* ditto _POSIX2_C_VERSION
60 /* Bogus use of non-existent variable POSIX_C_SOURCE in the supplied header files
61 for gcc-2.7.1 on Solaris forces us to define it: (this strikes when using st_atime
62 and friends in <sys/stat.h> )
65 #if (__GNUC__ == 2) && (__GNUC_MINOR__ == 7)
66 /* sigh, not possible to get at bugfix release number (fixed in 2.7.2) */
67 #define POSIX_C_SOURCE _POSIX_C_SOURCE
74 /* these are all ANSI C headers */
83 /* hack: though the following are defined in the ANSI C library,
84 they may not be defined in a systems stdio.h (Suns, for example).
85 GCC is schizophrenic about whether it adds these into its
86 own headers for you; so we have no choice but to throw them in.
88 int fclose PROTO((FILE *));
89 int fflush PROTO((FILE *));
90 int fgetc PROTO((FILE *));
91 int fprintf PROTO((FILE *, const char *, ...));
92 int fputc PROTO((int, FILE *));
93 int fputs PROTO((const char *, FILE *));
94 size_t fread PROTO((void *, size_t, size_t, FILE *));
95 int fscanf PROTO((FILE *, const char *, ...));
96 int fseek PROTO((FILE *, long int, int));
97 size_t fwrite PROTO((const void *, size_t, size_t, FILE *));
98 void perror PROTO((const char *));
99 int printf PROTO((const char *, ...));
100 int puts PROTO((const char *));
101 int remove PROTO((const char *));
102 int rename PROTO((const char *, const char *));
103 void rewind PROTO((FILE *));
104 int scanf PROTO((const char *, ...));
105 void setbuf PROTO((FILE *, char *));
106 int setvbuf PROTO((FILE *, char *, int, size_t));
107 int sscanf PROTO((const char *, const char *, ...));
109 #endif /* STDC_HEADERS */
111 #if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
112 /* "stdlib.h" should have defined these; but at least
113 on SunOS 4.1.3, this is not so.
115 #define EXIT_SUCCESS 0
116 #define EXIT_FAILURE 1
119 /* Make sure that *some* register map is defined */
120 #ifdef __STG_GCC_REGS__
121 # if !(defined(NULL_REG_MAP) || defined(FLUSH_REG_MAP) || defined(MAIN_REG_MAP) \
122 || defined(MARK_REG_MAP) || defined(SCAN_REG_MAP) || defined(SCAV_REG_MAP))
123 yikes! no register map defined!
127 /* Make sure that *some* garbage-collector is expected; GCap is the default */
128 #if !(defined(GCap) || defined(GC2s) || defined(GC1s) || defined(GCdu) || defined(GCgn))
135 #define IF_RTS(x) /*nothing*/
138 /* GNU multi-precision arith */
141 /* typedefs for the basic entities */
142 #include "StgTypes.h"
144 /* constants about the system known to *everybody* (compiler & RTS) */
145 #include "GhcConstants.h"
147 /* macros to deal with stacks (no longer heap) growing in either dirn */
148 #include "StgDirections.h"
150 /* declarations for all the runtime flags for the RTS */
152 #include "RtsFlags.h"
154 /* and those that are visible *everywhere* (RTS + Haskell code) */
157 W_ doUpdEntryCounts; /* if true, we cannot short-circuit Inds,
158 common-up {Int,Char}Likes or Consts
161 W_ dummy_entry; /* so there is *something* in it... */
163 extern struct ALL_FLAGS AllFlags;
165 /* declarations for garbage collection routines */
166 #include "SMinterface.h"
168 /* Macros for declaring "registers" and other Optimising stuff */
169 #include "COptJumps.h"
170 #include "COptRegs.h"
171 #include "COptWraps.h"
173 /* these will come into play if you use -DTICKY_TICKY (default: off) */
176 hash_t hash_str PROTO((char *str));
177 hash_t hash_fixed PROTO((char *data, I_ len));
179 /* ullong (64bit) formatting */
180 char *ullong_format_string PROTO((ullong x, char *s, rtsBool with_commas));
182 /* declarations of macros for "high-level instructions" */
183 #include "StgMacros.h"
185 /* You always need these */
188 /* You need these if you are using the threads package or a parallel machine... */
190 #include "Parallel.h"
192 /* Things will happen in here if the driver does -DPROFILING */
193 #include "CostCentre.h"
195 /* GRAN and PAR stuff */
198 #if defined(PROFILING) || defined(CONCURRENT)
199 char * time_str(STG_NO_ARGS);
202 /* declarations for runtime-system entry points */
203 void miniInterpret PROTO((StgFunPtr));
204 void miniInterpret_debug PROTO(( StgFunPtr, void(*)(STG_NO_ARGS) ));
205 void miniInterpretEnd(STG_NO_ARGS);
207 StgFunPtr evaluateMain(STG_NO_ARGS);
208 StgFunPtr returnMain(STG_NO_ARGS);
209 StgFunPtr impossible_jump_after_switch(STG_NO_ARGS);
211 /* hooks: user might write some of their own */
212 void ErrorHdrHook PROTO((FILE *));
213 void OutOfHeapHook PROTO((W_, W_));
214 void StackOverflowHook PROTO((I_));
216 void NoRunnableThreadsHook (STG_NO_ARGS);
218 void MallocFailHook PROTO((I_, char *));
219 void PatErrorHdrHook PROTO((FILE *));
220 void PreTraceHook PROTO((FILE *));
221 void PostTraceHook PROTO((FILE *));
222 void defaultsHook (STG_NO_ARGS);
223 void initEachPEHook (STG_NO_ARGS);
225 EXTFUN(startStgWorld);
227 EXTFUN(CheckHeapCode);
229 EXTFUN(resumeThread);
232 extern char **prog_argv; /* from runtime/main/main.lc */
233 extern int prog_argc;
234 extern char **environ; /* we can get this one straight */
236 EXTDATA(STK_STUB_closure);
238 /* now these really *DO* need to be somewhere else... */
239 char *time_str(STG_NO_ARGS);
240 I_ stg_exit PROTO((I_));
241 I_ _stg_rem PROTO((I_, I_));
242 char *stgMallocBytes PROTO((I_, char *));
243 char *stgMallocWords PROTO((I_, char *));
245 /* definitions for closures */
246 #include "SMClosures.h"
248 /* definitions for info tables */
249 #include "SMInfoTables.h"
251 /* declarations for Update & Indirection stuff */
252 #include "SMupdate.h"
254 /* declarations for runtime flags/values */
255 #define MAX_RTS_ARGS 32
257 /* Saving and restoring registers */
262 * threadWaitWrite# uses FD_SETSIZE to distinguish
263 * between read file descriptors and write fd's.
264 * Hence we need to include <sys/types.h>, but
265 * is this the best place to do it?
266 * (the following has been moved from libposix.h)
269 #ifdef HAVE_SYS_TYPES_H
270 #include <sys/types.h>
271 #endif /* HAVE_SYS_TYPES_H */
275 # define FD_SETSIZE __FD_SETSIZE
277 # define FD_SETSIZE 1024
281 #endif /* ! STGDEFS_H */