Minor refactoring of placeHolderPunRhs
[ghc-hetmet.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 /* This macro indicates that the target OS supports ELF-like shared libraries */
20 #if linux_TARGET_OS || freebsd_TARGET_OS
21 #define elf_OBJ_FORMAT 1
22 #endif
23
24 /* Pull in the autoconf defines (HAVE_FOO), but don't include
25  * ghcconfig.h, because that will include ghcplatform.h which has the
26  * wrong platform settings for the compiler (it has the platform
27  * settings for the target plat instead). */
28 #include "../includes/ghcautoconf.h"
29
30 /* Global variables may not work in other Haskell implementations,
31  * but we need them currently! so the conditional on GLASGOW won't do. */
32 #ifndef __HADDOCK__
33 #if defined(__GLASGOW_HASKELL__) || !defined(__GLASGOW_HASKELL__)
34 #define GLOBAL_VAR(name,value,ty)  \
35 {-# NOINLINE name #-};             \
36 name :: IORef (ty);                \
37 name = Util.global (value);
38
39 #define GLOBAL_MVAR(name,value,ty) \
40 {-# NOINLINE name #-};             \
41 name :: MVar (ty);                 \
42 name = Util.globalMVar (value);
43 #endif
44 #else /* __HADDOCK__ */
45 #define GLOBAL_VAR(name,value,ty)  \
46 name :: IORef (ty);                \
47 name = Util.global (value);
48
49 #define GLOBAL_MVAR(name,value,ty) \
50 name :: MVar (ty);                 \
51 name = Util.globalMVar (value);
52 #endif
53
54 #define COMMA ,
55
56 #ifdef DEBUG
57 #define ASSERT(e) if (not (e)) then (assertPanic __FILE__ __LINE__) else
58 #define ASSERT2(e,msg) if (not (e)) then (assertPprPanic __FILE__ __LINE__ (msg)) else
59 #define MASSERT(e)      ASSERT(e) return ()
60 #define MASSERT2(e,msg) ASSERT2(e,msg) return ()
61 #define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg))
62 #define ASSERTM(mbool) do { bool <- mbool; ASSERT(bool) return () }
63 #define ASSERTM2(mbool,msg) do { bool <- mbool; ASSERT2(bool,msg) return () }
64 #else
65 -- We have to actually use all the variables we are given or we may get
66 -- unused variable warnings when DEBUG is off.
67 #define ASSERT(e)      if False && (not (e)) then panic "ASSERT" else
68 #define ASSERT2(e,msg) if False && (const False (e,msg)) then pprPanic "ASSERT2" (msg) else
69 #define MASSERT(e)      ASSERT(e) return ()
70 #define MASSERT2(e,msg) ASSERT2(e,msg) return ()
71 #define ASSERTM(e)       do { let { _mbool = (e) } }
72 -- Here we deliberately don't use when as Control.Monad might not be imported
73 #define ASSERTM2(e,msg)  do { let { _mbool = (e) }; if False then panic "ASSERTM2" else return () }
74 #define WARN(e,msg)    if False && (e) then pprPanic "WARN" (msg) else
75 #endif
76
77 -- Useful for declaring arguments to be strict
78 #define STRICT1(f) f a | a `seq` False = undefined
79 #define STRICT2(f) f a b | a `seq` b `seq` False = undefined
80 #define STRICT3(f) f a b c | a `seq` b `seq` c `seq` False = undefined
81 #define STRICT4(f) f a b c d | a `seq` b `seq` c `seq` d `seq` False = undefined
82 #define STRICT5(f) f a b c d e | a `seq` b `seq` c `seq` d `seq` e `seq` False = undefined
83 #define STRICT6(f) f a b c d e f | a `seq` b `seq` c `seq` d `seq` e `seq` f `seq` False = undefined
84
85 #endif /* HsVersions.h */
86