Add some more Integer rules; fixes #6111
[ghc.git] / compiler / HsVersions.h
1 #ifndef HSVERSIONS_H
2 #define HSVERSIONS_H
3
4 #if 0
5
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!
8
9 (This is cpp-dependent, of course)
10
11 #endif
12
13 /* Useful in the headers that we share with the RTS */
14 #define COMPILING_GHC 1
15
16 /* Pull in all the platform defines for this build (foo_TARGET_ARCH etc.) */
17 #include "ghc_boot_platform.h"
18
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"
24
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 #ifndef __HADDOCK__
28 #if defined(__GLASGOW_HASKELL__) || !defined(__GLASGOW_HASKELL__)
29 #define GLOBAL_VAR(name,value,ty) \
30 {-# NOINLINE name #-}; \
31 name :: IORef (ty); \
32 name = Util.global (value);
33
34 #define GLOBAL_VAR_M(name,value,ty) \
35 {-# NOINLINE name #-}; \
36 name :: IORef (ty); \
37 name = Util.globalM (value);
38 #endif
39 #else /* __HADDOCK__ */
40 #define GLOBAL_VAR(name,value,ty) \
41 name :: IORef (ty); \
42 name = Util.global (value);
43
44 #define GLOBAL_VAR_M(name,value,ty) \
45 name :: IORef (ty); \
46 name = Util.globalM (value);
47 #endif
48
49 #define ASSERT(e) if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else
50 #define ASSERT2(e,msg) if debugIsOn && not (e) then (assertPprPanic __FILE__ __LINE__ (msg)) else
51 #define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg)) $
52
53 -- Examples: Assuming flagSet :: String -> m Bool
54 --
55 -- do { c <- getChar; MASSERT( isUpper c ); ... }
56 -- do { c <- getChar; MASSERT2( isUpper c, text "Bad" ); ... }
57 -- do { str <- getStr; ASSERTM( flagSet str ); .. }
58 -- do { str <- getStr; ASSERTM2( flagSet str, text "Bad" ); .. }
59 -- do { str <- getStr; WARNM2( flagSet str, text "Flag is set" ); .. }
60 #define MASSERT(e) ASSERT(e) return ()
61 #define MASSERT2(e,msg) ASSERT2(e,msg) return ()
62 #define ASSERTM(e) do { bool <- e; MASSERT(bool) }
63 #define ASSERTM2(e,msg) do { bool <- e; MASSERT2(bool,msg) }
64 #define WARNM2(e,msg) do { bool <- e; WARN(bool, msg) return () }
65
66 -- Useful for declaring arguments to be strict
67 #define STRICT1(f) f a | a `seq` False = undefined
68 #define STRICT2(f) f a b | a `seq` b `seq` False = undefined
69 #define STRICT3(f) f a b c | a `seq` b `seq` c `seq` False = undefined
70 #define STRICT4(f) f a b c d | a `seq` b `seq` c `seq` d `seq` False = undefined
71 #define STRICT5(f) f a b c d e | a `seq` b `seq` c `seq` d `seq` e `seq` False = undefined
72 #define STRICT6(f) f a b c d e f | a `seq` b `seq` c `seq` d `seq` e `seq` f `seq` False = undefined
73
74 #endif /* HsVersions.h */
75