[project @ 2000-01-12 15:15:17 by simonmar]
[ghc-hetmet.git] / ghc / includes / Rts.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Rts.h,v 1.10 2000/01/12 15:15:17 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    Miscellaneous garbage
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 /* declarations for runtime flags/values */
31 #define MAX_RTS_ARGS 32
32
33 /* -----------------------------------------------------------------------------
34    Useful typedefs
35    -------------------------------------------------------------------------- */
36
37 typedef unsigned int  nat;           /* at least 32 bits (like int) */
38 typedef unsigned long lnat;          /* at least 32 bits            */
39 typedef unsigned long long ullong;   /* at least 32 bits            */
40   
41 typedef enum { 
42     rtsFalse = 0, 
43     rtsTrue 
44 } rtsBool;
45
46 /* -----------------------------------------------------------------------------
47    Assertions and Debuggery
48    -------------------------------------------------------------------------- */
49
50 #ifdef DEBUG
51 #define IF_DEBUG(c,s)  if (RtsFlags.DebugFlags.c) { s; }
52 #else
53 #define IF_DEBUG(c,s)  doNothing()
54 #endif
55
56 #if defined(GRAN) && defined(DEBUG)
57 #define IF_GRAN_DEBUG(c,s)  if (RtsFlags.GranFlags.Debug.c) { s; }
58 #else
59 #define IF_GRAN_DEBUG(c,s)  doNothing()
60 #endif
61
62 #if defined(PAR) && defined(DEBUG)
63 #define IF_PAR_DEBUG(c,s)  if (RtsFlags.ParFlags.Debug.c) { s; }
64 #else
65 #define IF_PAR_DEBUG(c,s)  doNothing()
66 #endif
67
68 /* -----------------------------------------------------------------------------
69    Attributes
70    -------------------------------------------------------------------------- */
71
72 #ifdef __GNUC__     /* Avoid spurious warnings                             */
73 #if __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
74 #define STG_NORETURN  __attribute__ ((noreturn))
75 #define STG_UNUSED    __attribute__ ((unused))
76 #else
77 #define STG_NORETURN  
78 #define STG_UNUSED
79 #endif
80 #else
81 #define STG_NORETURN  
82 #define STG_UNUSED
83 #endif
84
85 /* -----------------------------------------------------------------------------
86    Useful macros and inline functions
87    -------------------------------------------------------------------------- */
88
89 /* 
90  * Use this on the RHS of macros which expand to nothing
91  * to make sure that the macro can be used in a context which
92  * demands a non-empty statement.
93  */
94
95 #define doNothing() do { } while (0)
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 #endif RTS_H