Float unboxed expressions by boxing
[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 "ghcautoconf.h"
24
25 #define GLOBAL_VAR(name,value,ty) \
26 {-# NOINLINE name #-}; \
27 name :: IORef (ty); \
28 name = Util.global (value);
29
30 #define GLOBAL_VAR_M(name,value,ty) \
31 {-# NOINLINE name #-}; \
32 name :: IORef (ty); \
33 name = Util.globalM (value);
34
35
36 #define SHARED_GLOBAL_VAR(name,accessor,saccessor,value,ty) \
37 {-# NOINLINE name #-}; \
38 name :: IORef (ty); \
39 name = Util.sharedGlobal (value) (accessor); \
40 foreign import ccall unsafe saccessor \
41 accessor :: Ptr (IORef a) -> IO (Ptr (IORef a));
42
43 #define SHARED_GLOBAL_VAR_M(name,accessor,saccessor,value,ty) \
44 {-# NOINLINE name #-}; \
45 name :: IORef (ty); \
46 name = Util.sharedGlobalM (value) (accessor); \
47 foreign import ccall unsafe saccessor \
48 accessor :: Ptr (IORef a) -> IO (Ptr (IORef a));
49
50
51 #define ASSERT(e) if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else
52 #define ASSERT2(e,msg) if debugIsOn && not (e) then (assertPprPanic __FILE__ __LINE__ (msg)) else
53 #define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg)) $
54
55 -- Examples: Assuming flagSet :: String -> m Bool
56 --
57 -- do { c <- getChar; MASSERT( isUpper c ); ... }
58 -- do { c <- getChar; MASSERT2( isUpper c, text "Bad" ); ... }
59 -- do { str <- getStr; ASSERTM( flagSet str ); .. }
60 -- do { str <- getStr; ASSERTM2( flagSet str, text "Bad" ); .. }
61 -- do { str <- getStr; WARNM2( flagSet str, text "Flag is set" ); .. }
62 #define MASSERT(e) ASSERT(e) return ()
63 #define MASSERT2(e,msg) ASSERT2(e,msg) return ()
64 #define ASSERTM(e) do { bool <- e; MASSERT(bool) }
65 #define ASSERTM2(e,msg) do { bool <- e; MASSERT2(bool,msg) }
66 #define WARNM2(e,msg) do { bool <- e; WARN(bool, msg) return () }
67
68 #endif /* HsVersions.h */
69