3da1db12238d311797e30f7c73598ca1f5db6092
[ghc-hetmet.git] / ghc / 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 #ifdef __GLASGOW_HASKELL__
14 #define GLOBAL_VAR(name,value,ty)  \
15 name = global (value) :: IORef (ty); \
16 {-# NOINLINE name #-}
17 #endif
18
19 #define COMMA ,
20
21 #ifdef DEBUG
22 #define ASSERT(e) if (not (e)) then (assertPanic __FILE__ __LINE__) else
23 #define ASSERT2(e,msg) if (not (e)) then (assertPprPanic __FILE__ __LINE__ (msg)) else
24 #define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg))
25 #else
26 #define ASSERT(e)
27 #define ASSERT2(e,msg)
28 #define WARN(e,msg)
29 #endif
30
31 #if __STDC__
32 #define CAT2(a,b)a##b
33 #else
34 #define CAT2(a,b)a/**/b
35 #endif
36
37 #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 202
38 # define failWith fail
39 # define MkIOError(h,errt,msg) (IOError (Just h) errt msg)
40 # define minInt (minBound::Int)
41 # define maxInt (maxBound::Int)
42 #else
43 # define MkIOError(h,errt,msg) (errt msg)
44 #endif
45
46 #if __GLASGOW_HASKELL__ >= 23
47
48 -- This #ifndef lets us switch off the "import FastString"
49 -- when compiling FastString itself
50 #ifndef COMPILING_FAST_STRING
51 -- 
52 import qualified FastString 
53 #endif
54
55 # define USE_FAST_STRINGS 1
56 # define FAST_STRING    FastString.FastString
57 # define SLIT(x)        (FastString.mkFastCharString# (x#))
58 # define _NULL_         FastString.nullFastString
59 # define _NIL_          (FastString.mkFastString "")
60 # define _CONS_         FastString.consFS
61 # define _HEAD_         FastString.headFS
62 # define _HEAD_INT_     FastString.headIntFS
63 # define _TAIL_         FastString.tailFS
64 # define _LENGTH_       FastString.lengthFS
65 # define _PK_           FastString.mkFastString
66 # define _PK_INT_       FastString.mkFastStringInt
67 # define _UNPK_         FastString.unpackFS
68 # define _UNPK_INT_     FastString.unpackIntFS
69 # define _APPEND_       `FastString.appendFS`
70 # define _CONCAT_       FastString.concatFS
71 #else
72 # error I think that FastString is now always used. If not, fix this.
73 # define FAST_STRING String
74 # define SLIT(x)      (x)
75 # define _CMP_STRING_ cmpString
76 # define _NULL_       null
77 # define _NIL_        ""
78 # define _CONS_       (:)
79 # define _HEAD_       head
80 # define _TAIL_       tail
81 # define _LENGTH_     length
82 # define _PK_         (\x->x)
83 # define _UNPK_       (\x->x)
84 # define _SUBSTR_     substr{-from Utils-}
85 # define _APPEND_     ++
86 # define _CONCAT_     concat
87 #endif
88
89 #if __HASKELL1__ > 4
90 # define FMAP fmap
91 # define ISALPHANUM isAlphaNum
92 # define IOERROR ioError
93 # define PSEQ seq
94 # define SAPPLY $!
95 #else
96 # define FMAP map
97 # define ISALPHANUM isAlphanum
98 # define IOERROR fail
99 # define PSEQ (\x y -> y)
100 # define SAPPLY $
101 #endif
102
103 #endif