diff options
Diffstat (limited to 'ghc/includes/stgdefs.h')
-rw-r--r-- | ghc/includes/stgdefs.h | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/ghc/includes/stgdefs.h b/ghc/includes/stgdefs.h new file mode 100644 index 0000000000..e04ebee448 --- /dev/null +++ b/ghc/includes/stgdefs.h @@ -0,0 +1,219 @@ +/* these are the definitions included at the beginning + * of every compiled-to-C module + */ +#ifndef STGDEFS_H +#define STGDEFS_H + +/* machine/compiler/system dependencies :-( Must be first! */ +#include "platform.h" /* generated by configure */ +#include "config.h" /* generated by configure */ +#include "error.h" +#include "StgMachDeps.h" + +#include "COptRegs.h" + +/* our own ASSERT macro (for C) */ +#ifndef DEBUG +#define NDEBUG 1 /* for assert.h */ +#define ASSERT(predicate) /*nothing*/ + +#else +#undef NDEBUG /* for assert.h */ + +void _stgAssert PROTO((char *, unsigned int)); + +#define ASSERT(predicate) \ + if (predicate) \ + /*null*/; \ + else \ + _stgAssert(__FILE__, __LINE__) +#endif + +#if macos7_TARGET_OS +#define NON_POSIX_SOURCE +#endif + +#ifdef NON_POSIX_SOURCE +#undef _POSIX_SOURCE +#undef _POSIX_C_SOURCE +#else +#define _POSIX_SOURCE 1 +#define _POSIX_C_SOURCE 199301L +#include <unistd.h> +#include <signal.h> +#endif + +/* these are all ANSI C headers */ +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <assert.h> +#include <errno.h> +#include <stdio.h> + +#ifndef STDC_HEADERS +/* hack: though the following are defined in the ANSI C library, + they may not be defined in a systems stdio.h (Suns, for example). + GCC is schizophrenic about whether it adds these into its + own headers for you; so we have no choice but to throw them in. +*/ +extern int fclose PROTO((FILE *)); +extern int fflush PROTO((FILE *)); +extern int fgetc PROTO((FILE *)); +/* extern int fgetpos PROTO((FILE *, fpos_t *)); */ +extern int fprintf PROTO((FILE *, const char *, ...)); +extern int fputc PROTO((int, FILE *)); +extern int fputs PROTO((const char *, FILE *)); +extern size_t fread PROTO((void *, size_t, size_t, FILE *)); +extern int fscanf PROTO((FILE *, const char *, ...)); +extern int fseek PROTO((FILE *, long int, int)); +/* extern int fsetpos PROTO((FILE *, const fpos_t *)); */ +extern size_t fwrite PROTO((const void *, size_t, size_t, FILE *)); +extern void perror PROTO((const char *)); +extern int printf PROTO((const char *, ...)); +extern int puts PROTO((const char *)); +extern int remove PROTO((const char *)); +extern int rename PROTO((const char *, const char *)); +extern void rewind PROTO((FILE *)); +extern int scanf PROTO((const char *, ...)); +extern void setbuf PROTO((FILE *, char *)); +extern int setvbuf PROTO((FILE *, char *, int, size_t)); +extern int sscanf PROTO((const char *, const char *, ...)); +/* end of hack */ +#endif /* STDC_HEADERS */ + +#if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE) +/* "stdlib.h" should have defined these; but at least + on SunOS 4.1.3, this is not so. +*/ +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 +#endif + +/* Make sure that *some* register map is defined */ +#ifdef __STG_GCC_REGS__ +# if !(defined(NULL_REG_MAP) || defined(FLUSH_REG_MAP) || defined(MAIN_REG_MAP) \ + || defined(MARK_REG_MAP) || defined(SCAN_REG_MAP) || defined(SCAV_REG_MAP)) +yikes! no register map defined! +# endif +#endif + +/* Make sure that *some* garbage-collector is expected; GCap is the default */ +#if !(defined(GCap) || defined(GC2s) || defined(GC1s) || defined(GCdu) || defined(GCgn)) +#define GCap 1 +#endif + +#ifdef IN_GHC_RTS +#define IF_RTS(x) x +#else +#define IF_RTS(x) /*nothing*/ +#endif + +/* GNU multi-precision arith */ +#include "gmp.h" + +/* typedefs for the basic entities */ +#include "StgTypes.h" + +/* constants about the system known to *everybody* (compiler & RTS) */ +#include "GhcConstants.h" + +/* macros to deal with stacks (no longer heap) growing in either dirn */ +#include "StgDirections.h" + +/* declarations for garbage collection routines */ +#include "SMinterface.h" + +/* Macros for declaring "registers" and other Optimising stuff */ +#include "COptJumps.h" +#include "COptRegs.h" +#include "COptWraps.h" + +/* these will come into play if you use -DDO_RUNTIME_PROFILING (default: off) */ +#include "RednCounts.h" + +extern hash_t hash_str PROTO((char *str)); +extern hash_t hash_fixed PROTO((char *data, I_ len)); +extern I_ decode PROTO((char *s)); + +/* ullong (64bit) formatting */ +char *ullong_format_string PROTO((ullong x, char *s, rtsBool with_commas)); + +/* declarations of macros for "high-level instructions" */ +#include "StgMacros.h" + +/* You always need these */ +#include "Info.h" + +/* You need these if you are using the threads package or a parallel machine... */ +#include "Threads.h" +#include "Parallel.h" + +/* Things will happen in here if the driver does -DUSE_COST_CENTRES */ +#include "CostCentre.h" + +/* These will come into play if you use -DLIFE_PROFILE or -DHEAP_PROF_WITH_AGE */ +#include "AgeProfile.h" + +/* These will come into play if you use -DFORCE_GC */ +#include "Force_GC.h" + +/* GRAN and PAR stuff */ +#include "GranSim.h" + +#if defined(USE_COST_CENTRES) || defined(CONCURRENT) +char * time_str(STG_NO_ARGS); +#endif + +/* declarations for runtime-system entry points */ +extern void miniInterpret PROTO((StgFunPtr)); +extern void miniInterpret_debug PROTO(( StgFunPtr, void(*)(STG_NO_ARGS) )); +extern void miniInterpretEnd(STG_NO_ARGS); + +extern StgFunPtr evaluateMain(STG_NO_ARGS); +extern StgFunPtr returnMain(STG_NO_ARGS); +extern StgFunPtr impossible_jump_after_switch(STG_NO_ARGS); + +/* hooks: user might write some of their own */ +extern void ErrorHdrHook PROTO((FILE *)); +extern void OutOfHeapHook PROTO((W_, W_)); +extern void StackOverflowHook PROTO((I_)); +extern void MallocFailHook PROTO((I_)); +extern void PatErrorHdrHook PROTO((FILE *)); +extern void PreTraceHook PROTO((FILE *)); +extern void PostTraceHook PROTO((FILE *)); + +EXTFUN(startStgWorld); +#ifdef CONCURRENT +EXTFUN(CheckHeapCode); +EXTFUN(Continue); +EXTFUN(resumeThread); +#endif + +extern char **prog_argv; /* from runtime/main/main.lc */ +extern I_ prog_argc; +extern char **environ; /* we can get this one straight */ + +EXTDATA(STK_STUB_closure); + +/* now these really *DO* need to be somewhere else... */ +extern char *time_str(STG_NO_ARGS); +extern I_ stg_exit PROTO((I_)); +extern I_ _stg_rem PROTO((I_, I_)); + +/* definitions for closures */ +#include "SMClosures.h" + +/* definitions for info tables */ +#include "SMInfoTables.h" + +/* declarations for Update & Indirection stuff */ +#include "SMupdate.h" + +/* declarations for runtime flags/values */ +#define MAX_RTS_ARGS 32 + +/* Saving and restoring registers */ +#include "StgRegs.h" + +#endif /* ! STGDEFS_H */ |