6 IMPORTANT
! If you put extra tabs
/spaces in these macro definitions
,
7 you will screw up the layout where they are used in
case expressions
!
9 (This is cpp
-dependent
, of course
)
13 /* Useful in the headers that we share with the RTS */
14 #define COMPILING_GHC 1
16 /* Pull in all the platform defines for this build (foo_TARGET_ARCH etc.) */
17 #include "ghc_boot_platform.h"
19 /* Pull in the autoconf defines (HAVE_FOO), but don't include
20 * ghcconfig.h, because that will include ghcplatform.h which has the
21 * wrong platform settings for the compiler (it has the platform
22 * settings for the target plat instead). */
23 #include "../includes/ghcautoconf.h"
25 /* Global variables may not work in other Haskell implementations,
26 * but we need them currently! so the conditional on GLASGOW won't do. */
27 #if defined(__GLASGOW_HASKELL__) || !defined(__GLASGOW_HASKELL__)
28 #define GLOBAL_VAR(name,value,ty) \
29 {-# NOINLINE name #-}; \
31 name = Util.global (value);
33 #define GLOBAL_VAR_M(name,value,ty) \
34 {-# NOINLINE name #-}; \
36 name = Util.globalM (value);
39 #define ASSERT(e) if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else
40 #define ASSERT2(e,msg) if debugIsOn && not (e) then (assertPprPanic __FILE__ __LINE__ (msg)) else
41 #define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg)) $
43 -- Examples
: Assuming flagSet
:: String
-> m Bool
45 -- do { c
<- getChar
; MASSERT( isUpper c
); ... }
46 -- do { c
<- getChar
; MASSERT2( isUpper c
, text
"Bad" ); ... }
47 -- do { str
<- getStr
; ASSERTM( flagSet str
); .. }
48 -- do { str
<- getStr
; ASSERTM2( flagSet str
, text
"Bad" ); .. }
49 -- do { str
<- getStr
; WARNM2( flagSet str
, text
"Flag is set" ); .. }
50 #define MASSERT(e) ASSERT(e) return ()
51 #define MASSERT2(e,msg) ASSERT2(e,msg) return ()
52 #define ASSERTM(e) do { bool <- e; MASSERT(bool) }
53 #define ASSERTM2(e,msg) do { bool <- e; MASSERT2(bool,msg) }
54 #define WARNM2(e,msg) do { bool <- e; WARN(bool, msg) return () }
56 -- Useful
for declaring arguments to be strict
57 #define STRICT1(f) f a | a `seq` False = undefined
58 #define STRICT2(f) f a b | a `seq` b `seq` False = undefined
59 #define STRICT3(f) f a b c | a `seq` b `seq` c `seq` False = undefined
60 #define STRICT4(f) f a b c d | a `seq` b `seq` c `seq` d `seq` False = undefined
61 #define STRICT5(f) f a b c d e | a `seq` b `seq` c `seq` d `seq` e `seq` False = undefined
62 #define STRICT6(f) f a b c d e f | a `seq` b `seq` c `seq` d `seq` e `seq` f `seq` False = undefined
64 #endif /* HsVersions.h */