HASH: Rewrite internal xxh64() to accept pointer instead of array.
Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
parent
b5183dfa0e
commit
398b3e331d
@ -195,25 +195,22 @@ module hash
|
|||||||
!
|
!
|
||||||
integer(kind=8) function digest(input, hash_type) result(hash)
|
integer(kind=8) function digest(input, hash_type) result(hash)
|
||||||
|
|
||||||
#ifdef XXHASH
|
|
||||||
use iso_c_binding, only: c_loc
|
use iso_c_binding, only: c_loc
|
||||||
#endif /* XXHASH */
|
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
integer(kind=1), dimension(:), target, intent(in) :: input
|
integer(kind=1), dimension(:), target, intent(in) :: input
|
||||||
integer , intent(in) :: hash_type
|
integer , intent(in) :: hash_type
|
||||||
|
|
||||||
#ifdef XXHASH
|
|
||||||
integer(kind=8) :: length
|
integer(kind=8) :: length
|
||||||
#endif /* XXHASH */
|
|
||||||
|
|
||||||
!-------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------
|
||||||
!
|
!
|
||||||
select case(hash_type)
|
select case(hash_type)
|
||||||
case(hash_xxh64)
|
case(hash_xxh64)
|
||||||
#ifndef XXHASH
|
#ifndef XXHASH
|
||||||
hash = xxh64(input)
|
length = size(input, kind=8)
|
||||||
|
hash = xxh64(c_loc(input), length)
|
||||||
#else /* XXHASH */
|
#else /* XXHASH */
|
||||||
length = size(input, kind=8)
|
length = size(input, kind=8)
|
||||||
hash = xxh64_lib(c_loc(input), length, 0_8)
|
hash = xxh64_lib(c_loc(input), length, 0_8)
|
||||||
@ -354,24 +351,30 @@ module hash
|
|||||||
!
|
!
|
||||||
! Arguments:
|
! Arguments:
|
||||||
!
|
!
|
||||||
! input - the input sequence of bytes;
|
! buffer - the buffer pointer;
|
||||||
|
! length - the buffer length;
|
||||||
!
|
!
|
||||||
!===============================================================================
|
!===============================================================================
|
||||||
!
|
!
|
||||||
integer(kind=8) function xxh64(input) result(hash)
|
integer(kind=8) function xxh64(buffer, length) result(hash)
|
||||||
|
|
||||||
|
use iso_c_binding, only: c_ptr, c_f_pointer
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
integer(kind=1), dimension(:), target, intent(in) :: input
|
type(c_ptr) , intent(in) :: buffer
|
||||||
|
integer(kind=8), intent(in) :: length
|
||||||
|
|
||||||
integer(kind=8) :: length
|
|
||||||
integer(kind=8) :: remaining, offset
|
integer(kind=8) :: remaining, offset
|
||||||
|
|
||||||
integer(kind=8), dimension(4) :: lane, chunk
|
integer(kind=8), dimension(4) :: lane, chunk
|
||||||
|
|
||||||
|
integer(kind=1), dimension(:), pointer :: input
|
||||||
|
|
||||||
!-------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------
|
||||||
!
|
!
|
||||||
length = size(input, kind=8)
|
call c_f_pointer(buffer, input, [ length ])
|
||||||
|
|
||||||
hash = 0_8
|
hash = 0_8
|
||||||
offset = 1_8
|
offset = 1_8
|
||||||
remaining = length
|
remaining = length
|
||||||
|
Loading…
x
Reference in New Issue
Block a user