1 /* -----------------------------------------------------------------------------
2 * $Id: Rts.h,v 1.13 2000/04/05 14:26:31 panne 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 /* -----------------------------------------------------------------------------
45 Assertions and Debuggery
46 -------------------------------------------------------------------------- */
48 #define IF_RTSFLAGS(c,s) if (RtsFlags.c) { s; }
50 /* -----------------------------------------------------------------------------
51 Assertions and Debuggery
52 -------------------------------------------------------------------------- */
55 #define IF_DEBUG(c,s) if (RtsFlags.DebugFlags.c) { s; }
57 #define IF_DEBUG(c,s) doNothing()
60 #if defined(GRAN) && defined(DEBUG)
61 #define IF_GRAN_DEBUG(c,s) if (RtsFlags.GranFlags.Debug.c) { s; }
63 #define IF_GRAN_DEBUG(c,s) doNothing()
66 #if defined(PAR) && defined(DEBUG)
67 #define IF_PAR_DEBUG(c,s) if (RtsFlags.ParFlags.Debug.c) { s; }
69 #define IF_PAR_DEBUG(c,s) doNothing()
72 /* -----------------------------------------------------------------------------
74 -------------------------------------------------------------------------- */
76 #ifdef __GNUC__ /* Avoid spurious warnings */
77 #if __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
78 #define STG_NORETURN __attribute__ ((noreturn))
79 #define STG_UNUSED __attribute__ ((unused))
89 /* -----------------------------------------------------------------------------
90 Useful macros and inline functions
91 -------------------------------------------------------------------------- */
94 * Use this on the RHS of macros which expand to nothing
95 * to make sure that the macro can be used in a context which
96 * demands a non-empty statement.
99 #define doNothing() do { } while (0)
101 #define stg_min(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _a : _b; })
102 #define stg_max(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _b : _a; })