Support GHC 9.4 (#29)
This commit is contained in:
parent
4fc69c259e
commit
214e655199
3 changed files with 69 additions and 14 deletions
|
@ -49,7 +49,7 @@ library
|
||||||
reexported-modules:
|
reexported-modules:
|
||||||
Data.Bytes.Chunks
|
Data.Bytes.Chunks
|
||||||
build-depends:
|
build-depends:
|
||||||
, base >=4.12.0.0 && <4.17
|
, base >=4.12.0.0 && <4.18
|
||||||
, byteslice >=0.2.6 && <0.3
|
, byteslice >=0.2.6 && <0.3
|
||||||
, bytestring >=0.10.8.2 && <0.12
|
, bytestring >=0.10.8.2 && <0.12
|
||||||
, haskell-src-meta >=0.8
|
, haskell-src-meta >=0.8
|
||||||
|
@ -102,7 +102,7 @@ test-suite test
|
||||||
, tasty >=1.2.3 && <1.5
|
, tasty >=1.2.3 && <1.5
|
||||||
, tasty-hunit >=0.10.0.2 && <0.11
|
, tasty-hunit >=0.10.0.2 && <0.11
|
||||||
, tasty-quickcheck >=0.10.1 && <0.11
|
, tasty-quickcheck >=0.10.1 && <0.11
|
||||||
, text >=1.2 && <1.3
|
, text >=1.2 && <2.2
|
||||||
, vector
|
, vector
|
||||||
, wide-word >=0.1.0.9 && <0.2
|
, wide-word >=0.1.0.9 && <0.2
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
module Op
|
module Op
|
||||||
( writeCharArray#
|
( writeCharArray#
|
||||||
, copyByteArray#
|
, copyByteArray#
|
||||||
|
, copyMutableByteArray#
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import GHC.Exts (writeCharArray#,copyByteArray#,copyMutableByteArray#)
|
import GHC.Exts (copyMutableByteArray#,writeCharArray#,copyByteArray#,copyMutableByteArray#)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
{-# language CPP #-}
|
||||||
{-# language BangPatterns #-}
|
{-# language BangPatterns #-}
|
||||||
{-# language BinaryLiterals #-}
|
{-# language BinaryLiterals #-}
|
||||||
{-# language DataKinds #-}
|
{-# language DataKinds #-}
|
||||||
|
@ -227,7 +228,12 @@ doubleDec (D# d) = Builder (\arr off0 s0 -> doubleDec# d arr off0 s0)
|
||||||
-- | Requires up to 19 bytes. Encodes an unsigned 64-bit integer as decimal.
|
-- | Requires up to 19 bytes. Encodes an unsigned 64-bit integer as decimal.
|
||||||
-- This encoding never starts with a zero unless the argument was zero.
|
-- This encoding never starts with a zero unless the argument was zero.
|
||||||
word64Dec :: Word64 -> Builder 19
|
word64Dec :: Word64 -> Builder 19
|
||||||
word64Dec (W64# w) = wordCommonDec# w
|
word64Dec (W64# w) = wordCommonDec#
|
||||||
|
#if MIN_VERSION_base(4,17,0)
|
||||||
|
(word64ToWord# w)
|
||||||
|
#else
|
||||||
|
w
|
||||||
|
#endif
|
||||||
|
|
||||||
-- | Requires up to 10 bytes. Encodes an unsigned 32-bit integer as decimal.
|
-- | Requires up to 10 bytes. Encodes an unsigned 32-bit integer as decimal.
|
||||||
-- This encoding never starts with a zero unless the argument was zero.
|
-- This encoding never starts with a zero unless the argument was zero.
|
||||||
|
@ -262,7 +268,12 @@ wordDec (W# w) = wordCommonDec# w
|
||||||
-- Negative numbers are preceded by a minus sign. Positive numbers
|
-- Negative numbers are preceded by a minus sign. Positive numbers
|
||||||
-- are not preceded by anything.
|
-- are not preceded by anything.
|
||||||
int64Dec :: Int64 -> Builder 20
|
int64Dec :: Int64 -> Builder 20
|
||||||
int64Dec (I64# w) = intCommonDec# w
|
int64Dec (I64# w) = intCommonDec#
|
||||||
|
#if MIN_VERSION_base(4,17,0)
|
||||||
|
(int64ToInt# w)
|
||||||
|
#else
|
||||||
|
w
|
||||||
|
#endif
|
||||||
|
|
||||||
-- | Requires up to 11 bytes. Encodes a signed 32-bit integer as decimal.
|
-- | Requires up to 11 bytes. Encodes a signed 32-bit integer as decimal.
|
||||||
-- This encoding never starts with a zero unless the argument was zero.
|
-- This encoding never starts with a zero unless the argument was zero.
|
||||||
|
@ -318,7 +329,12 @@ wordCommonDec# w# = Unsafe.construct $ \arr off0 -> if w /= 0
|
||||||
writeByteArray arr off0 (c2w '0')
|
writeByteArray arr off0 (c2w '0')
|
||||||
pure (off0 + 1)
|
pure (off0 + 1)
|
||||||
where
|
where
|
||||||
w = W64# w#
|
w = W64#
|
||||||
|
#if MIN_VERSION_base(4,17,0)
|
||||||
|
(wordToWord64# w#)
|
||||||
|
#else
|
||||||
|
w#
|
||||||
|
#endif
|
||||||
|
|
||||||
internalWordLoop :: MutableByteArray s -> Int -> Word -> ST s Int
|
internalWordLoop :: MutableByteArray s -> Int -> Word -> ST s Int
|
||||||
{-# inline internalWordLoop #-}
|
{-# inline internalWordLoop #-}
|
||||||
|
@ -350,7 +366,12 @@ intCommonDec# w# = Unsafe.construct $ \arr off0 -> case compare w 0 of
|
||||||
writeByteArray arr off0 (c2w '-')
|
writeByteArray arr off0 (c2w '-')
|
||||||
internalWordLoop arr (off0 + 1) (fromIntegral (negate w))
|
internalWordLoop arr (off0 + 1) (fromIntegral (negate w))
|
||||||
where
|
where
|
||||||
w = I64# w#
|
w = I64#
|
||||||
|
#if MIN_VERSION_base(4,17,0)
|
||||||
|
(intToInt64# w#)
|
||||||
|
#else
|
||||||
|
w#
|
||||||
|
#endif
|
||||||
|
|
||||||
-- Convert a number between 0 and 16 to the ASCII
|
-- Convert a number between 0 and 16 to the ASCII
|
||||||
-- representation of its hexadecimal character.
|
-- representation of its hexadecimal character.
|
||||||
|
@ -422,14 +443,25 @@ word128PaddedUpperHex (Word128 w64 w0) =
|
||||||
-- uppercase for the alphabetical digits. For example, this encodes the
|
-- uppercase for the alphabetical digits. For example, this encodes the
|
||||||
-- number 1022 as @00000000000003FE@.
|
-- number 1022 as @00000000000003FE@.
|
||||||
word64PaddedUpperHex :: Word64 -> Builder 16
|
word64PaddedUpperHex :: Word64 -> Builder 16
|
||||||
word64PaddedUpperHex (W64# w) = word64PaddedUpperHex# w
|
word64PaddedUpperHex (W64# w) = word64PaddedUpperHex#
|
||||||
|
#if MIN_VERSION_base(4,17,0)
|
||||||
|
(word64ToWord# w)
|
||||||
|
#else
|
||||||
|
w
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
-- | Requires exactly 16 bytes. Encodes a 64-bit unsigned integer as
|
-- | Requires exactly 16 bytes. Encodes a 64-bit unsigned integer as
|
||||||
-- hexadecimal, zero-padding the encoding to 16 digits. This uses
|
-- hexadecimal, zero-padding the encoding to 16 digits. This uses
|
||||||
-- lowercase for the alphabetical digits. For example, this encodes the
|
-- lowercase for the alphabetical digits. For example, this encodes the
|
||||||
-- number 1022 as @00000000000003fe@.
|
-- number 1022 as @00000000000003fe@.
|
||||||
word64PaddedLowerHex :: Word64 -> Builder 16
|
word64PaddedLowerHex :: Word64 -> Builder 16
|
||||||
word64PaddedLowerHex (W64# w) = word64PaddedLowerHex# w
|
word64PaddedLowerHex (W64# w) = word64PaddedLowerHex#
|
||||||
|
#if MIN_VERSION_base(4,17,0)
|
||||||
|
(word64ToWord# w)
|
||||||
|
#else
|
||||||
|
w
|
||||||
|
#endif
|
||||||
|
|
||||||
-- | Requires exactly 12 bytes. Discards the upper 16 bits of a
|
-- | Requires exactly 12 bytes. Discards the upper 16 bits of a
|
||||||
-- 64-bit unsigned integer and then encodes the lower 48 bits as
|
-- 64-bit unsigned integer and then encodes the lower 48 bits as
|
||||||
|
@ -437,7 +469,12 @@ word64PaddedLowerHex (W64# w) = word64PaddedLowerHex# w
|
||||||
-- lowercase for the alphabetical digits. For example, this encodes the
|
-- lowercase for the alphabetical digits. For example, this encodes the
|
||||||
-- number 1022 as @0000000003fe@.
|
-- number 1022 as @0000000003fe@.
|
||||||
word48PaddedLowerHex :: Word64 -> Builder 12
|
word48PaddedLowerHex :: Word64 -> Builder 12
|
||||||
word48PaddedLowerHex (W64# w) = word48PaddedLowerHex# w
|
word48PaddedLowerHex (W64# w) = word48PaddedLowerHex#
|
||||||
|
#if MIN_VERSION_base(4,17,0)
|
||||||
|
(word64ToWord# w)
|
||||||
|
#else
|
||||||
|
w
|
||||||
|
#endif
|
||||||
|
|
||||||
-- | Requires exactly 8 bytes. Encodes a 32-bit unsigned integer as
|
-- | Requires exactly 8 bytes. Encodes a 32-bit unsigned integer as
|
||||||
-- hexadecimal, zero-padding the encoding to 8 digits. This uses
|
-- hexadecimal, zero-padding the encoding to 8 digits. This uses
|
||||||
|
@ -862,7 +899,13 @@ word32LEB128 (W32# w) = lebCommon (W# (C.word32ToWord# w))
|
||||||
-- | Encode a 64-bit word with LEB-128.
|
-- | Encode a 64-bit word with LEB-128.
|
||||||
word64LEB128 :: Word64 -> Builder 10
|
word64LEB128 :: Word64 -> Builder 10
|
||||||
{-# inline word64LEB128 #-}
|
{-# inline word64LEB128 #-}
|
||||||
word64LEB128 (W64# w) = lebCommon (W# w)
|
word64LEB128 (W64# w) = lebCommon (W#
|
||||||
|
#if MIN_VERSION_base(4,17,0)
|
||||||
|
(word64ToWord# w)
|
||||||
|
#else
|
||||||
|
w
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
|
||||||
lebCommon :: Word -> Builder n
|
lebCommon :: Word -> Builder n
|
||||||
lebCommon !w = case quotRem w 128 of
|
lebCommon !w = case quotRem w 128 of
|
||||||
|
@ -935,7 +978,12 @@ char c
|
||||||
byteFourFour w = (0b00111111 .&. w) .|. 0b10000000
|
byteFourFour w = (0b00111111 .&. w) .|. 0b10000000
|
||||||
|
|
||||||
int64BE :: Int64 -> Builder 8
|
int64BE :: Int64 -> Builder 8
|
||||||
int64BE (I64# i) = word64BE (W64# (int2Word# i))
|
int64BE (I64# i) = word64BE (W64# (
|
||||||
|
#if MIN_VERSION_base(4,17,0)
|
||||||
|
wordToWord64# (int2Word# (int64ToInt# i))))
|
||||||
|
#else
|
||||||
|
int2Word# i))
|
||||||
|
#endif
|
||||||
|
|
||||||
int32BE :: Int32 -> Builder 4
|
int32BE :: Int32 -> Builder 4
|
||||||
int32BE (I32# i) = word32BE (W32# (C.wordToWord32# (int2Word# (C.int32ToInt# i))))
|
int32BE (I32# i) = word32BE (W32# (C.wordToWord32# (int2Word# (C.int32ToInt# i))))
|
||||||
|
@ -944,7 +992,13 @@ int16BE :: Int16 -> Builder 2
|
||||||
int16BE (I16# i) = word16BE (W16# (C.wordToWord16# (int2Word# (C.int16ToInt# i))))
|
int16BE (I16# i) = word16BE (W16# (C.wordToWord16# (int2Word# (C.int16ToInt# i))))
|
||||||
|
|
||||||
int64LE :: Int64 -> Builder 8
|
int64LE :: Int64 -> Builder 8
|
||||||
int64LE (I64# i) = word64LE (W64# (int2Word# i))
|
int64LE (I64# i) = word64LE (W64# (
|
||||||
|
#if MIN_VERSION_base(4,17,0)
|
||||||
|
wordToWord64# (int2Word# (int64ToInt# i))))
|
||||||
|
#else
|
||||||
|
int2Word# i))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int32LE :: Int32 -> Builder 4
|
int32LE :: Int32 -> Builder 4
|
||||||
int32LE (I32# i) = word32LE (W32# (C.wordToWord32# (int2Word# (C.int32ToInt# i))))
|
int32LE (I32# i) = word32LE (W32# (C.wordToWord32# (int2Word# (C.int32ToInt# i))))
|
||||||
|
|
Loading…
Reference in a new issue