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 #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 #ifdef NON_POSIX_SOURCE
38 #undef _POSIX_C_SOURCE
40 #define _POSIX_SOURCE 1
41 #define _POSIX_C_SOURCE 199301L
46 /* these are all ANSI C headers */
55 /* hack: though the following are defined in the ANSI C library,
56 they may not be defined in a systems stdio.h (Suns, for example).
57 GCC is schizophrenic about whether it adds these into its
58 own headers for you; so we have no choice but to throw them in.
60 extern int fclose PROTO((FILE *));
61 extern int fflush PROTO((FILE *));
62 extern int fgetc PROTO((FILE *));
63 /* extern int fgetpos PROTO((FILE *, fpos_t *)); */
64 extern int fprintf PROTO((FILE *, const char *, ...));
65 extern int fputc PROTO((int, FILE *));
66 extern int fputs PROTO((const char *, FILE *));
67 extern size_t fread PROTO((void *, size_t, size_t, FILE *));
68 extern int fscanf PROTO((FILE *, const char *, ...));
69 extern int fseek PROTO((FILE *, long int, int));
70 /* extern int fsetpos PROTO((FILE *, const fpos_t *)); */
71 extern size_t fwrite PROTO((const void *, size_t, size_t, FILE *));
72 extern void perror PROTO((const char *));
73 extern int printf PROTO((const char *, ...));
74 extern int puts PROTO((const char *));
75 extern int remove PROTO((const char *));
76 extern int rename PROTO((const char *, const char *));
77 extern void rewind PROTO((FILE *));
78 extern int scanf PROTO((const char *, ...));
79 extern void setbuf PROTO((FILE *, char *));
80 extern int setvbuf PROTO((FILE *, char *, int, size_t));
81 extern int sscanf PROTO((const char *, const char *, ...));
83 #endif /* STDC_HEADERS */
85 #if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
86 /* "stdlib.h" should have defined these; but at least
87 on SunOS 4.1.3, this is not so.
89 #define EXIT_SUCCESS 0
90 #define EXIT_FAILURE 1
93 /* Make sure that *some* register map is defined */
94 #ifdef __STG_GCC_REGS__
95 # if !(defined(NULL_REG_MAP) || defined(FLUSH_REG_MAP) || defined(MAIN_REG_MAP) \
96 || defined(MARK_REG_MAP) || defined(SCAN_REG_MAP) || defined(SCAV_REG_MAP))
97 yikes! no register map defined!
101 /* Make sure that *some* garbage-collector is expected; GCap is the default */
102 #if !(defined(GCap) || defined(GC2s) || defined(GC1s) || defined(GCdu) || defined(GCgn))
109 #define IF_RTS(x) /*nothing*/
112 /* GNU multi-precision arith */
115 /* typedefs for the basic entities */
116 #include "StgTypes.h"
118 /* constants about the system known to *everybody* (compiler & RTS) */
119 #include "GhcConstants.h"
121 /* macros to deal with stacks (no longer heap) growing in either dirn */
122 #include "StgDirections.h"
124 /* declarations for garbage collection routines */
125 #include "SMinterface.h"
127 /* Macros for declaring "registers" and other Optimising stuff */
128 #include "COptJumps.h"
129 #include "COptRegs.h"
130 #include "COptWraps.h"
132 /* these will come into play if you use -DDO_RUNTIME_PROFILING (default: off) */
133 #include "RednCounts.h"
135 extern hash_t hash_str PROTO((char *str));
136 extern hash_t hash_fixed PROTO((char *data, I_ len));
137 extern I_ decode PROTO((char *s));
139 /* ullong (64bit) formatting */
140 char *ullong_format_string PROTO((ullong x, char *s, rtsBool with_commas));
142 /* declarations of macros for "high-level instructions" */
143 #include "StgMacros.h"
145 /* You always need these */
148 /* You need these if you are using the threads package or a parallel machine... */
150 #include "Parallel.h"
152 /* Things will happen in here if the driver does -DUSE_COST_CENTRES */
153 #include "CostCentre.h"
155 /* These will come into play if you use -DLIFE_PROFILE or -DHEAP_PROF_WITH_AGE */
156 #include "AgeProfile.h"
158 /* These will come into play if you use -DFORCE_GC */
159 #include "Force_GC.h"
161 /* GRAN and PAR stuff */
164 #if defined(USE_COST_CENTRES) || defined(CONCURRENT)
165 char * time_str(STG_NO_ARGS);
168 /* declarations for runtime-system entry points */
169 extern void miniInterpret PROTO((StgFunPtr));
170 extern void miniInterpret_debug PROTO(( StgFunPtr, void(*)(STG_NO_ARGS) ));
171 extern void miniInterpretEnd(STG_NO_ARGS);
173 extern StgFunPtr evaluateMain(STG_NO_ARGS);
174 extern StgFunPtr returnMain(STG_NO_ARGS);
175 extern StgFunPtr impossible_jump_after_switch(STG_NO_ARGS);
177 /* hooks: user might write some of their own */
178 extern void ErrorHdrHook PROTO((FILE *));
179 extern void OutOfHeapHook PROTO((W_, W_));
180 extern void StackOverflowHook PROTO((I_));
181 extern void MallocFailHook PROTO((I_));
182 extern void PatErrorHdrHook PROTO((FILE *));
183 extern void PreTraceHook PROTO((FILE *));
184 extern void PostTraceHook PROTO((FILE *));
186 EXTFUN(startStgWorld);
188 EXTFUN(CheckHeapCode);
190 EXTFUN(resumeThread);
193 extern char **prog_argv; /* from runtime/main/main.lc */
195 extern char **environ; /* we can get this one straight */
197 EXTDATA(STK_STUB_closure);
199 /* now these really *DO* need to be somewhere else... */
200 extern char *time_str(STG_NO_ARGS);
201 extern I_ stg_exit PROTO((I_));
202 extern I_ _stg_rem PROTO((I_, I_));
204 /* definitions for closures */
205 #include "SMClosures.h"
207 /* definitions for info tables */
208 #include "SMInfoTables.h"
210 /* declarations for Update & Indirection stuff */
211 #include "SMupdate.h"
213 /* declarations for runtime flags/values */
214 #define MAX_RTS_ARGS 32
216 /* Saving and restoring registers */
219 #endif /* ! STGDEFS_H */