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 int fclose PROTO((FILE *));
66 int fflush PROTO((FILE *));
67 int fgetc PROTO((FILE *));
68 int fprintf PROTO((FILE *, const char *, ...));
69 int fputc PROTO((int, FILE *));
70 int fputs PROTO((const char *, FILE *));
71 size_t fread PROTO((void *, size_t, size_t, FILE *));
72 int fscanf PROTO((FILE *, const char *, ...));
73 int fseek PROTO((FILE *, long int, int));
74 size_t fwrite PROTO((const void *, size_t, size_t, FILE *));
75 void perror PROTO((const char *));
76 int printf PROTO((const char *, ...));
77 int puts PROTO((const char *));
78 int remove PROTO((const char *));
79 int rename PROTO((const char *, const char *));
80 void rewind PROTO((FILE *));
81 int scanf PROTO((const char *, ...));
82 void setbuf PROTO((FILE *, char *));
83 int setvbuf PROTO((FILE *, char *, int, size_t));
84 int sscanf PROTO((const char *, const char *, ...));
86 #endif /* STDC_HEADERS */
89 * threadWaitWrite# uses FD_SETSIZE to distinguish
90 * between read file descriptors and write fd's.
91 * Hence we need to include <sys/types.h>, but
92 * is this the best place to do it?
93 * (the following has been moved from libposix.h)
96 #ifdef HAVE_SYS_TYPES_H
97 #include <sys/types.h>
98 #endif /* HAVE_SYS_TYPES_H */
101 #define FD_SETSIZE 1024
104 #if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
105 /* "stdlib.h" should have defined these; but at least
106 on SunOS 4.1.3, this is not so.
108 #define EXIT_SUCCESS 0
109 #define EXIT_FAILURE 1
112 /* Make sure that *some* register map is defined */
113 #ifdef __STG_GCC_REGS__
114 # if !(defined(NULL_REG_MAP) || defined(FLUSH_REG_MAP) || defined(MAIN_REG_MAP) \
115 || defined(MARK_REG_MAP) || defined(SCAN_REG_MAP) || defined(SCAV_REG_MAP))
116 yikes! no register map defined!
120 /* Make sure that *some* garbage-collector is expected; GCap is the default */
121 #if !(defined(GCap) || defined(GC2s) || defined(GC1s) || defined(GCdu) || defined(GCgn))
128 #define IF_RTS(x) /*nothing*/
131 /* GNU multi-precision arith */
134 /* typedefs for the basic entities */
135 #include "StgTypes.h"
137 /* constants about the system known to *everybody* (compiler & RTS) */
138 #include "GhcConstants.h"
140 /* macros to deal with stacks (no longer heap) growing in either dirn */
141 #include "StgDirections.h"
143 /* declarations for all the runtime flags for the RTS */
145 #include "RtsFlags.h"
147 /* and those that are visible *everywhere* (RTS + Haskell code) */
150 W_ doUpdEntryCounts; /* if true, we cannot short-circuit Inds,
151 common-up {Int,Char}Likes or Consts
154 W_ dummy_entry; /* so there is *something* in it... */
156 extern struct ALL_FLAGS AllFlags;
158 /* declarations for garbage collection routines */
159 #include "SMinterface.h"
161 /* Macros for declaring "registers" and other Optimising stuff */
162 #include "COptJumps.h"
163 #include "COptRegs.h"
164 #include "COptWraps.h"
166 /* these will come into play if you use -DTICKY_TICKY (default: off) */
169 hash_t hash_str PROTO((char *str));
170 hash_t hash_fixed PROTO((char *data, I_ len));
172 /* ullong (64bit) formatting */
173 char *ullong_format_string PROTO((ullong x, char *s, rtsBool with_commas));
175 /* declarations of macros for "high-level instructions" */
176 #include "StgMacros.h"
178 /* You always need these */
181 /* You need these if you are using the threads package or a parallel machine... */
183 #include "Parallel.h"
185 /* Things will happen in here if the driver does -DPROFILING */
186 #include "CostCentre.h"
188 /* GRAN and PAR stuff */
191 #if defined(PROFILING) || defined(CONCURRENT)
192 char * time_str(STG_NO_ARGS);
195 /* declarations for runtime-system entry points */
196 void miniInterpret PROTO((StgFunPtr));
197 void miniInterpret_debug PROTO(( StgFunPtr, void(*)(STG_NO_ARGS) ));
198 void miniInterpretEnd(STG_NO_ARGS);
200 StgFunPtr evaluateMain(STG_NO_ARGS);
201 StgFunPtr returnMain(STG_NO_ARGS);
202 StgFunPtr impossible_jump_after_switch(STG_NO_ARGS);
204 /* hooks: user might write some of their own */
205 void ErrorHdrHook PROTO((FILE *));
206 void OutOfHeapHook PROTO((W_, W_));
207 void StackOverflowHook PROTO((I_));
209 void NoRunnableThreadsHook (STG_NO_ARGS);
211 void MallocFailHook PROTO((I_, char *));
212 void PatErrorHdrHook PROTO((FILE *));
213 void PreTraceHook PROTO((FILE *));
214 void PostTraceHook PROTO((FILE *));
215 void defaultsHook (STG_NO_ARGS);
216 void initEachPEHook (STG_NO_ARGS);
218 EXTFUN(startStgWorld);
220 EXTFUN(CheckHeapCode);
222 EXTFUN(resumeThread);
225 extern char **prog_argv; /* from runtime/main/main.lc */
226 extern int prog_argc;
227 extern char **environ; /* we can get this one straight */
229 EXTDATA(STK_STUB_closure);
231 /* now these really *DO* need to be somewhere else... */
232 char *time_str(STG_NO_ARGS);
233 I_ stg_exit PROTO((I_));
234 I_ _stg_rem PROTO((I_, I_));
235 char *stgMallocBytes PROTO((I_, char *));
236 char *stgMallocWords PROTO((I_, char *));
238 /* definitions for closures */
239 #include "SMClosures.h"
241 /* definitions for info tables */
242 #include "SMInfoTables.h"
244 /* declarations for Update & Indirection stuff */
245 #include "SMupdate.h"
247 /* declarations for runtime flags/values */
248 #define MAX_RTS_ARGS 32
250 /* Saving and restoring registers */
253 #endif /* ! STGDEFS_H */