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