39285ba3de62e0759acd2abb73df897ad83c4dee
[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 = Util.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 -- temporary usage assertion control KSW 2000-10
32 #ifdef DO_USAGES
33 #define UASSERT(e) ASSERT(e)
34 #define UASSERT2(e,msg) ASSERT2(e,msg)
35 #else
36 #define UASSERT(e)
37 #define UASSERT2(e,msg)
38 #endif
39
40 #if __STDC__
41 #define CAT2(a,b)a##b
42 #else
43 #define CAT2(a,b)a/**/b
44 #endif
45
46 #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 202
47 # define failWith fail
48 # define MkIOError(h,errt,msg) (IOError (Just h) errt msg)
49 # define minInt (minBound::Int)
50 # define maxInt (maxBound::Int)
51 #else
52 # define MkIOError(h,errt,msg) (errt msg)
53 #endif
54
55 #if __GLASGOW_HASKELL__ >= 23
56
57 -- This #ifndef lets us switch off the "import FastString"
58 -- when compiling FastString itself
59 #ifndef COMPILING_FAST_STRING
60 -- 
61 import qualified FastString 
62 #endif
63
64 # define USE_FAST_STRINGS 1
65 # define FAST_STRING    FastString.FastString
66 # define SLIT(x)        (FastString.mkFastCharString# (x#))
67 # define _NULL_         FastString.nullFastString
68 # define _NIL_          (FastString.mkFastString "")
69 # define _CONS_         FastString.consFS
70 # define _HEAD_         FastString.headFS
71 # define _HEAD_INT_     FastString.headIntFS
72 # define _TAIL_         FastString.tailFS
73 # define _LENGTH_       FastString.lengthFS
74 # define _PK_           FastString.mkFastString
75 # define _PK_INT_       FastString.mkFastStringInt
76 # define _UNPK_         FastString.unpackFS
77 # define _UNPK_INT_     FastString.unpackIntFS
78 # define _APPEND_       `FastString.appendFS`
79 # define _CONCAT_       FastString.concatFS
80 #else
81 # error I think that FastString is now always used. If not, fix this.
82 # define FAST_STRING String
83 # define SLIT(x)      (x)
84 # define _CMP_STRING_ cmpString
85 # define _NULL_       null
86 # define _NIL_        ""
87 # define _CONS_       (:)
88 # define _HEAD_       head
89 # define _TAIL_       tail
90 # define _LENGTH_     length
91 # define _PK_         (\x->x)
92 # define _UNPK_       (\x->x)
93 # define _SUBSTR_     substr{-from Utils-}
94 # define _APPEND_     ++
95 # define _CONCAT_     concat
96 #endif
97
98 #if __HASKELL1__ > 4
99 # define FMAP fmap
100 # define ISALPHANUM isAlphaNum
101 # define IOERROR ioError
102 # define PSEQ seq
103 # define SAPPLY $!
104 #else
105 # define FMAP map
106 # define ISALPHANUM isAlphanum
107 # define IOERROR fail
108 # define PSEQ (\x y -> y)
109 # define SAPPLY $
110 #endif
111
112 #endif