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
42 /* Alphas set _POSIX_VERSION (unistd.h) */
43 /* ditto _POSIX2_C_VERSION
51 /* these are all ANSI C headers */
60 /* hack: though the following are defined in the ANSI C library,
61 they may not be defined in a systems stdio.h (Suns, for example).
62 GCC is schizophrenic about whether it adds these into its
63 own headers for you; so we have no choice but to throw them in.
65 extern int fclose PROTO((FILE *));
66 extern int fflush PROTO((FILE *));
67 extern int fgetc PROTO((FILE *));
68 /* extern int fgetpos PROTO((FILE *, fpos_t *)); */
69 extern int fprintf PROTO((FILE *, const char *, ...));
70 extern int fputc PROTO((int, FILE *));
71 extern int fputs PROTO((const char *, FILE *));
72 extern size_t fread PROTO((void *, size_t, size_t, FILE *));
73 extern int fscanf PROTO((FILE *, const char *, ...));
74 extern int fseek PROTO((FILE *, long int, int));
75 /* extern int fsetpos PROTO((FILE *, const fpos_t *)); */
76 extern size_t fwrite PROTO((const void *, size_t, size_t, FILE *));
77 extern void perror PROTO((const char *));
78 extern int printf PROTO((const char *, ...));
79 extern int puts PROTO((const char *));
80 extern int remove PROTO((const char *));
81 extern int rename PROTO((const char *, const char *));
82 extern void rewind PROTO((FILE *));
83 extern int scanf PROTO((const char *, ...));
84 extern void setbuf PROTO((FILE *, char *));
85 extern int setvbuf PROTO((FILE *, char *, int, size_t));
86 extern int sscanf PROTO((const char *, const char *, ...));
88 #endif /* STDC_HEADERS */
90 #if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
91 /* "stdlib.h" should have defined these; but at least
92 on SunOS 4.1.3, this is not so.
94 #define EXIT_SUCCESS 0
95 #define EXIT_FAILURE 1
98 /* Make sure that *some* register map is defined */
99 #ifdef __STG_GCC_REGS__
100 # if !(defined(NULL_REG_MAP) || defined(FLUSH_REG_MAP) || defined(MAIN_REG_MAP) \
101 || defined(MARK_REG_MAP) || defined(SCAN_REG_MAP) || defined(SCAV_REG_MAP))
102 yikes! no register map defined!
106 /* Make sure that *some* garbage-collector is expected; GCap is the default */
107 #if !(defined(GCap) || defined(GC2s) || defined(GC1s) || defined(GCdu) || defined(GCgn))
114 #define IF_RTS(x) /*nothing*/
117 /* GNU multi-precision arith */
120 /* typedefs for the basic entities */
121 #include "StgTypes.h"
123 /* constants about the system known to *everybody* (compiler & RTS) */
124 #include "GhcConstants.h"
126 /* macros to deal with stacks (no longer heap) growing in either dirn */
127 #include "StgDirections.h"
129 /* declarations for all the runtime flags for the RTS */
131 #include "RtsFlags.h"
133 /* and those that are visible *everywhere* (RTS + Haskell code) */
136 W_ doUpdEntryCounts; /* if true, we cannot short-circuit Inds,
137 common-up {Int,Char}Likes or Consts
140 W_ dummy_entry; /* so there is *something* in it... */
142 extern struct ALL_FLAGS AllFlags;
144 /* declarations for garbage collection routines */
145 #include "SMinterface.h"
147 /* Macros for declaring "registers" and other Optimising stuff */
148 #include "COptJumps.h"
149 #include "COptRegs.h"
150 #include "COptWraps.h"
152 /* these will come into play if you use -DTICKY_TICKY (default: off) */
155 hash_t hash_str PROTO((char *str));
156 hash_t hash_fixed PROTO((char *data, I_ len));
158 /* ullong (64bit) formatting */
159 char *ullong_format_string PROTO((ullong x, char *s, rtsBool with_commas));
161 /* declarations of macros for "high-level instructions" */
162 #include "StgMacros.h"
164 /* You always need these */
167 /* You need these if you are using the threads package or a parallel machine... */
169 #include "Parallel.h"
171 /* Things will happen in here if the driver does -DPROFILING */
172 #include "CostCentre.h"
174 /* GRAN and PAR stuff */
177 #if defined(PROFILING) || defined(CONCURRENT)
178 char * time_str(STG_NO_ARGS);
181 /* declarations for runtime-system entry points */
182 extern void miniInterpret PROTO((StgFunPtr));
183 extern void miniInterpret_debug PROTO(( StgFunPtr, void(*)(STG_NO_ARGS) ));
184 extern void miniInterpretEnd(STG_NO_ARGS);
186 extern StgFunPtr evaluateMain(STG_NO_ARGS);
187 extern StgFunPtr returnMain(STG_NO_ARGS);
188 extern StgFunPtr impossible_jump_after_switch(STG_NO_ARGS);
190 /* hooks: user might write some of their own */
191 extern void ErrorHdrHook PROTO((FILE *));
192 extern void OutOfHeapHook PROTO((W_));
193 extern void StackOverflowHook PROTO((I_));
194 extern void MallocFailHook PROTO((I_, char *));
195 extern void PatErrorHdrHook PROTO((FILE *));
196 extern void PreTraceHook PROTO((FILE *));
197 extern void PostTraceHook PROTO((FILE *));
199 EXTFUN(startStgWorld);
201 EXTFUN(CheckHeapCode);
203 EXTFUN(resumeThread);
206 extern char **prog_argv; /* from runtime/main/main.lc */
207 extern int prog_argc;
208 extern char **environ; /* we can get this one straight */
210 EXTDATA(STK_STUB_closure);
212 /* now these really *DO* need to be somewhere else... */
213 char *time_str(STG_NO_ARGS);
214 I_ stg_exit PROTO((I_));
215 I_ _stg_rem PROTO((I_, I_));
216 char *stgMallocBytes PROTO((I_, char *));
217 char *stgMallocWords PROTO((I_, char *));
219 /* definitions for closures */
220 #include "SMClosures.h"
222 /* definitions for info tables */
223 #include "SMInfoTables.h"
225 /* declarations for Update & Indirection stuff */
226 #include "SMupdate.h"
228 /* declarations for runtime flags/values */
229 #define MAX_RTS_ARGS 32
231 /* Saving and restoring registers */
234 #endif /* ! STGDEFS_H */