[project @ 2003-01-28 16:30:06 by simonmar]
[ghc-hetmet.git] / ghc / includes / Rts.h
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  * 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 /* 255 is allegedly used by dynamic linkers to report linking failure */
27 #define EXIT_INTERNAL_ERROR 254
28 #define EXIT_DEADLOCK       253
29 #define EXIT_INTERRUPTED    252
30 #define EXIT_HEAPOVERFLOW   251
31 #define EXIT_KILLED         250
32
33 /* -----------------------------------------------------------------------------
34    Miscellaneous garbage
35    -------------------------------------------------------------------------- */
36
37 /* declarations for runtime flags/values */
38 #define MAX_RTS_ARGS 32
39
40 #ifdef _WIN32
41 /* On the yucky side..suppress -Wmissing-declarations warnings when
42  * including <windows.h>
43  */
44 extern void* GetCurrentFiber ( void );
45 extern void* GetFiberData ( void );
46 #endif
47
48 /* -----------------------------------------------------------------------------
49    Assertions and Debuggery
50    -------------------------------------------------------------------------- */
51
52 #define IF_RTSFLAGS(c,s)  if (RtsFlags.c) { s; }
53
54 /* -----------------------------------------------------------------------------
55    Assertions and Debuggery
56    -------------------------------------------------------------------------- */
57
58 #ifdef DEBUG
59 #define IF_DEBUG(c,s)  if (RtsFlags.DebugFlags.c) { s; }
60 #else
61 #define IF_DEBUG(c,s)  doNothing()
62 #endif
63
64 #ifdef DEBUG
65 #define DEBUG_ONLY(s) s
66 #else
67 #define DEBUG_ONLY(s) doNothing()
68 #endif
69
70 #if defined(GRAN) && defined(DEBUG)
71 #define IF_GRAN_DEBUG(c,s)  if (RtsFlags.GranFlags.Debug.c) { s; }
72 #else
73 #define IF_GRAN_DEBUG(c,s)  doNothing()
74 #endif
75
76 #if defined(PAR) && defined(DEBUG)
77 #define IF_PAR_DEBUG(c,s)  if (RtsFlags.ParFlags.Debug.c) { s; }
78 #else
79 #define IF_PAR_DEBUG(c,s)  doNothing()
80 #endif
81
82 /* -----------------------------------------------------------------------------
83    Attributes
84    -------------------------------------------------------------------------- */
85
86 #ifdef __GNUC__     /* Avoid spurious warnings                             */
87 #if (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ >= 3
88 #define STG_NORETURN  __attribute__ ((noreturn))
89 #define STG_UNUSED    __attribute__ ((unused))
90 #else
91 #define STG_NORETURN  
92 #define STG_UNUSED
93 #endif
94 #else
95 #define STG_NORETURN  
96 #define STG_UNUSED
97 #endif
98
99 /* -----------------------------------------------------------------------------
100    Useful macros and inline functions
101    -------------------------------------------------------------------------- */
102
103 #define stg_min(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _a : _b; })
104 #define stg_max(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _b : _a; })
105
106 /* -------------------------------------------------------------------------- */
107
108 #ifdef __cplusplus
109 }
110 #endif
111
112 #endif /* RTS_H */