Rts.h 3.18 KB
Newer Older
1
/* -----------------------------------------------------------------------------
2
 * $Id: Rts.h,v 1.22 2002/12/19 17:57:39 panne Exp $
3
4
 *
 * (c) The GHC Team, 1998-1999
5
6
7
8
9
10
11
12
 *
 * Top-level include file for the RTS itself
 *
 * ---------------------------------------------------------------------------*/

#ifndef RTS_H
#define RTS_H

13
14
15
16
#ifdef __cplusplus
extern "C" {
#endif

17
#ifndef IN_STG_CODE
18
#define IN_STG_CODE 0
19
20
21
22
#endif
#include "Stg.h"

/* -----------------------------------------------------------------------------
23
   RTS Exit codes
24
25
   -------------------------------------------------------------------------- */

26
27
28
29
30
31
32
33
34
35
36
/* 255 is allegedly used by dynamic linkers to report linking failure */
#define EXIT_INTERNAL_ERROR 254
#define EXIT_DEADLOCK       253
#define EXIT_INTERRUPTED    252
#define EXIT_HEAPOVERFLOW   251
#define EXIT_KILLED         250

/* -----------------------------------------------------------------------------
   Miscellaneous garbage
   -------------------------------------------------------------------------- */

37
38
39
/* declarations for runtime flags/values */
#define MAX_RTS_ARGS 32

sof's avatar
sof committed
40
41
42
43
44
45
46
47
#ifdef _WIN32
/* On the yucky side..suppress -Wmissing-declarations warnings when
 * including <windows.h>
 */
extern void* GetCurrentFiber ( void );
extern void* GetFiberData ( void );
#endif

48
/* -----------------------------------------------------------------------------
49
   Assertions and Debuggery
50
51
   -------------------------------------------------------------------------- */

52
#define IF_RTSFLAGS(c,s)  if (RtsFlags.c) { s; }
53
54
55
56
57

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

58
59
60
#ifdef DEBUG
#define IF_DEBUG(c,s)  if (RtsFlags.DebugFlags.c) { s; }
#else
61
#define IF_DEBUG(c,s)  doNothing()
62
63
#endif

64
65
66
67
68
69
#ifdef DEBUG
#define DEBUG_ONLY(s) s
#else
#define DEBUG_ONLY(s) doNothing()
#endif

70
71
#if defined(GRAN) && defined(DEBUG)
#define IF_GRAN_DEBUG(c,s)  if (RtsFlags.GranFlags.Debug.c) { s; }
72
#else
73
74
75
76
77
78
79
#define IF_GRAN_DEBUG(c,s)  doNothing()
#endif

#if defined(PAR) && defined(DEBUG)
#define IF_PAR_DEBUG(c,s)  if (RtsFlags.ParFlags.Debug.c) { s; }
#else
#define IF_PAR_DEBUG(c,s)  doNothing()
80
81
82
83
84
85
86
#endif

/* -----------------------------------------------------------------------------
   Attributes
   -------------------------------------------------------------------------- */

#ifdef __GNUC__     /* Avoid spurious warnings                             */
87
#if (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ >= 3
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#define STG_NORETURN  __attribute__ ((noreturn))
#define STG_UNUSED    __attribute__ ((unused))
#else
#define STG_NORETURN  
#define STG_UNUSED
#endif
#else
#define STG_NORETURN  
#define STG_UNUSED
#endif

/* -----------------------------------------------------------------------------
   Useful macros and inline functions
   -------------------------------------------------------------------------- */

#define stg_min(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _a : _b; })
#define stg_max(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _b : _a; })

106
107
108
109
110
111
/* -------------------------------------------------------------------------- */

#ifdef __cplusplus
}
#endif

112
#endif /* RTS_H */