[project @ 2002-02-14 16:58:13 by sof]
[ghc-hetmet.git] / ghc / includes / Rts.h
1 /* -----------------------------------------------------------------------------
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  * Top-level include file for the RTS itself
7  *
8  * ---------------------------------------------------------------------------*/
9
10 #ifndef RTS_H
11 #define RTS_H
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 #ifndef IN_STG_CODE
18 #define IN_STG_CODE 0
19 #endif
20 #include "Stg.h"
21
22 /* -----------------------------------------------------------------------------
23    RTS Exit codes
24    -------------------------------------------------------------------------- */
25
26 #if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
27 /* "stdlib.h" should have defined these; but at least
28    on SunOS 4.1.3, this is not so.
29 */
30 #define EXIT_SUCCESS 0
31 #define EXIT_FAILURE 1
32 #endif
33
34 /* 255 is allegedly used by dynamic linkers to report linking failure */
35 #define EXIT_INTERNAL_ERROR 254
36 #define EXIT_DEADLOCK       253
37 #define EXIT_INTERRUPTED    252
38 #define EXIT_HEAPOVERFLOW   251
39 #define EXIT_KILLED         250
40
41 /* -----------------------------------------------------------------------------
42    Miscellaneous garbage
43    -------------------------------------------------------------------------- */
44
45 /* declarations for runtime flags/values */
46 #define MAX_RTS_ARGS 32
47
48 #ifdef _WIN32
49 /* On the yucky side..suppress -Wmissing-declarations warnings when
50  * including <windows.h>
51  */
52 extern void* GetCurrentFiber ( void );
53 extern void* GetFiberData ( void );
54 #endif
55
56 /* -----------------------------------------------------------------------------
57    Assertions and Debuggery
58    -------------------------------------------------------------------------- */
59
60 #define IF_RTSFLAGS(c,s)  if (RtsFlags.c) { s; }
61
62 /* -----------------------------------------------------------------------------
63    Assertions and Debuggery
64    -------------------------------------------------------------------------- */
65
66 #ifdef DEBUG
67 #define IF_DEBUG(c,s)  if (RtsFlags.DebugFlags.c) { s; }
68 #else
69 #define IF_DEBUG(c,s)  doNothing()
70 #endif
71
72 #if defined(GRAN) && defined(DEBUG)
73 #define IF_GRAN_DEBUG(c,s)  if (RtsFlags.GranFlags.Debug.c) { s; }
74 #else
75 #define IF_GRAN_DEBUG(c,s)  doNothing()
76 #endif
77
78 #if defined(PAR) && defined(DEBUG)
79 #define IF_PAR_DEBUG(c,s)  if (RtsFlags.ParFlags.Debug.c) { s; }
80 #else
81 #define IF_PAR_DEBUG(c,s)  doNothing()
82 #endif
83
84 /* -----------------------------------------------------------------------------
85    Attributes
86    -------------------------------------------------------------------------- */
87
88 #ifdef __GNUC__     /* Avoid spurious warnings                             */
89 #if __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
90 #define STG_NORETURN  __attribute__ ((noreturn))
91 #define STG_UNUSED    __attribute__ ((unused))
92 #else
93 #define STG_NORETURN  
94 #define STG_UNUSED
95 #endif
96 #else
97 #define STG_NORETURN  
98 #define STG_UNUSED
99 #endif
100
101 /* -----------------------------------------------------------------------------
102    Useful macros and inline functions
103    -------------------------------------------------------------------------- */
104
105 #define stg_min(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _a : _b; })
106 #define stg_max(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _b : _a; })
107
108 /* -------------------------------------------------------------------------- */
109
110 #ifdef __cplusplus
111 }
112 #endif
113
114 #endif /* RTS_H */