Stg.h 3.71 KB
Newer Older
1
/* -----------------------------------------------------------------------------
2
 * $Id: Stg.h,v 1.9 1999/03/15 16:30:25 simonm Exp $
3 4
 *
 * (c) The GHC Team, 1998-1999
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 *
 * 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

/* Configuration */
#include "config.h"
#ifdef __HUGS__ /* vile hack till the GHC folks come on board */
#include "options.h"
#endif

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

sof's avatar
sof committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
/* This is a feature test - doesn't belong here. FixMe. */
#ifdef __MINGW32__
#define HAVE_WIN32_DLL_SUPPORT
#endif

#ifdef HAVE_WIN32_DLL_SUPPORT
# if __GNUC__ && !defined(__declspec)
#  define DLLIMPORT
# else
#  define DLLIMPORT __declspec(dllimport)
#  define DLLIMPORT_DATA(x) _imp__##x
# endif
#else
# define DLLIMPORT
#endif

#ifdef COMPILING_RTS
#define DLL_IMPORT DLLIMPORT
#define DLL_IMPORT_RTS
#define DLL_IMPORT_DATA
#define DLL_IMPORT_DATA_VAR(x) x
#else
#define DLL_IMPORT
#define DLL_IMPORT_RTS DLLIMPORT
#define DLL_IMPORT_DATA DLLIMPORT
sof's avatar
sof committed
55 56 57 58 59
# ifdef HAVE_WIN32_DLL_SUPPORT
#  define DLL_IMPORT_DATA_VAR(x) _imp__##x
# else
#  define DLL_IMPORT_DATA_VAR(x) x
# endif
sof's avatar
sof committed
60 61
#endif

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
/* 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
   -------------------------------------------------------------------------- */

88 89 90 91 92 93 94 95 96 97 98
/* Global type definitions*/
#include "StgTypes.h"

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

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

/* Storage format definitions */
#include "Closures.h"
99
#include "ClosureTypes.h"
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
#include "InfoTables.h"
#include "TSO.h"

/* STG/Optimised-C related stuff */
#include "MachRegs.h"
#include "Regs.h"
#include "TailCalls.h"

/* 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

/* 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"
140
#include "StgTicky.h"
141
#include "CCall.h"
142
#include "Stable.h"
143 144 145 146 147 148 149 150

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

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

/* Misc stuff without a home */
sof's avatar
sof committed
151 152 153 154
#ifdef BUILDING_RTS_DLL
extern DLLIMPORT char **prog_argv;	/* so we can get at these from Haskell */
extern DLLIMPORT int    prog_argc;
#else
155 156
extern char **prog_argv;	/* so we can get at these from Haskell */
extern int    prog_argc;
sof's avatar
sof committed
157
#endif
158 159 160

extern char **environ;

sof's avatar
sof committed
161
/* Creating and destroying an adjustor thunk.
162
   I cannot make myself create a separate .h file
sof's avatar
sof committed
163 164 165 166 167
   for these two (sof.)
*/
extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr);
extern void  freeHaskellFunctionPtr(void* ptr);

168
#endif /* STG_H */