HsVersions.h 4.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#ifndef HSVERSIONS_H
#define HSVERSIONS_H

#if 0

IMPORTANT!  If you put extra tabs/spaces in these macro definitions,
you will screw up the layout where they are used in case expressions!

(This is cpp-dependent, of course)

#endif

#define COMMA ,

#ifdef DEBUG
#define ASSERT(e) if (not (e)) then (assertPanic __FILE__ __LINE__) else
sof's avatar
sof committed
17
#define ASSERT2(e,msg) if (not (e)) then (assertPprPanic __FILE__ __LINE__ (msg)) else
18 19
#else
#define ASSERT(e)
sof's avatar
sof committed
20
#define ASSERT2(e,msg)
21
#endif
22 23 24 25 26 27 28

#if __STDC__
#define CAT2(a,b)a##b
#else
#define CAT2(a,b)a/**/b
#endif

29
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 202
30 31
# define REALLY_HASKELL_1_3
# define SYN_IE(a) a
32
# define EXP_MODULE(a) module a
sof's avatar
sof committed
33
# define IMPORT_DELOOPER(mod) import mod
34
# define IMPORT_1_3(mod) import mod
35
# define _Addr Addr
sof's avatar
sof committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49
# define _ByteArray GlaExts.ByteArray
# define _MutableByteArray GlaExts.MutableByteArray
# define _MutableArray GlaExts.MutableArray
# define _RealWorld GlaExts.RealWorld
# define _ST GlaExts.ST
# define _ForeignObj Foreign.ForeignObj
# define _runST ST.runST
# define seqStrictlyST seqST
# define thenStrictlyST thenST
# define returnStrictlyST return
# define _readHandle IOHandle.readHandle
# define _writeHandle IOHandle.writeHandle
# define _newHandle   IOHandle.newdHandle
# define MkST ST
sof's avatar
sof committed
50 51 52 53 54 55 56 57 58 59 60
# if __GLASGOW_HASKELL__ >= 209
#  define STATE_TOK(x)    x
#  define ST_RET(x,y)     STret (y) (x)
#  define unsafePerformST(x)  runST (x)
#  define ST_TO_PrimIO(x) (stToIO (x))
# else
#  define STATE_TOK(x)  (S# x)
#  define ST_RET(x,y)   (x,y)
#  define unsafePerformST(x) unsafePerformPrimIO(x)
#  define ST_TO_PrimIO(x) x
# endif
sof's avatar
sof committed
61 62 63 64 65 66
# define failWith fail
# define MkIOError(h,errt,msg) (IOError (Just h) errt msg)
# define CCALL_THEN thenIO_Prim
# define _filePtr IOHandle.filePtr
# define Text Show
# define IMP_FASTSTRING() import FastString
sof's avatar
sof committed
67 68 69 70 71 72 73
# if __GLASGOW_HASKELL__ >= 209
#  define IMP_Ubiq() import GlaExts ; import Addr(Addr(..)); import FastString
#  define CHK_Ubiq() import GlaExts ; import Addr(Addr(..)); import FastString
# else
#  define IMP_Ubiq() import GlaExts ; import FastString
#  define CHK_Ubiq() import GlaExts ; import FastString
# endif
sof's avatar
sof committed
74 75
# define minInt (minBound::Int)
# define maxInt (maxBound::Int)
76
#else
77 78 79 80
# define STATE_TOK(x)  (S# x)
# define ST_RET(x,y)   (x,y)
# define unsafePerformST(x) unsafePerformPrimIO(x)
# define ST_TO_PrimIO(x) x
81
# define SYN_IE(a) a(..)
82
# define EXP_MODULE(a) a..
83 84
# define IMPORT_DELOOPER(mod) import mod
# define IMPORT_1_3(mod) {--}
85 86 87
# define IMP_FASTSTRING() import FastString
# define IMP_Ubiq() IMPORT_DELOOPER(Ubiq) ; import FastString
# define CHK_Ubiq() IMPORT_DELOOPER(Ubiq) ; import FastString
sof's avatar
sof committed
88 89 90
# define MkST
# define CCALL_THEN thenPrimIO
# define MkIOError(h,errt,msg) (errt msg)
91
#endif
92

93
#if defined(__GLASGOW_HASKELL__)
94

95 96 97 98
-- Import the beggars
import GlaExts	( Int(..), Int#, (+#), (-#), (*#), 
		  quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
		)
99

100 101 102
#define FAST_INT Int#
#define ILIT(x) (x#)
#define IBOX(x) (I# (x))
sof's avatar
sof committed
103 104 105 106 107 108 109 110 111 112
#define _ADD_ +#
#define _SUB_ -#
#define _MUL_ *#
#define _QUOT_ `quotInt#`
#define _NEG_ negateInt#
#define _EQ_ ==#
#define _LT_ <#
#define _LE_ <=#
#define _GE_ >=#
#define _GT_ >#
113 114 115 116

#define FAST_BOOL Int#
#define _TRUE_ 1#
#define _FALSE_ 0#
sof's avatar
sof committed
117
#define _IS_TRUE_(x) ((x) _EQ_ 1#)
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142

#else {- ! __GLASGOW_HASKELL__ -}

#define FAST_INT Int
#define ILIT(x) (x)
#define IBOX(x) (x)
#define _ADD_ +
#define _SUB_ -
#define _MUL_ *
#define _DIV_ `div`
#define _QUOT_ `quot`
#define _NEG_ -
#define _EQ_ ==
#define _LT_ <
#define _LE_ <=
#define _GE_ >=
#define _GT_ >

#define FAST_BOOL Bool
#define _TRUE_ True
#define _FALSE_ False
#define _IS_TRUE_(x) (x)

#endif  {- ! __GLASGOW_HASKELL__ -}

143
#if __GLASGOW_HASKELL__ >= 23
144 145 146 147 148 149 150 151 152 153

-- This #ifndef lets us switch off the "import FastString"
-- when compiling FastString itself
#ifndef COMPILING_FAST_STRING
-- 
import FastString	( FastString, mkFastString, mkFastCharString#, nullFastString, 
			  consFS, headFS, tailFS, lengthFS, unpackFS, appendFS, concatFS
			)
#endif

154
# define USE_FAST_STRINGS 1
155 156 157 158 159 160 161 162 163 164 165 166
# define FAST_STRING	FastString
# define SLIT(x)	(mkFastCharString# (x#))
# define _NULL_		nullFastString
# define _NIL_		(mkFastString "")
# define _CONS_		consFS
# define _HEAD_		headFS
# define _TAIL_		tailFS
# define _LENGTH_	lengthFS
# define _PK_		mkFastString
# define _UNPK_		unpackFS
# define _APPEND_	`appendFS`
# define _CONCAT_	concatFS
167
#else
168 169 170 171 172 173 174 175 176 177 178 179 180 181
# define FAST_STRING String
# define SLIT(x)      (x)
# define _CMP_STRING_ cmpString
# define _NULL_	      null
# define _NIL_	      ""
# define _CONS_	      (:)
# define _HEAD_	      head
# define _TAIL_	      tail
# define _LENGTH_     length
# define _PK_	      (\x->x)
# define _UNPK_	      (\x->x)
# define _SUBSTR_     substr{-from Utils-}
# define _APPEND_     ++
# define _CONCAT_     concat
182 183 184
#endif

#endif