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 "config.h" /* generated by configure */
10 #include "StgMachDeps.h"
14 /* our own ASSERT macro (for C) */
16 #define NDEBUG 1 /* for assert.h */
17 #define ASSERT(predicate) /*nothing*/
20 #undef NDEBUG /* for assert.h */
22 void _stgAssert PROTO((char *, unsigned int));
24 #define ASSERT(predicate) \
28 _stgAssert(__FILE__, __LINE__)
32 #define NON_POSIX_SOURCE
35 /* If _NEXT_SOURCE is defined, certain header files make more
36 * constants visible to us.
37 * Perhaps it would have been wise, also to define NON_POSIX_SOURCE.
38 * Things seemed to work better without it however, so I have not
39 * done it. Nevertheless we do the signal stuff in a NON_POSIX way,
43 #ifdef nextstep3_TARGET_OS
49 #include <sys/select.h>
52 #ifdef NON_POSIX_SOURCE
54 #undef _POSIX_C_SOURCE
56 # ifndef aix_TARGET_OS
57 /* already defined on aix */
58 #define _POSIX_SOURCE 1
60 #ifndef irix_TARGET_OS
61 #define _POSIX_C_SOURCE 199301L
63 /* defines contributed by Tomasz Cholewo <tjchol01@mecca.spd.louisville.edu>
64 ( this is with gcc-2.7.2 for irix-6.{2.3} ) .. hopefully they will not
65 upset anything under irix5 ..
67 #define _POSIX_C_SOURCE 199309L
68 #define __EXTENSIONS__
70 /* Bogus use of non-existent variable POSIX_C_SOURCE in the supplied header files
71 for gcc-2.7.1 on Solaris forces us to define it: (this strikes when using st_atime
72 and friends in <sys/stat.h> )
75 #if (__GNUC__ == 2) && (__GNUC_MINOR__ == 7)
76 /* sigh, not possible to get at bugfix release number (fixed in 2.7.2) */
77 #define POSIX_C_SOURCE _POSIX_C_SOURCE
84 /* these are all ANSI C headers */
93 /* hack: though the following are defined in the ANSI C library,
94 they may not be defined in a systems stdio.h (Suns, for example).
95 GCC is schizophrenic about whether it adds these into its
96 own headers for you; so we have no choice but to throw them in.
98 int fclose PROTO((FILE *));
99 int fflush PROTO((FILE *));
100 int fgetc PROTO((FILE *));
101 int fprintf PROTO((FILE *, const char *, ...));
102 int fputc PROTO((int, FILE *));
103 int fputs PROTO((const char *, FILE *));
104 size_t fread PROTO((void *, size_t, size_t, FILE *));
105 int fscanf PROTO((FILE *, const char *, ...));
106 int fseek PROTO((FILE *, long int, int));
107 size_t fwrite PROTO((const void *, size_t, size_t, FILE *));
108 void perror PROTO((const char *));
109 int printf PROTO((const char *, ...));
110 int puts PROTO((const char *));
111 int remove PROTO((const char *));
112 int rename PROTO((const char *, const char *));
113 void rewind PROTO((FILE *));
114 int scanf PROTO((const char *, ...));
115 void setbuf PROTO((FILE *, char *));
116 int setvbuf PROTO((FILE *, char *, int, size_t));
117 int sscanf PROTO((const char *, const char *, ...));
119 #endif /* STDC_HEADERS */
121 #if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
122 /* "stdlib.h" should have defined these; but at least
123 on SunOS 4.1.3, this is not so.
125 #define EXIT_SUCCESS 0
126 #define EXIT_FAILURE 1
129 /* Make sure that *some* register map is defined */
130 #ifdef __STG_GCC_REGS__
131 # if !(defined(NULL_REG_MAP) || defined(FLUSH_REG_MAP) || defined(MAIN_REG_MAP) \
132 || defined(MARK_REG_MAP) || defined(SCAN_REG_MAP) || defined(SCAV_REG_MAP))
133 yikes! no register map defined!
137 /* Make sure that *some* garbage-collector is expected; GCap is the default */
138 #if !(defined(GCap) || defined(GC2s) || defined(GC1s) || defined(GCdu) || defined(GCgn))
145 #define IF_RTS(x) /*nothing*/
148 /* GNU multi-precision arith */
151 /* typedefs for the basic entities */
152 #include "StgTypes.h"
154 /* constants about the system known to *everybody* (compiler & RTS) */
155 #include "GhcConstants.h"
157 /* macros to deal with stacks (no longer heap) growing in either dirn */
158 #include "StgDirections.h"
160 /* declarations for all the runtime flags for the RTS */
162 #include "RtsFlags.h"
164 /* and those that are visible *everywhere* (RTS + Haskell code) */
167 W_ doUpdEntryCounts; /* if true, we cannot short-circuit Inds,
168 common-up {Int,Char}Likes or Consts
171 W_ dummy_entry; /* so there is *something* in it... */
173 extern struct ALL_FLAGS AllFlags;
175 /* declarations for garbage collection routines */
176 #include "SMinterface.h"
178 /* Macros for declaring "registers" and other Optimising stuff */
179 #include "COptJumps.h"
180 #include "COptRegs.h"
181 #include "COptWraps.h"
183 /* these will come into play if you use -DTICKY_TICKY (default: off) */
186 hash_t hash_str PROTO((char *str));
187 hash_t hash_fixed PROTO((char *data, I_ len));
189 /* ullong (64bit) formatting */
190 char *ullong_format_string PROTO((ullong x, char *s, rtsBool with_commas));
192 /* declarations of macros for "high-level instructions" */
193 #include "StgMacros.h"
195 /* You always need these */
198 /* You need these if you are using the threads package or a parallel machine... */
200 #include "Parallel.h"
202 /* Things will happen in here if the driver does -DPROFILING */
203 #include "CostCentre.h"
205 /* GRAN and PAR stuff */
208 #if defined(PROFILING) || defined(CONCURRENT)
209 char * time_str(STG_NO_ARGS);
212 /* declarations for runtime-system entry points */
213 void miniInterpret PROTO((StgFunPtr));
214 void miniInterpret_debug PROTO(( StgFunPtr, void(*)(STG_NO_ARGS) ));
215 void miniInterpretEnd(STG_NO_ARGS);
217 /* UNUSED -- SOF 9/97
218 StgFunPtr evaluateMain(STG_NO_ARGS);
219 StgFunPtr returnMain(STG_NO_ARGS);
220 StgFunPtr impossible_jump_after_switch(STG_NO_ARGS);
223 /* error handling for IO implementation*/
224 extern int ghc_errno;
225 extern int ghc_errtype;
226 extern char *ghc_errstr;
228 void cvtErrno (void);
229 void stdErrno (void);
231 /* hooks: user might write some of their own */
232 void ErrorHdrHook PROTO((StgInt));
233 void OutOfHeapHook PROTO((W_, W_));
234 void OnExitHook (STG_NO_ARGS);
235 void StackOverflowHook PROTO((I_));
237 int NoRunnableThreadsHook (STG_NO_ARGS);
239 void MallocFailHook PROTO((I_, char *));
240 void PatErrorHdrHook PROTO((StgInt));
241 void PreTraceHook PROTO((StgInt));
242 void PostTraceHook PROTO((StgInt));
243 void defaultsHook (STG_NO_ARGS);
244 void initEachPEHook (STG_NO_ARGS);
245 void IOErrorHdrHook PROTO((StgInt));
247 EXTFUN(startStgWorld);
249 EXTFUN(CheckHeapCode);
251 EXTFUN(resumeThread);
254 extern char **prog_argv; /* from runtime/main/main.lc */
255 extern int prog_argc;
256 extern char **environ; /* we can get this one straight */
258 EXTDATA(STK_STUB_closure);
260 /* now these really *DO* need to be somewhere else... */
261 char *time_str(STG_NO_ARGS);
262 I_ stg_exit PROTO((I_));
263 I_ _stg_rem PROTO((I_, I_));
264 char *stgMallocBytes PROTO((I_, char *));
265 char *stgMallocWords PROTO((I_, char *));
267 /* definitions for closures */
268 #include "SMClosures.h"
270 /* definitions for info tables */
271 #include "SMInfoTables.h"
273 /* declarations for Update & Indirection stuff */
274 #include "SMupdate.h"
276 /* declarations for runtime flags/values */
277 #define MAX_RTS_ARGS 32
279 /* Saving and restoring registers */
284 * threadWaitWrite# uses FD_SETSIZE to distinguish
285 * between read file descriptors and write fd's.
286 * Hence we need to include <sys/types.h>, but
287 * is this the best place to do it?
288 * (the following has been moved from libposix.h)
291 #ifdef HAVE_SYS_TYPES_H
292 #include <sys/types.h>
293 #endif /* HAVE_SYS_TYPES_H */
297 # define FD_SETSIZE __FD_SETSIZE
299 # define FD_SETSIZE 1024
303 #endif /* ! STGDEFS_H */