[project @ 1999-08-25 16:11:43 by simonmar]
[ghc-hetmet.git] / ghc / includes / Rts.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Rts.h,v 1.7 1999/08/25 16:11:44 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 NO_REGS
14 #define NO_REGS                 /* don't define fixed registers */
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 #ifndef DEBUG
51 #define IF_DEBUG(c,s)  doNothing()
52 #else
53 #define IF_DEBUG(c,s)  if (RtsFlags.DebugFlags.c) { s; }
54 #endif
55
56 /* -----------------------------------------------------------------------------
57    Attributes
58    -------------------------------------------------------------------------- */
59
60 #ifdef __GNUC__     /* Avoid spurious warnings                             */
61 #if __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
62 #define STG_NORETURN  __attribute__ ((noreturn))
63 #define STG_UNUSED    __attribute__ ((unused))
64 #else
65 #define STG_NORETURN  
66 #define STG_UNUSED
67 #endif
68 #else
69 #define STG_NORETURN  
70 #define STG_UNUSED
71 #endif
72
73 /* -----------------------------------------------------------------------------
74    Useful macros and inline functions
75    -------------------------------------------------------------------------- */
76
77 /* 
78  * Use this on the RHS of macros which expand to nothing
79  * to make sure that the macro can be used in a context which
80  * demands a non-empty statement.
81  */
82
83 #define doNothing() do { } while (0)
84
85 #define stg_min(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _a : _b; })
86 #define stg_max(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _b : _a; })
87
88 #endif RTS_H