Stg.h 4.49 KB
Newer Older
1
/* -----------------------------------------------------------------------------
2
 * $Id: Stg.h,v 1.19 1999/11/05 12:28:05 simonmar Exp $
3 4
 *
 * (c) The GHC Team, 1998-1999
5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * Top-level include file for everything STG-ish.  
 *
 * This file is included *automatically* by all .hc files.
 *
 * ---------------------------------------------------------------------------*/

#ifndef STG_H
#define STG_H

#ifndef NON_POSIX_SOURCE
#define _POSIX_SOURCE
#endif

19 20 21 22 23 24
/* If we include "Stg.h" directly, we're in STG code, and we therefore
 * get all the global register variables, macros etc. that go along
 * with that.  If "Stg.h" is included via "Rts.h", we're assumed to
 * be in vanilla C.
 */
#ifdef NOT_IN_STG_CODE
25 26 27
# ifndef NO_REGS
#  define NO_REGS			/* don't define fixed registers */
# endif
28
#else
29
# define IN_STG_CODE
30 31
#endif

32 33 34 35 36 37
/* Configuration */
#include "config.h"
#ifdef __HUGS__ /* vile hack till the GHC folks come on board */
#include "options.h"
#endif

sof's avatar
sof committed
38 39 40
/* Some macros to handle DLLing (Win32 only at the moment). */
#include "StgDLL.h"

41 42 43 44 45 46 47 48
/* Turn lazy blackholing and eager blackholing on/off.
 *
 * Using eager blackholing makes things easier to debug because
 * the blackholes are more predictable - but it's slower and less sexy.
 *
 * For now, do lazy and not eager.
 */

49 50 51 52 53 54 55 56 57 58 59
/* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of
 * single-entry thunks.
 *
 * SMP needs EAGER_BLACKHOLING because it has to lock thunks
 * synchronously, in case another thread is trying to evaluate the
 * same thunk simultaneously.
 */
#if defined(SMP) || defined(TICKY_TICKY)
#  define EAGER_BLACKHOLING
#else
#  define LAZY_BLACKHOLING
60 61
#endif

62 63 64 65 66
/* ToDo: Set this flag properly: COMPILER and INTERPRETER should not be mutually exclusive. */
#ifndef INTERPRETER
#define COMPILER 1
#endif

67 68 69 70 71
/* TABLES_NEXT_TO_CODE says whether to assume that info tables are
 * assumed to reside just before the code for a function.
 *
 * UNDEFINING THIS WON'T WORK ON ITS OWN.  You have been warned.
 */
72 73 74 75
#ifndef USE_MINIINTERPRETER
#define TABLES_NEXT_TO_CODE
#endif

76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
/* bit macros
 */
#define BITS_PER_BYTE 8
#define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))

/* -----------------------------------------------------------------------------
   Assertions and Debuggery
   -------------------------------------------------------------------------- */

#ifndef DEBUG
#define ASSERT(predicate) /* nothing */
#else

void _stgAssert (char *, unsigned int);

#define ASSERT(predicate)			\
	if (predicate)				\
	    /*null*/;				\
	else					\
	    _stgAssert(__FILE__, __LINE__)
#endif /* DEBUG */

/* -----------------------------------------------------------------------------
   Include everything STG-ish
   -------------------------------------------------------------------------- */

102 103 104 105 106 107 108 109 110 111 112
/* Global type definitions*/
#include "StgTypes.h"

/* Global constaints */
#include "Constants.h"

/* Profiling information */
#include "Profiling.h"

/* Storage format definitions */
#include "Closures.h"
113
#include "ClosureTypes.h"
114 115
#include "InfoTables.h"
#include "TSO.h"
116
#include "Block.h"
117 118

/* STG/Optimised-C related stuff */
119
#include "SMP.h"
120 121 122 123
#include "MachRegs.h"
#include "Regs.h"
#include "TailCalls.h"

sof's avatar
sof committed
124 125 126
/* RTS public interface */
#include "RtsAPI.h"

127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
/* these are all ANSI C headers */
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>

#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

143 144 145 146
#ifdef SMP
#include <pthread.h>
#endif

147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
/* GNU mp library */
#include "gmp.h"

/* Wired-in Prelude identifiers */
#include "Prelude.h"

/* Storage Manager */
#include "StgStorage.h"

/* Macros for STG/C code */
#include "ClosureMacros.h"
#include "InfoMacros.h"
#include "StgMacros.h"
#include "StgProf.h"
#include "PrimOps.h"
#include "Updates.h"
163
#include "StgTicky.h"
164
#include "CCall.h"
165
#include "Stable.h"
166 167 168 169 170 171 172 173

/* Built-in entry points */
#include "StgMiscClosures.h"

/* Runtime-system hooks */
#include "Hooks.h"

/* Misc stuff without a home */
sof's avatar
sof committed
174
#if defined(ENABLE_WIN32_DLL_SUPPOT) && !defined(COMPILING_RTS)
sof's avatar
sof committed
175 176 177
extern DLLIMPORT char **prog_argv;	/* so we can get at these from Haskell */
extern DLLIMPORT int    prog_argc;
#else
178 179
extern char **prog_argv;	/* so we can get at these from Haskell */
extern int    prog_argc;
sof's avatar
sof committed
180
#endif
181 182 183

extern char **environ;

sof's avatar
sof committed
184
/* Creating and destroying an adjustor thunk.
185
   I cannot make myself create a separate .h file
sof's avatar
sof committed
186 187
   for these two (sof.) 
   
sof's avatar
sof committed
188 189 190 191
*/
extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
extern void  freeHaskellFunctionPtr(void* ptr);

192
#endif /* STG_H */