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
50 #include <sys/select.h>
53 #ifdef NON_POSIX_SOURCE
55 #undef _POSIX_C_SOURCE
57 # ifndef aix_TARGET_OS
58 /* already defined on aix */
59 #define _POSIX_SOURCE 1
61 #ifndef irix_TARGET_OS
62 #define _POSIX_C_SOURCE 199301L
64 /* defines contributed by Tomasz Cholewo <tjchol01@mecca.spd.louisville.edu>
65 ( this is with gcc-2.7.2 for irix-6.{2.3} ) .. hopefully they will not
66 upset anything under irix5 ..
68 #define _POSIX_C_SOURCE 199309L
69 #define __EXTENSIONS__
71 /* Bogus use of non-existent variable POSIX_C_SOURCE in the supplied header files
72 for gcc-2.7.1 on Solaris forces us to define it: (this strikes when using st_atime
73 and friends in <sys/stat.h> )
76 #if (__GNUC__ == 2) && (__GNUC_MINOR__ == 7)
77 /* sigh, not possible to get at bugfix release number (fixed in 2.7.2) */
78 #define POSIX_C_SOURCE _POSIX_C_SOURCE
85 /* these are all ANSI C headers */
94 /* hack: though the following are defined in the ANSI C library,
95 they may not be defined in a systems stdio.h (Suns, for example).
96 GCC is schizophrenic about whether it adds these into its
97 own headers for you; so we have no choice but to throw them in.
99 int fclose PROTO((FILE *));
100 int fflush PROTO((FILE *));
101 int fgetc PROTO((FILE *));
102 int fprintf PROTO((FILE *, const char *, ...));
103 int fputc PROTO((int, FILE *));
104 int fputs PROTO((const char *, FILE *));
105 size_t fread PROTO((void *, size_t, size_t, FILE *));
106 int fscanf PROTO((FILE *, const char *, ...));
107 int fseek PROTO((FILE *, long int, int));
108 size_t fwrite PROTO((const void *, size_t, size_t, FILE *));
109 void perror PROTO((const char *));
110 int printf PROTO((const char *, ...));
111 int puts PROTO((const char *));
112 int remove PROTO((const char *));
113 int rename PROTO((const char *, const char *));
114 void rewind PROTO((FILE *));
115 int scanf PROTO((const char *, ...));
116 void setbuf PROTO((FILE *, char *));
117 int setvbuf PROTO((FILE *, char *, int, size_t));
118 int sscanf PROTO((const char *, const char *, ...));
120 #endif /* STDC_HEADERS */
122 #if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
123 /* "stdlib.h" should have defined these; but at least
124 on SunOS 4.1.3, this is not so.
126 #define EXIT_SUCCESS 0
127 #define EXIT_FAILURE 1
130 /* Make sure that *some* register map is defined */
131 #ifdef __STG_GCC_REGS__
132 # if !(defined(NULL_REG_MAP) || defined(FLUSH_REG_MAP) || defined(MAIN_REG_MAP) \
133 || defined(MARK_REG_MAP) || defined(SCAN_REG_MAP) || defined(SCAV_REG_MAP))
134 yikes! no register map defined!
138 /* Make sure that *some* garbage-collector is expected; GCap is the default */
139 #if !(defined(GCap) || defined(GC2s) || defined(GC1s) || defined(GCdu) || defined(GCgn))
146 #define IF_RTS(x) /*nothing*/
149 /* GNU multi-precision arith */
152 /* typedefs for the basic entities */
153 #include "StgTypes.h"
155 /* constants about the system known to *everybody* (compiler & RTS) */
156 #include "GhcConstants.h"
158 /* macros to deal with stacks (no longer heap) growing in either dirn */
159 #include "StgDirections.h"
161 /* declarations for all the runtime flags for the RTS */
163 #include "RtsFlags.h"
165 /* and those that are visible *everywhere* (RTS + Haskell code) */
168 W_ doUpdEntryCounts; /* if true, we cannot short-circuit Inds,
169 common-up {Int,Char}Likes or Consts
172 W_ dummy_entry; /* so there is *something* in it... */
174 extern struct ALL_FLAGS AllFlags;
176 /* declarations for garbage collection routines */
177 #include "SMinterface.h"
179 /* Macros for declaring "registers" and other Optimising stuff */
180 #include "COptJumps.h"
181 #include "COptRegs.h"
182 #include "COptWraps.h"
184 /* these will come into play if you use -DTICKY_TICKY (default: off) */
187 hash_t hash_str PROTO((char *str));
188 hash_t hash_fixed PROTO((char *data, I_ len));
190 /* ullong (64bit) formatting */
191 char *ullong_format_string PROTO((ullong x, char *s, rtsBool with_commas));
193 /* declarations of macros for "high-level instructions" */
194 #include "StgMacros.h"
196 /* You always need these */
199 /* You need these if you are using the threads package or a parallel machine... */
201 #include "Parallel.h"
203 /* Things will happen in here if the driver does -DPROFILING */
204 #include "CostCentre.h"
206 /* GRAN and PAR stuff */
209 #if defined(PROFILING) || defined(CONCURRENT)
210 char * time_str(STG_NO_ARGS);
213 /* declarations for runtime-system entry points */
214 void miniInterpret PROTO((StgFunPtr));
215 void miniInterpret_debug PROTO(( StgFunPtr, void(*)(STG_NO_ARGS) ));
216 void miniInterpretEnd(STG_NO_ARGS);
218 /* UNUSED -- SOF 9/97
219 StgFunPtr evaluateMain(STG_NO_ARGS);
220 StgFunPtr returnMain(STG_NO_ARGS);
221 StgFunPtr impossible_jump_after_switch(STG_NO_ARGS);
224 /* hooks: user might write some of their own */
225 void ErrorHdrHook PROTO((FILE *));
226 void OutOfHeapHook PROTO((W_, W_));
227 void StackOverflowHook PROTO((I_));
229 int NoRunnableThreadsHook (STG_NO_ARGS);
231 void MallocFailHook PROTO((I_, char *));
232 void PatErrorHdrHook PROTO((FILE *));
233 void PreTraceHook PROTO((FILE *));
234 void PostTraceHook PROTO((FILE *));
235 void defaultsHook (STG_NO_ARGS);
236 void initEachPEHook (STG_NO_ARGS);
238 EXTFUN(startStgWorld);
240 EXTFUN(CheckHeapCode);
242 EXTFUN(resumeThread);
245 extern char **prog_argv; /* from runtime/main/main.lc */
246 extern int prog_argc;
247 extern char **environ; /* we can get this one straight */
249 EXTDATA(STK_STUB_closure);
251 /* now these really *DO* need to be somewhere else... */
252 char *time_str(STG_NO_ARGS);
253 I_ stg_exit PROTO((I_));
254 I_ _stg_rem PROTO((I_, I_));
255 char *stgMallocBytes PROTO((I_, char *));
256 char *stgMallocWords PROTO((I_, char *));
258 /* definitions for closures */
259 #include "SMClosures.h"
261 /* definitions for info tables */
262 #include "SMInfoTables.h"
264 /* declarations for Update & Indirection stuff */
265 #include "SMupdate.h"
267 /* declarations for runtime flags/values */
268 #define MAX_RTS_ARGS 32
270 /* Saving and restoring registers */
275 * threadWaitWrite# uses FD_SETSIZE to distinguish
276 * between read file descriptors and write fd's.
277 * Hence we need to include <sys/types.h>, but
278 * is this the best place to do it?
279 * (the following has been moved from libposix.h)
282 #ifdef HAVE_SYS_TYPES_H
283 #include <sys/types.h>
284 #endif /* HAVE_SYS_TYPES_H */
288 # define FD_SETSIZE __FD_SETSIZE
290 # define FD_SETSIZE 1024
294 #endif /* ! STGDEFS_H */