Copyright | (c) 2017 Henri Verroken |
---|---|
License | BSD3 |
Maintainer | Henri Verroken <henriverroken@gmail.com |
Stability | stable |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
This module provides FFI imports to the C reference library at https://github.com/Cyan4973/xxHash.
This binding keeps the intermediate state for stream processing in an
MutableByteArray#
on the managed GHC heap. All foreign imports use unsafe
call semantics. Therefore, it is possible to use either unpinned or pinned
MutableByteArray#
since GHC's garbage collector doesn't move the either
kind during an unsafe foreign call. However GHCi <8.4 may replace unsafe
foreign calls with safe foreign calls in the bytecode
interpreter. Consequently, unpinned 'MutableByteArray#s' may be moved by the
garbage collector during foreign calls which obviously breaks this code. So
extra care should be taken when loading this code into the bytecode
interpreter.
- c_xxh64 :: Ptr a -> CSize -> CULLong -> IO CULLong
- c_xxh32 :: Ptr a -> CSize -> CUInt -> IO CUInt
- type XXH32State = MutableByteArray# RealWorld
- allocaXXH32State :: (XXH32State -> IO a) -> IO a
- c_xxh32_copyState :: XXH32State -> XXH32State -> IO ()
- c_xxh32_reset :: XXH32State -> CUInt -> IO ()
- c_xxh32_update :: XXH32State -> Ptr a -> CSize -> IO ()
- c_xxh32_digest :: XXH32State -> IO CUInt
- type XXH64State = MutableByteArray# RealWorld
- allocaXXH64State :: (XXH64State -> IO a) -> IO a
- c_xxh64_copyState :: XXH64State -> XXH64State -> IO ()
- c_xxh64_reset :: XXH64State -> CULLong -> IO ()
- c_xxh64_update :: XXH64State -> Ptr a -> CSize -> IO ()
- c_xxh64_digest :: XXH64State -> IO CULLong
C Interface
Direct Calculation
32-bit state functions
type XXH32State = MutableByteArray# RealWorld Source #
Intermediate state for computing a XXH32 using segmentation or streams.
allocaXXH32State :: (XXH32State -> IO a) -> IO a Source #
'allocaXXH32State f' temporarily allocates a XXH32State
and passes it
to the function f
.
:: XXH32State | Destination |
-> XXH32State | Source |
-> IO () |
:: XXH32State | The state to reset |
-> CUInt | The initial seed |
-> IO () |
:: XXH32State | The state to update |
-> Ptr a |
|
-> CSize | Buffer length |
-> IO () |
:: XXH32State | The state to digest |
-> IO CUInt | Resulting hash |
64-bit state functions
type XXH64State = MutableByteArray# RealWorld Source #
Intermediate state for computing a XXH64 using segmentation or streams.
allocaXXH64State :: (XXH64State -> IO a) -> IO a Source #
'allocaXXH64State f' temporarily allocates a XXH64State
and passes it
to the function f
.
:: XXH64State | Destination |
-> XXH64State | Source |
-> IO () |
:: XXH64State | The state to reset |
-> CULLong | The initial seed |
-> IO () |
:: XXH64State | The state to update |
-> Ptr a |
|
-> CSize | Buffer length |
-> IO () |
:: XXH64State | The state to digest |
-> IO CULLong | Resulting hash |