1 /* -----------------------------------------------------------------------------
2 * $Id: Rts.h,v 1.11 2000/01/13 12:40:15 simonmar Exp $
4 * (c) The GHC Team, 1998-1999
6 * Top-level include file for the RTS itself
8 * ---------------------------------------------------------------------------*/
18 /* -----------------------------------------------------------------------------
20 -------------------------------------------------------------------------- */
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.
26 #define EXIT_SUCCESS 0
27 #define EXIT_FAILURE 1
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
37 /* -----------------------------------------------------------------------------
39 -------------------------------------------------------------------------- */
41 /* declarations for runtime flags/values */
42 #define MAX_RTS_ARGS 32
44 /* -----------------------------------------------------------------------------
46 -------------------------------------------------------------------------- */
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 */
57 /* -----------------------------------------------------------------------------
58 Assertions and Debuggery
59 -------------------------------------------------------------------------- */
62 #define IF_DEBUG(c,s) if (RtsFlags.DebugFlags.c) { s; }
64 #define IF_DEBUG(c,s) doNothing()
67 #if defined(GRAN) && defined(DEBUG)
68 #define IF_GRAN_DEBUG(c,s) if (RtsFlags.GranFlags.Debug.c) { s; }
70 #define IF_GRAN_DEBUG(c,s) doNothing()
73 #if defined(PAR) && defined(DEBUG)
74 #define IF_PAR_DEBUG(c,s) if (RtsFlags.ParFlags.Debug.c) { s; }
76 #define IF_PAR_DEBUG(c,s) doNothing()
79 /* -----------------------------------------------------------------------------
81 -------------------------------------------------------------------------- */
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))
96 /* -----------------------------------------------------------------------------
97 Useful macros and inline functions
98 -------------------------------------------------------------------------- */
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.
106 #define doNothing() do { } while (0)
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; })