[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / includes / Rts.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Rts.h,v 1.2 1998/12/02 13:21:21 simonm Exp $
3  *
4  * Top-level include file for the RTS itself
5  *
6  * ---------------------------------------------------------------------------*/
7
8 #ifndef RTS_H
9 #define RTS_H
10
11 #ifndef NO_REGS
12 #define NO_REGS                 /* don't define fixed registers */
13 #endif
14 #include "Stg.h"
15
16 /* -----------------------------------------------------------------------------
17    Miscellaneous garbage
18    -------------------------------------------------------------------------- */
19
20 #if ! defined(EXIT_SUCCESS) || ! defined(EXIT_FAILURE)
21 /* "stdlib.h" should have defined these; but at least
22    on SunOS 4.1.3, this is not so.
23 */
24 #define EXIT_SUCCESS 0
25 #define EXIT_FAILURE 1
26 #endif
27
28 /* declarations for runtime flags/values */
29 #define MAX_RTS_ARGS 32
30
31 /* -----------------------------------------------------------------------------
32    Useful typedefs
33    -------------------------------------------------------------------------- */
34
35 typedef unsigned int  nat;           /* at least 32 bits (like int) */
36 typedef unsigned long lnat;          /* at least 32 bits            */
37 typedef unsigned long long ullong;   /* at least 32 bits            */
38   
39 typedef enum { 
40     rtsFalse = 0, 
41     rtsTrue 
42 } rtsBool;
43
44 /* -----------------------------------------------------------------------------
45    Assertions and Debuggery
46    -------------------------------------------------------------------------- */
47
48 #ifndef DEBUG
49 #define ASSERT(predicate) /* nothing */
50 #else
51
52 void _stgAssert (char *, unsigned int);
53
54 #define ASSERT(predicate)                       \
55         if (predicate)                          \
56             /*null*/;                           \
57         else                                    \
58             _stgAssert(__FILE__, __LINE__)
59
60 #endif /* DEBUG */
61
62 #ifndef DEBUG
63 #define IF_DEBUG(c,s)  doNothing()
64 #else
65 #define IF_DEBUG(c,s)  if (RtsFlags.DebugFlags.c) { s; }
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
101 #define UNUSED __attribute__((unused))
102
103 #endif RTS_H