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