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 #ifndef irix_TARGET_OS
54 #define _POSIX_C_SOURCE 199301L
56 /* defines contributed by Tomasz Cholewo <tjchol01@mecca.spd.louisville.edu>
57 ( this is with gcc-2.7.2 for irix-6.{2.3} ) .. hopefully they will not
58 upset anything under irix5 ..
60 #define _POSIX_C_SOURCE 199309L
61 #define __EXTENSIONS__
63 /* Bogus use of non-existent variable POSIX_C_SOURCE in the supplied header files
64 for gcc-2.7.1 on Solaris forces us to define it: (this strikes when using st_atime
65 and friends in <sys/stat.h> )
68 #if (__GNUC__ == 2) && (__GNUC_MINOR__ == 7)
69 /* sigh, not possible to get at bugfix release number (fixed in 2.7.2) */
70 #define POSIX_C_SOURCE _POSIX_C_SOURCE
77 /* these are all ANSI C headers */
86 /* hack: though the following are defined in the ANSI C library,
87 they may not be defined in a systems stdio.h (Suns, for example).
88 GCC is schizophrenic about whether it adds these into its
89 own headers for you; so we have no choice but to throw them in.
91 int fclose PROTO((FILE *));
92 int fflush PROTO((FILE *));
93 int fgetc PROTO((FILE *));
94 int fprintf PROTO((FILE *, const char *, ...));
95 int fputc PROTO((int, FILE *));
96 int fputs PROTO((const char *, FILE *));
97 size_t fread PROTO((void *, size_t, size_t, FILE *));
98 int fscanf PROTO((FILE *, const char *, ...));
99 int fseek PROTO((FILE *, long int, int));
100 size_t fwrite PROTO((const void *, size_t, size_t, FILE *));
101 void perror PROTO((const char *));
102 int printf PROTO((const char *, ...));
103 int puts PROTO((const char *));
104 int remove PROTO((const char *));
105 int rename PROTO((const char *, const char *));
106 void rewind PROTO((FILE *));
107 int scanf PROTO((const char *, ...));
108 void setbuf PROTO((FILE *, char *));
109 int setvbuf PROTO((FILE *, char *, int, size_t));
110 int sscanf PROTO((const char *, const char *, ...));
112 #endif /* STDC_HEADERS */
114 #if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
115 /* "stdlib.h" should have defined these; but at least
116 on SunOS 4.1.3, this is not so.
118 #define EXIT_SUCCESS 0
119 #define EXIT_FAILURE 1
122 /* Make sure that *some* register map is defined */
123 #ifdef __STG_GCC_REGS__
124 # if !(defined(NULL_REG_MAP) || defined(FLUSH_REG_MAP) || defined(MAIN_REG_MAP) \
125 || defined(MARK_REG_MAP) || defined(SCAN_REG_MAP) || defined(SCAV_REG_MAP))
126 yikes! no register map defined!
130 /* Make sure that *some* garbage-collector is expected; GCap is the default */
131 #if !(defined(GCap) || defined(GC2s) || defined(GC1s) || defined(GCdu) || defined(GCgn))
138 #define IF_RTS(x) /*nothing*/
141 /* GNU multi-precision arith */
144 /* typedefs for the basic entities */
145 #include "StgTypes.h"
147 /* constants about the system known to *everybody* (compiler & RTS) */
148 #include "GhcConstants.h"
150 /* macros to deal with stacks (no longer heap) growing in either dirn */
151 #include "StgDirections.h"
153 /* declarations for all the runtime flags for the RTS */
155 #include "RtsFlags.h"
157 /* and those that are visible *everywhere* (RTS + Haskell code) */
160 W_ doUpdEntryCounts; /* if true, we cannot short-circuit Inds,
161 common-up {Int,Char}Likes or Consts
164 W_ dummy_entry; /* so there is *something* in it... */
166 extern struct ALL_FLAGS AllFlags;
168 /* declarations for garbage collection routines */
169 #include "SMinterface.h"
171 /* Macros for declaring "registers" and other Optimising stuff */
172 #include "COptJumps.h"
173 #include "COptRegs.h"
174 #include "COptWraps.h"
176 /* these will come into play if you use -DTICKY_TICKY (default: off) */
179 hash_t hash_str PROTO((char *str));
180 hash_t hash_fixed PROTO((char *data, I_ len));
182 /* ullong (64bit) formatting */
183 char *ullong_format_string PROTO((ullong x, char *s, rtsBool with_commas));
185 /* declarations of macros for "high-level instructions" */
186 #include "StgMacros.h"
188 /* You always need these */
191 /* You need these if you are using the threads package or a parallel machine... */
193 #include "Parallel.h"
195 /* Things will happen in here if the driver does -DPROFILING */
196 #include "CostCentre.h"
198 /* GRAN and PAR stuff */
201 #if defined(PROFILING) || defined(CONCURRENT)
202 char * time_str(STG_NO_ARGS);
205 /* declarations for runtime-system entry points */
206 void miniInterpret PROTO((StgFunPtr));
207 void miniInterpret_debug PROTO(( StgFunPtr, void(*)(STG_NO_ARGS) ));
208 void miniInterpretEnd(STG_NO_ARGS);
210 StgFunPtr evaluateMain(STG_NO_ARGS);
211 StgFunPtr returnMain(STG_NO_ARGS);
212 StgFunPtr impossible_jump_after_switch(STG_NO_ARGS);
214 /* hooks: user might write some of their own */
215 void ErrorHdrHook PROTO((FILE *));
216 void OutOfHeapHook PROTO((W_, W_));
217 void StackOverflowHook PROTO((I_));
219 void NoRunnableThreadsHook (STG_NO_ARGS);
221 void MallocFailHook PROTO((I_, char *));
222 void PatErrorHdrHook PROTO((FILE *));
223 void PreTraceHook PROTO((FILE *));
224 void PostTraceHook PROTO((FILE *));
225 void defaultsHook (STG_NO_ARGS);
226 void initEachPEHook (STG_NO_ARGS);
228 EXTFUN(startStgWorld);
230 EXTFUN(CheckHeapCode);
232 EXTFUN(resumeThread);
235 extern char **prog_argv; /* from runtime/main/main.lc */
236 extern int prog_argc;
237 extern char **environ; /* we can get this one straight */
239 EXTDATA(STK_STUB_closure);
241 /* now these really *DO* need to be somewhere else... */
242 char *time_str(STG_NO_ARGS);
243 I_ stg_exit PROTO((I_));
244 I_ _stg_rem PROTO((I_, I_));
245 char *stgMallocBytes PROTO((I_, char *));
246 char *stgMallocWords PROTO((I_, char *));
248 /* definitions for closures */
249 #include "SMClosures.h"
251 /* definitions for info tables */
252 #include "SMInfoTables.h"
254 /* declarations for Update & Indirection stuff */
255 #include "SMupdate.h"
257 /* declarations for runtime flags/values */
258 #define MAX_RTS_ARGS 32
260 /* Saving and restoring registers */
265 * threadWaitWrite# uses FD_SETSIZE to distinguish
266 * between read file descriptors and write fd's.
267 * Hence we need to include <sys/types.h>, but
268 * is this the best place to do it?
269 * (the following has been moved from libposix.h)
272 #ifdef HAVE_SYS_TYPES_H
273 #include <sys/types.h>
274 #endif /* HAVE_SYS_TYPES_H */
278 # define FD_SETSIZE __FD_SETSIZE
280 # define FD_SETSIZE 1024
284 #endif /* ! STGDEFS_H */