xxhash-ffi-0.2.0.0: Bindings to the C implementation the xxHash algorithm

Copyright(c) 2017 Henri Verroken
LicenseBSD3
MaintainerHenri Verroken <henriverroken@gmail.com
Stabilitystable
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Data.Digest.XXHash.FFI.C

Contents

Description

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.

Synopsis

C Interface

Direct Calculation

c_xxh64 Source #

Arguments

:: Ptr a

Ptr to the input buffer

-> CSize

Buffer length

-> CULLong

Seed

-> IO CULLong

Resulting hash

c_xxh32 Source #

Arguments

:: Ptr a

Ptr to the input buffer

-> CSize

Buffer length

-> CUInt

Seed

-> IO CUInt

Resulting hash

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.

c_xxh32_copyState Source #

Arguments

:: XXH32State

Destination

-> XXH32State

Source

-> IO () 

c_xxh32_reset Source #

Arguments

:: XXH32State

The state to reset

-> CUInt

The initial seed

-> IO () 

c_xxh32_update Source #

Arguments

:: XXH32State

The state to update

-> Ptr a

Ptr to the input buffer

-> CSize

Buffer length

-> IO () 

c_xxh32_digest Source #

Arguments

:: 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.

c_xxh64_copyState Source #

Arguments

:: XXH64State

Destination

-> XXH64State

Source

-> IO () 

c_xxh64_reset Source #

Arguments

:: XXH64State

The state to reset

-> CULLong

The initial seed

-> IO () 

c_xxh64_update Source #

Arguments

:: XXH64State

The state to update

-> Ptr a

Ptr to the input buffer

-> CSize

Buffer length

-> IO () 

c_xxh64_digest Source #

Arguments

:: XXH64State

The state to digest

-> IO CULLong

Resulting hash