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
48 #ifdef NON_POSIX_SOURCE
50 #undef _POSIX_C_SOURCE
52 #define _POSIX_SOURCE 1
53 #define _POSIX_C_SOURCE 199301L
54 /* Alphas set _POSIX_VERSION (unistd.h) */
55 /* ditto _POSIX2_C_VERSION
63 /* these are all ANSI C headers */
72 /* hack: though the following are defined in the ANSI C library,
73 they may not be defined in a systems stdio.h (Suns, for example).
74 GCC is schizophrenic about whether it adds these into its
75 own headers for you; so we have no choice but to throw them in.
77 int fclose PROTO((FILE *));
78 int fflush PROTO((FILE *));
79 int fgetc PROTO((FILE *));
80 int fprintf PROTO((FILE *, const char *, ...));
81 int fputc PROTO((int, FILE *));
82 int fputs PROTO((const char *, FILE *));
83 size_t fread PROTO((void *, size_t, size_t, FILE *));
84 int fscanf PROTO((FILE *, const char *, ...));
85 int fseek PROTO((FILE *, long int, int));
86 size_t fwrite PROTO((const void *, size_t, size_t, FILE *));
87 void perror PROTO((const char *));
88 int printf PROTO((const char *, ...));
89 int puts PROTO((const char *));
90 int remove PROTO((const char *));
91 int rename PROTO((const char *, const char *));
92 void rewind PROTO((FILE *));
93 int scanf PROTO((const char *, ...));
94 void setbuf PROTO((FILE *, char *));
95 int setvbuf PROTO((FILE *, char *, int, size_t));
96 int sscanf PROTO((const char *, const char *, ...));
98 #endif /* STDC_HEADERS */
100 #if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
101 /* "stdlib.h" should have defined these; but at least
102 on SunOS 4.1.3, this is not so.
104 #define EXIT_SUCCESS 0
105 #define EXIT_FAILURE 1
108 /* Make sure that *some* register map is defined */
109 #ifdef __STG_GCC_REGS__
110 # if !(defined(NULL_REG_MAP) || defined(FLUSH_REG_MAP) || defined(MAIN_REG_MAP) \
111 || defined(MARK_REG_MAP) || defined(SCAN_REG_MAP) || defined(SCAV_REG_MAP))
112 yikes! no register map defined!
116 /* Make sure that *some* garbage-collector is expected; GCap is the default */
117 #if !(defined(GCap) || defined(GC2s) || defined(GC1s) || defined(GCdu) || defined(GCgn))
124 #define IF_RTS(x) /*nothing*/
127 /* GNU multi-precision arith */
130 /* typedefs for the basic entities */
131 #include "StgTypes.h"
133 /* constants about the system known to *everybody* (compiler & RTS) */
134 #include "GhcConstants.h"
136 /* macros to deal with stacks (no longer heap) growing in either dirn */
137 #include "StgDirections.h"
139 /* declarations for all the runtime flags for the RTS */
141 #include "RtsFlags.h"
143 /* and those that are visible *everywhere* (RTS + Haskell code) */
146 W_ doUpdEntryCounts; /* if true, we cannot short-circuit Inds,
147 common-up {Int,Char}Likes or Consts
150 W_ dummy_entry; /* so there is *something* in it... */
152 extern struct ALL_FLAGS AllFlags;
154 /* declarations for garbage collection routines */
155 #include "SMinterface.h"
157 /* Macros for declaring "registers" and other Optimising stuff */
158 #include "COptJumps.h"
159 #include "COptRegs.h"
160 #include "COptWraps.h"
162 /* these will come into play if you use -DTICKY_TICKY (default: off) */
165 hash_t hash_str PROTO((char *str));
166 hash_t hash_fixed PROTO((char *data, I_ len));
168 /* ullong (64bit) formatting */
169 char *ullong_format_string PROTO((ullong x, char *s, rtsBool with_commas));
171 /* declarations of macros for "high-level instructions" */
172 #include "StgMacros.h"
174 /* You always need these */
177 /* You need these if you are using the threads package or a parallel machine... */
179 #include "Parallel.h"
181 /* Things will happen in here if the driver does -DPROFILING */
182 #include "CostCentre.h"
184 /* GRAN and PAR stuff */
187 #if defined(PROFILING) || defined(CONCURRENT)
188 char * time_str(STG_NO_ARGS);
191 /* declarations for runtime-system entry points */
192 void miniInterpret PROTO((StgFunPtr));
193 void miniInterpret_debug PROTO(( StgFunPtr, void(*)(STG_NO_ARGS) ));
194 void miniInterpretEnd(STG_NO_ARGS);
196 StgFunPtr evaluateMain(STG_NO_ARGS);
197 StgFunPtr returnMain(STG_NO_ARGS);
198 StgFunPtr impossible_jump_after_switch(STG_NO_ARGS);
200 /* hooks: user might write some of their own */
201 void ErrorHdrHook PROTO((FILE *));
202 void OutOfHeapHook PROTO((W_, W_));
203 void StackOverflowHook PROTO((I_));
205 void NoRunnableThreadsHook (STG_NO_ARGS);
207 void MallocFailHook PROTO((I_, char *));
208 void PatErrorHdrHook PROTO((FILE *));
209 void PreTraceHook PROTO((FILE *));
210 void PostTraceHook PROTO((FILE *));
211 void defaultsHook (STG_NO_ARGS);
212 void initEachPEHook (STG_NO_ARGS);
214 EXTFUN(startStgWorld);
216 EXTFUN(CheckHeapCode);
218 EXTFUN(resumeThread);
221 extern char **prog_argv; /* from runtime/main/main.lc */
222 extern int prog_argc;
223 extern char **environ; /* we can get this one straight */
225 EXTDATA(STK_STUB_closure);
227 /* now these really *DO* need to be somewhere else... */
228 char *time_str(STG_NO_ARGS);
229 I_ stg_exit PROTO((I_));
230 I_ _stg_rem PROTO((I_, I_));
231 char *stgMallocBytes PROTO((I_, char *));
232 char *stgMallocWords PROTO((I_, char *));
234 /* definitions for closures */
235 #include "SMClosures.h"
237 /* definitions for info tables */
238 #include "SMInfoTables.h"
240 /* declarations for Update & Indirection stuff */
241 #include "SMupdate.h"
243 /* declarations for runtime flags/values */
244 #define MAX_RTS_ARGS 32
246 /* Saving and restoring registers */
251 * threadWaitWrite# uses FD_SETSIZE to distinguish
252 * between read file descriptors and write fd's.
253 * Hence we need to include <sys/types.h>, but
254 * is this the best place to do it?
255 * (the following has been moved from libposix.h)
258 #ifdef HAVE_SYS_TYPES_H
259 #include <sys/types.h>
260 #endif /* HAVE_SYS_TYPES_H */
264 # define FD_SETSIZE __FD_SETSIZE
266 # define FD_SETSIZE 1024
270 #endif /* ! STGDEFS_H */