[project @ 2000-01-13 14:33:57 by hwloidl]
[ghc-hetmet.git] / ghc / includes / Rts.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Rts.h,v 1.12 2000/01/13 14:34:01 hwloidl 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 #ifndef IN_STG_CODE
14 #define IN_STG_CODE 0
15 #endif
16 #include "Stg.h"
17
18 /* -----------------------------------------------------------------------------
19    RTS Exit codes
20    -------------------------------------------------------------------------- */
21
22 #if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
23 /* "stdlib.h" should have defined these; but at least
24    on SunOS 4.1.3, this is not so.
25 */
26 #define EXIT_SUCCESS 0
27 #define EXIT_FAILURE 1
28 #endif
29
30 /* 255 is allegedly used by dynamic linkers to report linking failure */
31 #define EXIT_INTERNAL_ERROR 254
32 #define EXIT_DEADLOCK       253
33 #define EXIT_INTERRUPTED    252
34 #define EXIT_HEAPOVERFLOW   251
35 #define EXIT_KILLED         250
36
37 /* -----------------------------------------------------------------------------
38    Miscellaneous garbage
39    -------------------------------------------------------------------------- */
40
41 /* declarations for runtime flags/values */
42 #define MAX_RTS_ARGS 32
43
44 /* -----------------------------------------------------------------------------
45    Assertions and Debuggery
46    -------------------------------------------------------------------------- */
47
48 #define IF_RTSFLAGS(c,s)  if (RtsFlags.c) { s; }
49
50 /* -----------------------------------------------------------------------------
51    Assertions and Debuggery
52    -------------------------------------------------------------------------- */
53
54 #ifdef DEBUG
55 #define IF_DEBUG(c,s)  if (RtsFlags.DebugFlags.c) { s; }
56 #else
57 #define IF_DEBUG(c,s)  doNothing()
58 #endif
59
60 #if defined(GRAN) && defined(DEBUG)
61 #define IF_GRAN_DEBUG(c,s)  if (RtsFlags.GranFlags.Debug.c) { s; }
62 #else
63 #define IF_GRAN_DEBUG(c,s)  doNothing()
64 #endif
65
66 #if defined(PAR) && defined(DEBUG)
67 #define IF_PAR_DEBUG(c,s)  if (RtsFlags.ParFlags.Debug.c) { s; }
68 #else
69 #define IF_PAR_DEBUG(c,s)  doNothing()
70 #endif
71
72 /* -----------------------------------------------------------------------------
73    Attributes
74    -------------------------------------------------------------------------- */
75
76 #ifdef __GNUC__     /* Avoid spurious warnings                             */
77 #if __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
78 #define STG_NORETURN  __attribute__ ((noreturn))
79 #define STG_UNUSED    __attribute__ ((unused))
80 #else
81 #define STG_NORETURN  
82 #define STG_UNUSED
83 #endif
84 #else
85 #define STG_NORETURN  
86 #define STG_UNUSED
87 #endif
88
89 /* -----------------------------------------------------------------------------
90    Useful macros and inline functions
91    -------------------------------------------------------------------------- */
92
93 /* 
94  * Use this on the RHS of macros which expand to nothing
95  * to make sure that the macro can be used in a context which
96  * demands a non-empty statement.
97  */
98
99 #define doNothing() do { } while (0)
100
101 #define stg_min(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _a : _b; })
102 #define stg_max(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _b : _a; })
103
104 #endif RTS_H