aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/ghc-basement-fix-32bit.patch
blob: 7407b2ef758c065c900be29cf0e9fd65a6902d24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
https://github.com/haskell-foundation/foundation/pull/573
https://github.com/haskell-foundation/foundation/commit/38be2c93acb6f459d24ed6c626981c35ccf44095.patch

Changes made:
Changed '904' to '902' to use the fix with GHC-9.2.

diff --git a/Basement/Bits.hs b/Basement/Bits.hs
index 7eeea0f..b1e9afd 100644
--- a/Basement/Bits.hs
+++ b/Basement/Bits.hs
@@ -54,8 +54,12 @@ import GHC.Int
 import Basement.Compat.Primitive
 
 #if WORD_SIZE_IN_BITS < 64
+#if __GLASGOW_HASKELL__ >= 902
+import GHC.Exts
+#else
 import GHC.IntWord64
 #endif
+#endif
 
 -- | operation over finite bits
 class FiniteBitsOps bits where
diff --git a/Basement/Numerical/Additive.hs b/Basement/Numerical/Additive.hs
index d0dfb97..79b7033 100644
--- a/Basement/Numerical/Additive.hs
+++ b/Basement/Numerical/Additive.hs
@@ -30,8 +30,12 @@ import qualified Basement.Types.Word128 as Word128
 import qualified Basement.Types.Word256 as Word256
 
 #if WORD_SIZE_IN_BITS < 64
+#if __GLASGOW_HASKELL__ >= 902
+import           GHC.Exts
+#else
 import           GHC.IntWord64
 #endif
+#endif
 
 -- | Represent class of things that can be added together,
 -- contains a neutral element and is commutative.
diff --git a/Basement/Numerical/Conversion.hs b/Basement/Numerical/Conversion.hs
index db502c0..abb6d93 100644
--- a/Basement/Numerical/Conversion.hs
+++ b/Basement/Numerical/Conversion.hs
@@ -26,8 +26,12 @@ import GHC.Word
 import Basement.Compat.Primitive
 
 #if WORD_SIZE_IN_BITS < 64
+#if __GLASGOW_HASKELL__ >= 902
+import GHC.Exts
+#else
 import GHC.IntWord64
 #endif
+#endif
 
 intToInt64 :: Int -> Int64
 #if WORD_SIZE_IN_BITS == 64
@@ -96,11 +100,22 @@ int64ToWord64 (I64# i) = W64# (int64ToWord64# i)
 #endif
 
 #if WORD_SIZE_IN_BITS == 64
+#if __GLASGOW_HASKELL__ >= 904
+word64ToWord# :: Word64# -> Word#
+word64ToWord# i = word64ToWord# i
+#else
 word64ToWord# :: Word# -> Word#
 word64ToWord# i = i
+#endif
 {-# INLINE word64ToWord# #-}
 #endif
 
+#if WORD_SIZE_IN_BITS < 64
+word64ToWord32# :: Word64# -> Word32#
+word64ToWord32# i = wordToWord32# (word64ToWord# i)
+{-# INLINE word64ToWord32# #-}
+#endif
+
 -- | 2 Word32s
 data Word32x2 = Word32x2 {-# UNPACK #-} !Word32
                          {-# UNPACK #-} !Word32
@@ -113,9 +128,14 @@ word64ToWord32s (W64# w64) = Word32x2 (W32# (wordToWord32# (uncheckedShiftRL# (G
 word64ToWord32s (W64# w64) = Word32x2 (W32# (wordToWord32# (uncheckedShiftRL# w64 32#))) (W32# (wordToWord32# w64))
 #endif
 #else
+#if __GLASGOW_HASKELL__ >= 902
+word64ToWord32s :: Word64 -> Word32x2
+word64ToWord32s (W64# w64) = Word32x2 (W32# (word64ToWord32# (uncheckedShiftRL64# w64 32#))) (W32# (word64ToWord32# w64))
+#else
 word64ToWord32s :: Word64 -> Word32x2
 word64ToWord32s (W64# w64) = Word32x2 (W32# (word64ToWord# (uncheckedShiftRL64# w64 32#))) (W32# (word64ToWord# w64))
 #endif
+#endif
 
 wordToChar :: Word -> Char
 wordToChar (W# word) = C# (chr# (word2Int# word))
diff --git a/Basement/PrimType.hs b/Basement/PrimType.hs
index f8ca292..b8fbaf7 100644
--- a/Basement/PrimType.hs
+++ b/Basement/PrimType.hs
@@ -54,7 +54,11 @@ import           Basement.Nat
 import qualified Prelude (quot)
 
 #if WORD_SIZE_IN_BITS < 64
-import           GHC.IntWord64
+#if __GLASGOW_HASKELL__ >= 902
+import GHC.Exts
+#else
+import GHC.IntWord64
+#endif
 #endif
 
 #ifdef FOUNDATION_BOUNDS_CHECK
diff --git a/Basement/Types/OffsetSize.hs b/Basement/Types/OffsetSize.hs
index cd94492..b2903ba 100644
--- a/Basement/Types/OffsetSize.hs
+++ b/Basement/Types/OffsetSize.hs
@@ -70,8 +70,12 @@ import Data.List (foldl')
 import qualified Prelude
 
 #if WORD_SIZE_IN_BITS < 64
+#if __GLASGOW_HASKELL__ >= 902
+import GHC.Exts
+#else
 import GHC.IntWord64
 #endif
+#endif
 
 -- | File size in bytes
 newtype FileSize = FileSize Word64
@@ -225,7 +229,11 @@ countOfRoundUp alignment (CountOf n) = CountOf ((n + (alignment-1)) .&. compleme
 
 csizeOfSize :: CountOf Word8 -> CSize
 #if WORD_SIZE_IN_BITS < 64
+#if __GLASGOW_HASKELL__ >= 902
+csizeOfSize (CountOf (I# sz)) = CSize (W32# (wordToWord32# (int2Word# sz)))
+#else
 csizeOfSize (CountOf (I# sz)) = CSize (W32# (int2Word# sz))
+#endif
 #else
 #if __GLASGOW_HASKELL__ >= 904
 csizeOfSize (CountOf (I# sz)) = CSize (W64# (wordToWord64# (int2Word# sz)))
@@ -238,7 +246,11 @@ csizeOfSize (CountOf (I# sz)) = CSize (W64# (int2Word# sz))
 
 csizeOfOffset :: Offset8 -> CSize
 #if WORD_SIZE_IN_BITS < 64
+#if __GLASGOW_HASKELL__ >= 902
+csizeOfOffset (Offset (I# sz)) = CSize (W32# (wordToWord32# (int2Word# sz)))
+#else
 csizeOfOffset (Offset (I# sz)) = CSize (W32# (int2Word# sz))
+#endif
 #else
 #if __GLASGOW_HASKELL__ >= 904
 csizeOfOffset (Offset (I# sz)) = CSize (W64# (wordToWord64# (int2Word# sz)))
@@ -250,7 +262,11 @@ csizeOfOffset (Offset (I# sz)) = CSize (W64# (int2Word# sz))
 sizeOfCSSize :: CSsize -> CountOf Word8
 sizeOfCSSize (CSsize (-1))      = error "invalid size: CSSize is -1"
 #if WORD_SIZE_IN_BITS < 64
+#if __GLASGOW_HASKELL__ >= 902
+sizeOfCSSize (CSsize (I32# sz)) = CountOf (I# (int32ToInt# sz))
+#else
 sizeOfCSSize (CSsize (I32# sz)) = CountOf (I# sz)
+#endif
 #else
 #if __GLASGOW_HASKELL__ >= 904
 sizeOfCSSize (CSsize (I64# sz)) = CountOf (I# (int64ToInt# sz))
@@ -261,7 +277,11 @@ sizeOfCSSize (CSsize (I64# sz)) = CountOf (I# sz)
 
 sizeOfCSize :: CSize -> CountOf Word8
 #if WORD_SIZE_IN_BITS < 64
+#if __GLASGOW_HASKELL__ >= 902
+sizeOfCSize (CSize (W32# sz)) = CountOf (I# (word2Int# (word32ToWord# sz)))
+#else
 sizeOfCSize (CSize (W32# sz)) = CountOf (I# (word2Int# sz))
+#endif
 #else
 #if __GLASGOW_HASKELL__ >= 904
 sizeOfCSize (CSize (W64# sz)) = CountOf (I# (word2Int# (word64ToWord# sz)))