{-# OPTIONS_GHC -optc-DXXH_STATIC_LINKING_ONLY #-}
{-# LINE 1 "src/Data/Digest/XXHash/FFI/C.hsc" #-}
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UnliftedFFITypes #-}
module Data.Digest.XXHash.FFI.C (
c_xxh3_64bits_withSeed
, c_xxh3_64bits_withSeed_safe
, c_xxh64
, c_xxh64_safe
, c_xxh32
, c_xxh32_safe
, XXH32State
, allocaXXH32State
, c_xxh32_copyState
, c_xxh32_reset
, c_xxh32_update
, c_xxh32_update_safe
, c_xxh32_digest
, XXH64State
, allocaXXH64State
, c_xxh64_copyState
, c_xxh64_reset
, c_xxh64_update
, c_xxh64_update_safe
, c_xxh64_digest
, XXH3State
, allocaXXH3State
, c_xxh3_copyState
, c_xxh3_64bits_reset_withSeed
, c_xxh3_64bits_update
, c_xxh3_64bits_update_safe
, c_xxh3_64bits_digest
) where
import Foreign.C.Types
import Foreign.Ptr (Ptr)
import GHC.Exts (Int(..), RealWorld,
MutableByteArray#, newPinnedByteArray#)
import GHC.IO (IO(IO))
foreign import capi unsafe "xxhash.h XXH3_64bits_withSeed" c_xxh3_64bits_withSeed ::
Ptr a
-> CSize
-> CULLong
-> IO CULLong
foreign import capi safe "xxhash.h XXH3_64bits_withSeed" c_xxh3_64bits_withSeed_safe ::
Ptr a
-> CSize
-> CULLong
-> IO CULLong
foreign import capi unsafe "xxhash.h XXH64" c_xxh64 ::
Ptr a
-> CSize
-> CULLong
-> IO CULLong
foreign import capi safe "xxhash.h XXH64" c_xxh64_safe ::
Ptr a
-> CSize
-> CULLong
-> IO CULLong
foreign import capi unsafe "xxhash.h XXH32" c_xxh32 ::
Ptr a
-> CSize
-> CUInt
-> IO CUInt
foreign import capi safe "xxhash.h XXH32" c_xxh32_safe ::
Ptr a
-> CSize
-> CUInt
-> IO CUInt
type XXH32State = MutableByteArray# RealWorld
foreign import capi unsafe "xxhash.h XXH32_copyState" c_xxh32_copyState ::
XXH32State
-> XXH32State
-> IO ()
foreign import capi unsafe "xxhash.h XXH32_reset" c_xxh32_reset ::
XXH32State
-> CUInt
-> IO ()
foreign import capi unsafe "xxhash.h XXH32_update" c_xxh32_update ::
XXH32State
-> Ptr a
-> CSize
-> IO ()
foreign import capi safe "xxhash.h XXH32_update" c_xxh32_update_safe ::
XXH32State
-> Ptr a
-> CSize
-> IO ()
foreign import capi unsafe "xxhash.h XXH32_digest" c_xxh32_digest ::
XXH32State
-> IO CUInt
type XXH64State = MutableByteArray# RealWorld
foreign import capi unsafe "xxhash.h XXH64_copyState" c_xxh64_copyState ::
XXH64State
-> XXH64State
-> IO ()
foreign import capi unsafe "xxhash.h XXH64_reset" c_xxh64_reset ::
XXH64State
-> CULLong
-> IO ()
foreign import capi unsafe "xxhash.h XXH64_update" c_xxh64_update ::
XXH64State
-> Ptr a
-> CSize
-> IO ()
foreign import capi safe "xxhash.h XXH64_update" c_xxh64_update_safe ::
XXH64State
-> Ptr a
-> CSize
-> IO ()
foreign import capi unsafe "xxhash.h XXH64_digest" c_xxh64_digest ::
XXH64State
-> IO CULLong
type XXH3State = MutableByteArray# RealWorld
foreign import capi unsafe "xxhash.h XXH3_copyState" c_xxh3_copyState ::
XXH3State
-> XXH3State
-> IO ()
foreign import capi unsafe "xxhash.h XXH3_64bits_reset_withSeed" c_xxh3_64bits_reset_withSeed ::
XXH3State
-> CULLong
-> IO ()
foreign import capi unsafe "xxhash.h XXH3_64bits_update" c_xxh3_64bits_update ::
XXH3State
-> Ptr a
-> CSize
-> IO ()
foreign import capi safe "xxhash.h XXH3_64bits_update" c_xxh3_64bits_update_safe ::
XXH3State
-> Ptr a
-> CSize
-> IO ()
foreign import capi unsafe "xxhash.h XXH3_64bits_digest" c_xxh3_64bits_digest ::
XXH3State
-> IO CULLong
{-# INLINE allocaMutableByteArray #-}
allocaMutableByteArray :: Int -> (MutableByteArray# RealWorld -> IO b) -> IO b
allocaMutableByteArray :: forall b. Int -> (MutableByteArray# RealWorld -> IO b) -> IO b
allocaMutableByteArray (I# Int#
len) MutableByteArray# RealWorld -> IO b
f = (State# RealWorld -> (# State# RealWorld, b #)) -> IO b
forall a. (State# RealWorld -> (# State# RealWorld, a #)) -> IO a
IO ((State# RealWorld -> (# State# RealWorld, b #)) -> IO b)
-> (State# RealWorld -> (# State# RealWorld, b #)) -> IO b
forall a b. (a -> b) -> a -> b
$ \State# RealWorld
s0 ->
case Int#
-> State# RealWorld
-> (# State# RealWorld, MutableByteArray# RealWorld #)
forall d. Int# -> State# d -> (# State# d, MutableByteArray# d #)
newPinnedByteArray# Int#
len State# RealWorld
s0 of { (# State# RealWorld
s1, MutableByteArray# RealWorld
mba #) ->
case MutableByteArray# RealWorld -> IO b
f MutableByteArray# RealWorld
mba of { IO State# RealWorld -> (# State# RealWorld, b #)
m -> State# RealWorld -> (# State# RealWorld, b #)
m State# RealWorld
s1 }}
{-# INLINE allocaXXH32State #-}
allocaXXH32State :: (XXH32State -> IO a) -> IO a
allocaXXH32State :: forall a. (MutableByteArray# RealWorld -> IO a) -> IO a
allocaXXH32State = Int -> (MutableByteArray# RealWorld -> IO a) -> IO a
forall b. Int -> (MutableByteArray# RealWorld -> IO b) -> IO b
allocaMutableByteArray (Int
48)
{-# LINE 226 "src/Data/Digest/XXHash/FFI/C.hsc" #-}
{-# INLINE allocaXXH64State #-}
allocaXXH64State :: (XXH64State -> IO a) -> IO a
allocaXXH64State :: forall a. (MutableByteArray# RealWorld -> IO a) -> IO a
allocaXXH64State = Int -> (MutableByteArray# RealWorld -> IO a) -> IO a
forall b. Int -> (MutableByteArray# RealWorld -> IO b) -> IO b
allocaMutableByteArray (Int
88)
{-# LINE 232 "src/Data/Digest/XXHash/FFI/C.hsc" #-}
{-# INLINE allocaXXH3State #-}
allocaXXH3State :: (XXH3State -> IO a) -> IO a
allocaXXH3State :: forall a. (MutableByteArray# RealWorld -> IO a) -> IO a
allocaXXH3State = Int -> (MutableByteArray# RealWorld -> IO a) -> IO a
forall b. Int -> (MutableByteArray# RealWorld -> IO b) -> IO b
allocaMutableByteArray (Int
576)
{-# LINE 238 "src/Data/Digest/XXHash/FFI/C.hsc" #-}