Rts.h 3.27 KB
Newer Older
1
/* -----------------------------------------------------------------------------
sof's avatar
sof committed
2
 * $Id: Rts.h,v 1.18 2002/02/14 16:58:13 sof 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
   -------------------------------------------------------------------------- */

#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

34
35
36
37
38
39
40
41
42
43
44
/* 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
   -------------------------------------------------------------------------- */

45
46
47
/* declarations for runtime flags/values */
#define MAX_RTS_ARGS 32

sof's avatar
sof committed
48
49
50
51
52
53
54
55
#ifdef _WIN32
/* On the yucky side..suppress -Wmissing-declarations warnings when
 * including <windows.h>
 */
extern void* GetCurrentFiber ( void );
extern void* GetFiberData ( void );
#endif

56
/* -----------------------------------------------------------------------------
57
   Assertions and Debuggery
58
59
   -------------------------------------------------------------------------- */

60
#define IF_RTSFLAGS(c,s)  if (RtsFlags.c) { s; }
61
62
63
64
65

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

66
67
68
#ifdef DEBUG
#define IF_DEBUG(c,s)  if (RtsFlags.DebugFlags.c) { s; }
#else
69
#define IF_DEBUG(c,s)  doNothing()
70
71
72
73
#endif

#if defined(GRAN) && defined(DEBUG)
#define IF_GRAN_DEBUG(c,s)  if (RtsFlags.GranFlags.Debug.c) { s; }
74
#else
75
76
77
78
79
80
81
#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()
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#endif

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

#ifdef __GNUC__     /* Avoid spurious warnings                             */
#if __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
#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; })

108
109
110
111
112
113
/* -------------------------------------------------------------------------- */

#ifdef __cplusplus
}
#endif

114
#endif /* RTS_H */