[project @ 2002-11-20 14:09:42 by simonmar]
[ghc-hetmet.git] / ghc / includes / Rts.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Rts.h,v 1.19 2002/07/18 06:07:37 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 /* 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 #if defined(GRAN) && defined(DEBUG)
65 #define IF_GRAN_DEBUG(c,s)  if (RtsFlags.GranFlags.Debug.c) { s; }
66 #else
67 #define IF_GRAN_DEBUG(c,s)  doNothing()
68 #endif
69
70 #if defined(PAR) && defined(DEBUG)
71 #define IF_PAR_DEBUG(c,s)  if (RtsFlags.ParFlags.Debug.c) { s; }
72 #else
73 #define IF_PAR_DEBUG(c,s)  doNothing()
74 #endif
75
76 /* -----------------------------------------------------------------------------
77    Attributes
78    -------------------------------------------------------------------------- */
79
80 #ifdef __GNUC__     /* Avoid spurious warnings                             */
81 #if __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
82 #define STG_NORETURN  __attribute__ ((noreturn))
83 #define STG_UNUSED    __attribute__ ((unused))
84 #else
85 #define STG_NORETURN  
86 #define STG_UNUSED
87 #endif
88 #else
89 #define STG_NORETURN  
90 #define STG_UNUSED
91 #endif
92
93 /* -----------------------------------------------------------------------------
94    Useful macros and inline functions
95    -------------------------------------------------------------------------- */
96
97 #define stg_min(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _a : _b; })
98 #define stg_max(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _b : _a; })
99
100 /* -------------------------------------------------------------------------- */
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif /* RTS_H */