Skip to content

Commit

Permalink
Merge pull request #5 from sainttttt/master
Browse files Browse the repository at this point in the history
updated xxhash version and added streaming for xxh3_64
  • Loading branch information
ba0f3 authored Jul 26, 2024
2 parents f49d54d + 9cfff2d commit e582337
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/private/xxHash
Submodule xxHash updated 67 files
+7 −0 .github/dependabot.yml
+630 −0 .github/workflows/ci.yml
+6 −1 .gitignore
+19 −9 .travis.yml
+43 −0 CHANGELOG
+63 −0 Doxyfile
+63 −0 Doxyfile-internal
+1 −23 LICENSE
+198 −52 Makefile
+133 −106 README.md
+13 −0 SECURITY.md
+18 −14 appveyor.yml
+3 −0 cli/.tipi/deps
+0 −0 cli/.tipi/opts
+339 −0 cli/COPYING
+4 −0 cli/README.md
+169 −0 cli/xsum_arch.h
+448 −0 cli/xsum_bench.c
+51 −0 cli/xsum_bench.h
+214 −0 cli/xsum_config.h
+508 −0 cli/xsum_os_specific.c
+89 −0 cli/xsum_os_specific.h
+66 −0 cli/xsum_output.c
+62 −0 cli/xsum_output.h
+694 −0 cli/xsum_sanity_check.c
+60 −0 cli/xsum_sanity_check.h
+31 −76 cli/xxhsum.1
+33 −27 cli/xxhsum.1.md
+1,345 −0 cli/xxhsum.c
+65 −22 cmake_unofficial/CMakeLists.txt
+23 −0 cmake_unofficial/JoinPaths.cmake
+2 −1 cmake_unofficial/README.md
+591 −88 doc/xxhash_spec.md
+4 −4 libxxhash.pc.in
+67 −15 tests/Makefile
+3 −2 tests/bench/Makefile
+3 −1 tests/bench/benchHash.c
+1 −1 tests/bench/benchHash.h
+2 −1 tests/bench/benchfn.c
+1 −1 tests/bench/benchfn.h
+3 −2 tests/bench/bhDisplay.c
+1 −1 tests/bench/bhDisplay.h
+1 −1 tests/bench/hashes.h
+3 −3 tests/bench/main.c
+1 −1 tests/bench/timefn.c
+1 −1 tests/bench/timefn.h
+32 −0 tests/cli-comment-line.sh
+51 −0 tests/cli-ignore-missing.sh
+5 −4 tests/collisions/Makefile
+1 −1 tests/collisions/hashes.h
+19 −19 tests/collisions/main.c
+1 −1 tests/collisions/pool.c
+1 −1 tests/collisions/pool.h
+1 −1 tests/collisions/sort.cc
+1 −1 tests/collisions/sort.hh
+21 −0 tests/filename-escape.sh
+21 −9 tests/multiInclude.c
+763 −0 tests/sanity_test.c
+45,832 −0 tests/sanity_test_vectors.h
+464 −0 tests/sanity_test_vectors_generator.c
+43 −0 tests/unicode_lint.sh
+2 −2 xxh3.h
+478 −382 xxh_x86dispatch.c
+9 −10 xxh_x86dispatch.h
+1 −1 xxhash.c
+3,285 −1,278 xxhash.h
+0 −2,597 xxhsum.c
32 changes: 31 additions & 1 deletion src/xxhash.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ proc XXH3_64bits_withSeed*(input: string, seed: uint64): uint64 =
type
LLxxh64State* = pointer
LLxxh32State* = pointer
LLxxh3_64State* = pointer
Xxh32State* = object
llstate*: LLxxh32State # wrapped in a object for destructor
Xxh64State* = object
llstate*: LLxxh64State # wrapped in a object for destructor
Xxh3_64State* = object
llstate*: LLxxh3_64State # wrapped in a object for destructor

proc XXH32_createState*(): LLxxh32State {.cdecl, importc: "XXH32_createState".}
proc XXH32_freeState*(state: LLxxh32State) {.cdecl, importc: "XXH32_freeState".}
Expand All @@ -58,6 +61,33 @@ proc reset*(state: Xxh32State, seed = 0'u32) =
proc `=destroy`*(state: var Xxh32State) =
state.llstate.XXH32_freeState()


proc XXH3_createState*(): LLxxh3_64State {.cdecl, importc: "XXH3_createState".}
proc XXH3_freeState*(state: LLxxh3_64State) {.cdecl, importc: "XXH3_freeState".}
proc XXH3_64_reset*(state: LLxxh3_64State) {.cdecl, importc: "XXH3_64bits_reset".}
proc XXH3_64_reset_withSeed*(state: LLxxh3_64State, seed: uint64 = 0) {.cdecl, importc: "XXH3_64bits_reset_withSeed".}
proc XXH3_64_update*(state: LLxxh3_64State, input: cstring, len: int) {.cdecl, importc: "XXH3_64bits_update".}
proc XXH3_64_digest*(state: LLxxh3_64State): uint64 {.cdecl, importc: "XXH3_64bits_digest".}

proc newXxH3_64*(seed: uint64 = 0): XxH3_64State =
result.llstate = XXH3_createState()
result.llstate.XXH3_64_reset_withSeed(seed)

proc update*(state: XxH3_64State, input: string) =
state.llstate.XXH3_64_update(input.cstring, input.len)

proc digest*(state: XxH3_64State): uint64 =
return state.llstate.XXH3_64_digest()

proc `$`*(state: XxH3_64State): string =
return $state.digest

proc reset*(state: XxH3_64State, seed = 0'u64) =
state.llstate.XXH3_64_reset_withSeed(seed)

proc `=destroy`*(state: var XxH3_64State) =
state.llstate.XXH3_freeState()

proc XXH64_createState*(): LLxxh64State {.cdecl, importc: "XXH64_createState".}
proc XXH64_freeState*(state: LLxxh64State) {.cdecl, importc: "XXH64_freeState".}
proc XXH64_reset*(state: LLxxh64State, seed: uint64 = 0) {.cdecl, importc: "XXH64_reset".}
Expand Down Expand Up @@ -137,4 +167,4 @@ when isMainModule:
state.update(msg)
assert state.digest() == msgh64
assert $state == $msgh64
state.reset()
state.reset()
2 changes: 1 addition & 1 deletion xxhash.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Package]
name = "xxhash"
version = "0.9.0"
version = "0.10.0"
author = "Huy Doan"
description = "xxhash wrapper for Nim"
license = "MIT"
Expand Down

0 comments on commit e582337

Please sign in to comment.