[project @ 2000-01-13 12:40:15 by simonmar]
[ghc-hetmet.git] / ghc / includes / Rts.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Rts.h,v 1.11 2000/01/13 12:40:15 simonmar 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    Useful typedefs
46    -------------------------------------------------------------------------- */
47
48 typedef unsigned int  nat;           /* at least 32 bits (like int) */
49 typedef unsigned long lnat;          /* at least 32 bits            */
50 typedef unsigned long long ullong;   /* at least 32 bits            */
51   
52 typedef enum { 
53     rtsFalse = 0, 
54     rtsTrue 
55 } rtsBool;
56
57 /* -----------------------------------------------------------------------------
58    Assertions and Debuggery
59    -------------------------------------------------------------------------- */
60
61 #ifdef DEBUG
62 #define IF_DEBUG(c,s)  if (RtsFlags.DebugFlags.c) { s; }
63 #else
64 #define IF_DEBUG(c,s)  doNothing()
65 #endif
66
67 #if defined(GRAN) && defined(DEBUG)
68 #define IF_GRAN_DEBUG(c,s)  if (RtsFlags.GranFlags.Debug.c) { s; }
69 #else
70 #define IF_GRAN_DEBUG(c,s)  doNothing()
71 #endif
72
73 #if defined(PAR) && defined(DEBUG)
74 #define IF_PAR_DEBUG(c,s)  if (RtsFlags.ParFlags.Debug.c) { s; }
75 #else
76 #define IF_PAR_DEBUG(c,s)  doNothing()
77 #endif
78
79 /* -----------------------------------------------------------------------------
80    Attributes
81    -------------------------------------------------------------------------- */
82
83 #ifdef __GNUC__     /* Avoid spurious warnings                             */
84 #if __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
85 #define STG_NORETURN  __attribute__ ((noreturn))
86 #define STG_UNUSED    __attribute__ ((unused))
87 #else
88 #define STG_NORETURN  
89 #define STG_UNUSED
90 #endif
91 #else
92 #define STG_NORETURN  
93 #define STG_UNUSED
94 #endif
95
96 /* -----------------------------------------------------------------------------
97    Useful macros and inline functions
98    -------------------------------------------------------------------------- */
99
100 /* 
101  * Use this on the RHS of macros which expand to nothing
102  * to make sure that the macro can be used in a context which
103  * demands a non-empty statement.
104  */
105
106 #define doNothing() do { } while (0)
107
108 #define stg_min(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _a : _b; })
109 #define stg_max(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _b : _a; })
110
111 #endif RTS_H