mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-24 17:08:17 +00:00
Dependencies: Updated xxHash from 0.1.0 to v0.8.0 - Stable XXH3
This commit is contained in:
parent
e365313a44
commit
0ba1558e17
30
deps/xxHash/.gitignore
vendored
30
deps/xxHash/.gitignore
vendored
@ -1,17 +1,47 @@
|
||||
# objects
|
||||
*.o
|
||||
*.obj
|
||||
*.s
|
||||
|
||||
# libraries
|
||||
libxxhash.*
|
||||
!libxxhash.pc.in
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
xxh32sum
|
||||
xxh64sum
|
||||
xxh128sum
|
||||
xxhsum
|
||||
xxhsum32
|
||||
xxhsum_privateXXH
|
||||
xxhsum_inlinedXXH
|
||||
dispatch
|
||||
tests/generate_unicode_test
|
||||
|
||||
# compilation chain
|
||||
.clang_complete
|
||||
|
||||
# Mac OS-X artefacts
|
||||
*.dSYM
|
||||
.DS_Store
|
||||
|
||||
# Wasm / emcc / emscripten artefacts
|
||||
*.html
|
||||
*.wasm
|
||||
*.js
|
||||
|
||||
# CMake build directories
|
||||
build*/
|
||||
|
||||
# project managers artifacts
|
||||
.projectile
|
||||
|
||||
# analyzer artifacts
|
||||
infer-out
|
||||
|
||||
# test artifacts
|
||||
.test*
|
||||
tmp*
|
||||
tests/*.unicode
|
||||
tests/unicode_test*
|
||||
|
137
deps/xxHash/.travis.yml
vendored
137
deps/xxHash/.travis.yml
vendored
@ -1,9 +1,132 @@
|
||||
language: c
|
||||
compiler: gcc
|
||||
script: make -B test-all
|
||||
|
||||
# Dump CPU info before start
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq gcc-arm-linux-gnueabi
|
||||
- sudo apt-get install -qq clang
|
||||
- sudo apt-get install -qq g++-multilib
|
||||
- sudo apt-get install -qq gcc-multilib
|
||||
- cat /proc/cpuinfo
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
|
||||
- name: General linux tests (Xenial)
|
||||
dist: xenial
|
||||
arch: amd64
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang
|
||||
- g++-multilib
|
||||
- gcc-multilib
|
||||
- cppcheck
|
||||
script:
|
||||
- make -B test-all
|
||||
- make clean
|
||||
- make dispatch
|
||||
- make clean
|
||||
- CC=g++ CFLAGS="-O1 -mavx512f" make
|
||||
- make clean
|
||||
- CC=g++ CFLAGS="-Wall -Wextra" make DISPATCH=1
|
||||
|
||||
|
||||
- name: Check results consistency on x64
|
||||
arch: amd64
|
||||
script:
|
||||
- CPPFLAGS=-DXXH_VECTOR=XXH_SCALAR make check # Scalar code path
|
||||
- make clean
|
||||
- CPPFLAGS=-DXXH_VECTOR=XXH_SSE2 make check # SSE2 code path
|
||||
- make clean
|
||||
- CPPFLAGS="-mavx2 -DXXH_VECTOR=XXH_AVX2" make check # AVX2 code path
|
||||
- make clean
|
||||
- CPPFLAGS="-mavx512f -DXXH_VECTOR=XXH_AVX512" make check # AVX512 code path
|
||||
- make clean
|
||||
- CPPFLAGS=-DXXH_REROLL=1 make check # reroll code path (#240)
|
||||
- make -C tests/bench
|
||||
|
||||
- name: ARM compilation and consistency checks (Qemu)
|
||||
dist: xenial
|
||||
arch: amd64
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- qemu-system-arm
|
||||
- qemu-user-static
|
||||
- gcc-arm-linux-gnueabi
|
||||
- libc6-dev-armel-cross
|
||||
script:
|
||||
# arm (32-bit)
|
||||
- CC=arm-linux-gnueabi-gcc CPPFLAGS=-DXXH_VECTOR=XXH_SCALAR LDFLAGS=-static RUN_ENV=qemu-arm-static make check # Scalar code path
|
||||
- make clean
|
||||
# NEON (32-bit)
|
||||
- CC=arm-linux-gnueabi-gcc CPPFLAGS=-DXXH_VECTOR=XXH_NEON CFLAGS="-O3 -march=armv7-a -fPIC -mfloat-abi=softfp -mfpu=neon-vfpv4" LDFLAGS=-static RUN_ENV=qemu-arm-static make check # NEON code path
|
||||
|
||||
- name: aarch64 compilation and consistency checks
|
||||
dist: xenial
|
||||
arch: arm64
|
||||
script:
|
||||
# aarch64
|
||||
- CPPFLAGS=-DXXH_VECTOR=XXH_SCALAR make check # Scalar code path
|
||||
# NEON (64-bit)
|
||||
- make clean
|
||||
- CPPFLAGS=-DXXH_VECTOR=XXH_NEON make check # NEON code path
|
||||
# clang
|
||||
- make clean
|
||||
- CC=clang CPPFLAGS=-DXXH_VECTOR=XXH_SCALAR make check # Scalar code path
|
||||
# clang + NEON
|
||||
- make clean
|
||||
- CC=clang CPPFLAGS=-DXXH_VECTOR=XXH_NEON make check # NEON code path
|
||||
|
||||
# We need Bionic here because the QEMU versions shipped in the older repos
|
||||
# do not support POWER8 emulation, and compiling QEMU from source is a pain.
|
||||
- name: PowerPC + PPC64 compilation and consistency checks (Qemu on Bionic)
|
||||
dist: bionic
|
||||
arch: amd64
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- qemu-system-ppc
|
||||
- qemu-user-static
|
||||
- gcc-powerpc-linux-gnu
|
||||
- gcc-powerpc64-linux-gnu
|
||||
- libc6-dev-powerpc-cross
|
||||
- libc6-dev-ppc64-cross
|
||||
script:
|
||||
- CC=powerpc-linux-gnu-gcc RUN_ENV=qemu-ppc-static LDFLAGS=-static make check # Scalar code path
|
||||
- make clean
|
||||
- CC=powerpc64-linux-gnu-gcc RUN_ENV=qemu-ppc64-static CPPFLAGS=-DXXH_VECTOR=XXH_SCALAR CFLAGS="-O3" LDFLAGS="-static -m64" make check # Scalar code path
|
||||
# VSX code
|
||||
- make clean
|
||||
- CC=powerpc64-linux-gnu-gcc RUN_ENV="qemu-ppc64-static -cpu power8" CPPFLAGS=-DXXH_VECTOR=XXH_VSX CFLAGS="-O3 -maltivec -mvsx -mcpu=power8 -mpower8-vector" LDFLAGS="-static -m64" make check # VSX code path
|
||||
# altivec.h redefinition issue #426
|
||||
- make clean
|
||||
- CC=powerpc64-linux-gnu-gcc CPPFLAGS=-DXXH_VECTOR=XXH_VSX CFLAGS="-maltivec -mvsx -mcpu=power8 -mpower8-vector" make -C tests test_ppc_redefine
|
||||
|
||||
- name: PPC64LE compilation and consistency checks
|
||||
dist: xenial
|
||||
arch: ppc64le
|
||||
script:
|
||||
# Scalar (universal) code path
|
||||
- CPPFLAGS=-DXXH_VECTOR=XXH_SCALAR LDFLAGS=-static make check
|
||||
# VSX code path (64-bit)
|
||||
- make clean
|
||||
- CPPFLAGS=-DXXH_VECTOR=XXH_VSX CFLAGS="-O3 -maltivec -mvsx -mpower8-vector -mcpu=power8" LDFLAGS="-static" make check
|
||||
# altivec.h redefinition issue #426
|
||||
- make clean
|
||||
- CPPFLAGS=-DXXH_VECTOR=XXH_VSX CFLAGS="-maltivec -mvsx -mcpu=power8 -mpower8-vector" make -C tests test_ppc_redefine
|
||||
|
||||
- name: IBM s390x compilation and consistency checks
|
||||
dist: bionic
|
||||
arch: s390x
|
||||
script:
|
||||
# Scalar (universal) code path
|
||||
- CPPFLAGS=-DXXH_VECTOR=XXH_SCALAR LDFLAGS=-static make check
|
||||
# s390x code path (64-bit)
|
||||
- make clean
|
||||
- CPPFLAGS=-DXXH_VECTOR=XXH_VSX CFLAGS="-O3 -march=arch11 -mzvector" LDFLAGS="-static" make check
|
||||
|
||||
- name: cmake build test
|
||||
script:
|
||||
- cd cmake_unofficial
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake ..
|
||||
- make
|
||||
|
52
deps/xxHash/CHANGELOG
vendored
Normal file
52
deps/xxHash/CHANGELOG
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
v0.8.0
|
||||
- api : stabilize XXH3
|
||||
- cli : xxhsum can parse BSD-style --check lines, by @WayneD
|
||||
- cli : `xxhsum -` accepts console input, requested by @jaki
|
||||
- cli : xxhsum accepts -- separator, by @jaki
|
||||
- cli : fix : print correct default algo for symlinked helpers, by @martinetd
|
||||
- install: improved pkgconfig script, allowing custom install locations, requested by @ellert
|
||||
|
||||
v0.7.4
|
||||
- perf: automatic vector detection and selection at runtime (`xxh_x86dispatch.h`), initiated by @easyaspi314
|
||||
- perf: added AVX512 support, by @gzm55
|
||||
- api : new: secret generator `XXH_generateSecret()`, suggested by @koraa
|
||||
- api : fix: XXH3_state_t is movable, identified by @koraa
|
||||
- api : fix: state is correctly aligned in AVX mode (unlike `malloc()`), by @easyaspi314
|
||||
- api : fix: streaming generated wrong values in some combination of random ingestion lengths, reported by @WayneD
|
||||
- cli : fix unicode print on Windows, by @easyaspi314
|
||||
- cli : can `-c` check file generated by sfv
|
||||
- build: `make DISPATCH=1` generates `xxhsum` and `libxxhash` with runtime vector detection (x86/x64 only)
|
||||
- install: cygwin installation support
|
||||
- doc : Cryptol specification of XXH32 and XXH64, by @weaversa
|
||||
|
||||
v0.7.3
|
||||
- perf: improved speed for large inputs (~+20%)
|
||||
- perf: improved latency for small inputs (~10%)
|
||||
- perf: s390x Vectorial code, by @easyaspi314
|
||||
- cli: improved support for Unicode filenames on Windows, thanks to @easyaspi314 and @t-mat
|
||||
- api: `xxhash.h` can now be included in any order, with and without `XXH_STATIC_LINKING_ONLY` and `XXH_INLINE_ALL`
|
||||
- build: xxHash's implementation transferred into `xxhash.h`. No more need to have `xxhash.c` in the `/include` directory for `XXH_INLINE_ALL` to work
|
||||
- install: created pkg-config file, by @bket
|
||||
- install: VCpkg installation instructions, by @LilyWangL
|
||||
- doc: Highly improved code documentation, by @easyaspi314
|
||||
- misc: New test tool in `/tests/collisions`: brute force collision tester for 64-bit hashes
|
||||
|
||||
v0.7.2
|
||||
- Fixed collision ratio of `XXH128` for some specific input lengths, reported by @svpv
|
||||
- Improved `VSX` and `NEON` variants, by @easyaspi314
|
||||
- Improved performance of scalar code path (`XXH_VECTOR=0`), by @easyaspi314
|
||||
- `xxhsum`: can generate 128-bit hashes with the `-H2` option (note: for experimental purposes only! `XXH128` is not yet frozen)
|
||||
- `xxhsum`: option `-q` removes status notifications
|
||||
|
||||
v0.7.1
|
||||
- Secret first: the algorithm computation can be altered by providing a "secret", which is any blob of bytes, of size >= `XXH3_SECRET_SIZE_MIN`.
|
||||
- `seed` is still available, and acts as a secret generator
|
||||
- updated `ARM NEON` variant by @easyaspi314
|
||||
- Streaming implementation is available
|
||||
- Improve compatibility and performance with Visual Studio, with help from @aras-p
|
||||
- Better integration when using `XXH_INLINE_ALL`: do not pollute host namespace, use its own macros, such as `XXH_ASSERT()`, `XXH_ALIGN`, etc.
|
||||
- 128-bit variant provides helper functions for comparison of hashes.
|
||||
- Better `clang` generation of `rotl` instruction, thanks to @easyaspi314
|
||||
- `XXH_REROLL` build macro to reduce binary size, by @easyaspi314
|
||||
- Improved `cmake` script, by @Mezozoysky
|
||||
- Full benchmark program provided in `/tests/bench`
|
26
deps/xxHash/LICENSE
vendored
26
deps/xxHash/LICENSE
vendored
@ -1,7 +1,9 @@
|
||||
xxHash Library
|
||||
Copyright (c) 2012-2014, Yann Collet
|
||||
Copyright (c) 2012-2020 Yann Collet
|
||||
All rights reserved.
|
||||
|
||||
BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
@ -22,3 +24,25 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
xxhsum command line interface
|
||||
Copyright (c) 2013-2020 Yann Collet
|
||||
All rights reserved.
|
||||
|
||||
GPL v2 License
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
442
deps/xxHash/Makefile
vendored
442
deps/xxHash/Makefile
vendored
@ -1,6 +1,6 @@
|
||||
# ################################################################
|
||||
# xxHash Makefile
|
||||
# Copyright (C) Yann Collet 2012-2015
|
||||
# Copyright (C) 2012-2020 Yann Collet
|
||||
#
|
||||
# GPL v2 License
|
||||
#
|
||||
@ -18,38 +18,35 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# You can contact the author at :
|
||||
# - xxHash source repository : http://code.google.com/p/xxhash/
|
||||
# You can contact the author at:
|
||||
# - xxHash homepage: https://www.xxhash.com
|
||||
# - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
# ################################################################
|
||||
# xxhsum : provides 32/64 bits hash of one or multiple files, or stdin
|
||||
# xxhsum: provides 32/64 bits hash of one or multiple files, or stdin
|
||||
# ################################################################
|
||||
Q = $(if $(filter 1,$(V) $(VERBOSE)),,@)
|
||||
|
||||
# Version numbers
|
||||
LIBVER_MAJOR_SCRIPT:=`sed -n '/define XXH_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
|
||||
LIBVER_MINOR_SCRIPT:=`sed -n '/define XXH_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
|
||||
LIBVER_PATCH_SCRIPT:=`sed -n '/define XXH_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
|
||||
SED ?= sed
|
||||
SED_ERE_OPT ?= -E
|
||||
LIBVER_MAJOR_SCRIPT:=`$(SED) -n '/define XXH_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
|
||||
LIBVER_MINOR_SCRIPT:=`$(SED) -n '/define XXH_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
|
||||
LIBVER_PATCH_SCRIPT:=`$(SED) -n '/define XXH_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
|
||||
LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))
|
||||
LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
|
||||
LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
|
||||
LIBVER := $(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH)
|
||||
|
||||
# SSE4 detection
|
||||
HAVE_SSE4 := $(shell $(CC) -dM -E - < /dev/null | grep "SSE4" > /dev/null && echo 1 || echo 0)
|
||||
ifeq ($(HAVE_SSE4), 1)
|
||||
NOSSE4 := -mno-sse4
|
||||
else
|
||||
NOSSE4 :=
|
||||
endif
|
||||
|
||||
CFLAGS ?= -O2 $(NOSSE4) # disables potential auto-vectorization
|
||||
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
|
||||
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
|
||||
-Wstrict-prototypes -Wundef
|
||||
|
||||
FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(MOREFLAGS)
|
||||
XXHSUM_VERSION=$(LIBVER)
|
||||
MD2ROFF = ronn
|
||||
MD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="xxhsum $(XXHSUM_VERSION)"
|
||||
CFLAGS ?= -O3
|
||||
DEBUGFLAGS+=-Wall -Wextra -Wconversion -Wcast-qual -Wcast-align -Wshadow \
|
||||
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
|
||||
-Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \
|
||||
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
|
||||
-Wredundant-decls -Wstrict-overflow=2
|
||||
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
|
||||
FLAGS = $(CFLAGS) $(CPPFLAGS)
|
||||
XXHSUM_VERSION = $(LIBVER)
|
||||
UNAME := $(shell uname)
|
||||
|
||||
# Define *.exe as extension for Windows systems
|
||||
ifneq (,$(filter Windows%,$(OS)))
|
||||
@ -59,8 +56,8 @@ EXT =
|
||||
endif
|
||||
|
||||
# OS X linker doesn't support -soname, and use different extension
|
||||
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
||||
ifeq ($(shell uname), Darwin)
|
||||
# see: https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
||||
ifeq ($(UNAME), Darwin)
|
||||
SHARED_EXT = dylib
|
||||
SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
|
||||
SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
|
||||
@ -75,191 +72,336 @@ endif
|
||||
LIBXXH = libxxhash.$(SHARED_EXT_VER)
|
||||
|
||||
|
||||
## generate CLI and libraries in release mode (default for `make`)
|
||||
.PHONY: default
|
||||
default: DEBUGFLAGS=
|
||||
default: lib xxhsum_and_links
|
||||
|
||||
.PHONY: all
|
||||
all: lib xxhsum xxhsum_inlinedXXH
|
||||
|
||||
xxhsum32: CFLAGS += -m32
|
||||
xxhsum xxhsum32: xxhash.c xxhsum.c
|
||||
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
||||
## xxhsum is the command line interface (CLI)
|
||||
ifeq ($(DISPATCH),1)
|
||||
xxhsum: CPPFLAGS += -DXXHSUM_DISPATCH=1
|
||||
xxhsum: xxh_x86dispatch.o
|
||||
endif
|
||||
xxhsum: xxhash.o xxhsum.o
|
||||
$(CC) $(FLAGS) $^ $(LDFLAGS) -o $@$(EXT)
|
||||
|
||||
xxhsum32: CFLAGS += -m32 ## generate CLI in 32-bits mode
|
||||
xxhsum32: xxhash.c xxhsum.c ## do not generate object (avoid mixing different ABI)
|
||||
$(CC) $(FLAGS) $^ $(LDFLAGS) -o $@$(EXT)
|
||||
|
||||
## dispatch only works for x86/x64 systems
|
||||
dispatch: CPPFLAGS += -DXXHSUM_DISPATCH=1
|
||||
dispatch: xxhash.o xxh_x86dispatch.o xxhsum.c
|
||||
$(CC) $(FLAGS) $^ $(LDFLAGS) -o $@$(EXT)
|
||||
|
||||
xxhash.o: xxhash.c xxhash.h
|
||||
xxhsum.o: xxhsum.c xxhash.h xxh_x86dispatch.h
|
||||
xxh_x86dispatch.o: xxh_x86dispatch.c xxh_x86dispatch.h xxhash.h
|
||||
|
||||
.PHONY: xxhsum_and_links
|
||||
xxhsum_and_links: xxhsum
|
||||
ln -sf xxhsum xxh32sum
|
||||
ln -sf xxhsum xxh64sum
|
||||
xxhsum_and_links: xxhsum xxh32sum xxh64sum xxh128sum
|
||||
|
||||
xxh32sum xxh64sum xxh128sum: xxhsum
|
||||
ln -sf $<$(EXT) $@$(EXT)
|
||||
|
||||
xxhsum_inlinedXXH: CPPFLAGS += -DXXH_INLINE_ALL
|
||||
xxhsum_inlinedXXH: xxhsum.c
|
||||
$(CC) $(FLAGS) -DXXH_PRIVATE_API $^ -o $@$(EXT)
|
||||
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
||||
|
||||
|
||||
# library
|
||||
|
||||
libxxhash.a: ARFLAGS = rcs
|
||||
libxxhash.a: xxhash.o
|
||||
@echo compiling static library
|
||||
@$(AR) $(ARFLAGS) $@ $^
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
$(LIBXXH): LDFLAGS += -shared
|
||||
ifeq (,$(filter Windows%,$(OS)))
|
||||
$(LIBXXH): LDFLAGS += -fPIC
|
||||
$(LIBXXH): CFLAGS += -fPIC
|
||||
endif
|
||||
ifeq ($(DISPATCH),1)
|
||||
$(LIBXXH): xxh_x86dispatch.c
|
||||
endif
|
||||
$(LIBXXH): xxhash.c
|
||||
@echo compiling dynamic library $(LIBVER)
|
||||
@$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||
@echo creating versioned links
|
||||
@ln -sf $@ libxxhash.$(SHARED_EXT_MAJOR)
|
||||
@ln -sf $@ libxxhash.$(SHARED_EXT)
|
||||
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||
ln -sf $@ libxxhash.$(SHARED_EXT_MAJOR)
|
||||
ln -sf $@ libxxhash.$(SHARED_EXT)
|
||||
|
||||
libxxhash : $(LIBXXH)
|
||||
.PHONY: libxxhash
|
||||
libxxhash: ## generate dynamic xxhash library
|
||||
libxxhash: $(LIBXXH)
|
||||
|
||||
.PHONY: lib
|
||||
lib: ## generate static and dynamic xxhash libraries
|
||||
lib: libxxhash.a libxxhash
|
||||
|
||||
# helper targets
|
||||
|
||||
AWK = awk
|
||||
GREP = grep
|
||||
SORT = sort
|
||||
|
||||
.PHONY: list
|
||||
list: ## list all Makefile targets
|
||||
$(Q)$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | $(AWK) -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | $(SORT) | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
|
||||
|
||||
.PHONY: help
|
||||
help: ## list documented targets
|
||||
$(Q)$(GREP) -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
|
||||
$(SORT) | \
|
||||
$(AWK) 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
.PHONY: clean
|
||||
clean: ## remove all build artifacts
|
||||
$(Q)$(RM) -r *.dSYM # Mac OS-X specific
|
||||
$(Q)$(RM) core *.o *.$(SHARED_EXT) *.$(SHARED_EXT).* *.a libxxhash.pc
|
||||
$(Q)$(RM) xxhsum$(EXT) xxhsum32$(EXT) xxhsum_inlinedXXH$(EXT) dispatch$(EXT)
|
||||
$(Q)$(RM) xxh32sum$(EXT) xxh64sum$(EXT) xxh128sum$(EXT)
|
||||
@echo cleaning completed
|
||||
|
||||
|
||||
# =================================================
|
||||
# tests
|
||||
# =================================================
|
||||
|
||||
# make check can be run with cross-compiled binaries on emulated environments (qemu user mode)
|
||||
# by setting $(RUN_ENV) to the target emulation environment
|
||||
.PHONY: check
|
||||
check: xxhsum
|
||||
check: xxhsum ## basic tests for xxhsum CLI, set RUN_ENV for emulated environments
|
||||
# stdin
|
||||
./xxhsum < xxhash.c
|
||||
$(RUN_ENV) ./xxhsum$(EXT) < xxhash.c
|
||||
# multiple files
|
||||
./xxhsum xxhash.* xxhsum.*
|
||||
$(RUN_ENV) ./xxhsum$(EXT) xxhash.* xxhsum.*
|
||||
# internal bench
|
||||
./xxhsum -bi1
|
||||
$(RUN_ENV) ./xxhsum$(EXT) -bi0
|
||||
# long bench command
|
||||
$(RUN_ENV) ./xxhsum$(EXT) --benchmark-all -i0
|
||||
# bench multiple variants
|
||||
$(RUN_ENV) ./xxhsum$(EXT) -b1,2,3 -i0
|
||||
# file bench
|
||||
./xxhsum -bi1 xxhash.c
|
||||
$(RUN_ENV) ./xxhsum$(EXT) -bi0 xxhash.c
|
||||
# 32-bit
|
||||
$(RUN_ENV) ./xxhsum$(EXT) -H0 xxhash.c
|
||||
# 128-bit
|
||||
$(RUN_ENV) ./xxhsum$(EXT) -H2 xxhash.c
|
||||
# request incorrect variant
|
||||
$(RUN_ENV) ./xxhsum$(EXT) -H9 xxhash.c ; test $$? -eq 1
|
||||
@printf "\n ....... checks completed successfully ....... \n"
|
||||
|
||||
.PHONY: test-unicode
|
||||
test-unicode:
|
||||
$(MAKE) -C tests test_unicode
|
||||
|
||||
.PHONY: test-mem
|
||||
test-mem: xxhsum
|
||||
# memory tests
|
||||
valgrind --leak-check=yes --error-exitcode=1 ./xxhsum -bi1 xxhash.c
|
||||
valgrind --leak-check=yes --error-exitcode=1 ./xxhsum -H0 xxhash.c
|
||||
valgrind --leak-check=yes --error-exitcode=1 ./xxhsum -H1 xxhash.c
|
||||
VALGRIND = valgrind --leak-check=yes --error-exitcode=1
|
||||
test-mem: RUN_ENV = $(VALGRIND)
|
||||
test-mem: xxhsum check
|
||||
|
||||
.PHONY: test32
|
||||
test32: clean xxhsum32
|
||||
@echo ---- test 32-bit ----
|
||||
./xxhsum32 -bi1 xxhash.c
|
||||
|
||||
.PHONY: test-xxhsum-c
|
||||
test-xxhsum-c: xxhsum
|
||||
# xxhsum to/from pipe
|
||||
./xxhsum lib* | ./xxhsum -c -
|
||||
./xxhsum -H0 lib* | ./xxhsum -c -
|
||||
./xxhsum xxh* | ./xxhsum -c -
|
||||
./xxhsum -H0 xxh* | ./xxhsum -c -
|
||||
# xxhsum -q does not display "Loading" message into stderr (#251)
|
||||
! ./xxhsum -q xxh* 2>&1 | grep Loading
|
||||
# xxhsum does not display "Loading" message into stderr either
|
||||
! ./xxhsum xxh* 2>&1 | grep Loading
|
||||
# Check that xxhsum do display filename that it failed to open.
|
||||
LC_ALL=C ./xxhsum nonexistent 2>&1 | grep "Error: Could not open 'nonexistent'"
|
||||
# xxhsum to/from file, shell redirection
|
||||
./xxhsum lib* > .test.xxh64
|
||||
./xxhsum -H0 lib* > .test.xxh32
|
||||
./xxhsum -c .test.xxh64
|
||||
./xxhsum -c .test.xxh32
|
||||
./xxhsum xxh* > .test.xxh64
|
||||
./xxhsum --tag xxh* > .test.xxh64_tag
|
||||
./xxhsum --little-endian xxh* > .test.le_xxh64
|
||||
./xxhsum --tag --little-endian xxh* > .test.le_xxh64_tag
|
||||
./xxhsum -H0 xxh* > .test.xxh32
|
||||
./xxhsum -H0 --tag xxh* > .test.xxh32_tag
|
||||
./xxhsum -H0 --little-endian xxh* > .test.le_xxh32
|
||||
./xxhsum -H0 --tag --little-endian xxh* > .test.le_xxh32_tag
|
||||
./xxhsum -H2 xxh* > .test.xxh128
|
||||
./xxhsum -H2 --tag xxh* > .test.xxh128_tag
|
||||
./xxhsum -H2 --little-endian xxh* > .test.le_xxh128
|
||||
./xxhsum -H2 --tag --little-endian xxh* > .test.le_xxh128_tag
|
||||
./xxhsum -c .test.xxh*
|
||||
./xxhsum -c --little-endian .test.le_xxh*
|
||||
./xxhsum -c .test.*_tag
|
||||
# read list of files from stdin
|
||||
./xxhsum -c < .test.xxh64
|
||||
./xxhsum -c < .test.xxh32
|
||||
cat .test.xxh* | ./xxhsum -c -
|
||||
# check variant with '*' marker as second separator
|
||||
$(SED) 's/ / \*/' .test.xxh32 | ./xxhsum -c
|
||||
# bsd-style output
|
||||
./xxhsum --tag xxhsum* | $(GREP) XXH64
|
||||
./xxhsum --tag -H0 xxhsum* | $(GREP) XXH32
|
||||
./xxhsum --tag -H1 xxhsum* | $(GREP) XXH64
|
||||
./xxhsum --tag -H2 xxhsum* | $(GREP) XXH128
|
||||
./xxhsum --tag -H32 xxhsum* | $(GREP) XXH32
|
||||
./xxhsum --tag -H64 xxhsum* | $(GREP) XXH64
|
||||
./xxhsum --tag -H128 xxhsum* | $(GREP) XXH128
|
||||
./xxhsum --tag -H0 --little-endian xxhsum* | $(GREP) XXH32_LE
|
||||
./xxhsum --tag -H1 --little-endian xxhsum* | $(GREP) XXH64_LE
|
||||
./xxhsum --tag -H2 --little-endian xxhsum* | $(GREP) XXH128_LE
|
||||
./xxhsum --tag -H32 --little-endian xxhsum* | $(GREP) XXH32_LE
|
||||
./xxhsum --tag -H64 --little-endian xxhsum* | $(GREP) XXH64_LE
|
||||
./xxhsum --tag -H128 --little-endian xxhsum* | $(GREP) XXH128_LE
|
||||
# check bsd-style
|
||||
./xxhsum --tag xxhsum* | ./xxhsum -c
|
||||
./xxhsum --tag -H32 --little-endian xxhsum* | ./xxhsum -c
|
||||
# xxhsum -c warns improperly format lines.
|
||||
cat .test.xxh64 .test.xxh32 | ./xxhsum -c -
|
||||
cat .test.xxh32 .test.xxh64 | ./xxhsum -c -
|
||||
echo '12345678 ' >>.test.xxh32
|
||||
./xxhsum -c .test.xxh32 | $(GREP) improperly
|
||||
echo '123456789 file' >>.test.xxh64
|
||||
./xxhsum -c .test.xxh64 | $(GREP) improperly
|
||||
# Expects "FAILED"
|
||||
echo "0000000000000000 LICENSE" | ./xxhsum -c -; test $$? -eq 1
|
||||
echo "00000000 LICENSE" | ./xxhsum -c -; test $$? -eq 1
|
||||
# Expects "FAILED open or read"
|
||||
echo "0000000000000000 test-expects-file-not-found" | ./xxhsum -c -; test $$? -eq 1
|
||||
echo "00000000 test-expects-file-not-found" | ./xxhsum -c -; test $$? -eq 1
|
||||
@$(RM) -f .test.xxh32 .test.xxh64
|
||||
@$(RM) .test.*
|
||||
|
||||
.PHONY: armtest
|
||||
armtest: clean
|
||||
@echo ---- test ARM compilation ----
|
||||
$(MAKE) xxhsum CC=arm-linux-gnueabi-gcc MOREFLAGS="-Werror -static"
|
||||
CC=arm-linux-gnueabi-gcc MOREFLAGS="-Werror -static" $(MAKE) xxhsum
|
||||
|
||||
.PHONY: clangtest
|
||||
clangtest: clean
|
||||
@echo ---- test clang compilation ----
|
||||
$(MAKE) all CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion"
|
||||
CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion" $(MAKE) all
|
||||
|
||||
gpptest: clean
|
||||
@echo ---- test g++ compilation ----
|
||||
$(MAKE) all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
|
||||
.PHONY: cxxtest
|
||||
cxxtest: clean
|
||||
@echo ---- test C++ compilation ----
|
||||
CC="$(CXX) -Wno-deprecated" $(MAKE) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror -fPIC"
|
||||
|
||||
c90test: clean
|
||||
.PHONY: c90test
|
||||
ifeq ($(NO_C90_TEST),true)
|
||||
c90test:
|
||||
@echo no c90 compatibility test
|
||||
else
|
||||
c90test: CPPFLAGS += -DXXH_NO_LONG_LONG
|
||||
c90test: CFLAGS += -std=c90 -Werror -pedantic
|
||||
c90test: xxhash.c
|
||||
@echo ---- test strict C90 compilation [xxh32 only] ----
|
||||
$(CC) -std=c90 -Werror -pedantic -DXXH_NO_LONG_LONG -c xxhash.c
|
||||
$(RM) xxhash.o
|
||||
$(CC) $(FLAGS) $^ $(LDFLAGS) -c
|
||||
$(RM) xxhash.o
|
||||
endif
|
||||
|
||||
.PHONY: usan
|
||||
usan: CC=clang
|
||||
usan: clean
|
||||
usan: CXX=clang++
|
||||
usan: ## check CLI runtime for undefined behavior, using clang's sanitizer
|
||||
@echo ---- check undefined behavior - sanitize ----
|
||||
$(MAKE) clean test CC=$(CC) MOREFLAGS="-g -fsanitize=undefined -fno-sanitize-recover=all"
|
||||
$(MAKE) clean
|
||||
$(MAKE) test CC=$(CC) CXX=$(CXX) MOREFLAGS="-g -fsanitize=undefined -fno-sanitize-recover=all"
|
||||
|
||||
staticAnalyze: clean
|
||||
@echo ---- static analyzer - scan-build ----
|
||||
CFLAGS="-g -Werror" scan-build --status-bugs -v $(MAKE) all
|
||||
.PHONY: staticAnalyze
|
||||
SCANBUILD ?= scan-build
|
||||
staticAnalyze: clean ## check C source files using $(SCANBUILD) static analyzer
|
||||
@echo ---- static analyzer - $(SCANBUILD) ----
|
||||
CFLAGS="-g -Werror" $(SCANBUILD) --status-bugs -v $(MAKE) all
|
||||
|
||||
namespaceTest:
|
||||
CPPCHECK ?= cppcheck
|
||||
.PHONY: cppcheck
|
||||
cppcheck: ## check C source files using $(CPPCHECK) static analyzer
|
||||
@echo ---- static analyzer - $(CPPCHECK) ----
|
||||
$(CPPCHECK) . --force --enable=warning,portability,performance,style --error-exitcode=1 > /dev/null
|
||||
|
||||
.PHONY: namespaceTest
|
||||
namespaceTest: ## ensure XXH_NAMESPACE redefines all public symbols
|
||||
$(CC) -c xxhash.c
|
||||
$(CC) -DXXH_NAMESPACE=TEST_ -c xxhash.c -o xxhash2.o
|
||||
$(CC) xxhash.o xxhash2.o xxhsum.c -o xxhsum2 # will fail if one namespace missing (symbol collision)
|
||||
$(RM) *.o xxhsum2 # clean
|
||||
|
||||
xxhsum.1: xxhsum.1.md
|
||||
cat $^ | $(MD2ROFF) $(MD2ROFF_FLAGS) | sed -n '/^\.\\\".*/!p' > $@
|
||||
MD2ROFF ?= ronn
|
||||
MD2ROFF_FLAGS ?= --roff --warnings --manual="User Commands" --organization="xxhsum $(XXHSUM_VERSION)"
|
||||
xxhsum.1: xxhsum.1.md xxhash.h
|
||||
cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | $(SED) -n '/^\.\\\".*/!p' > $@
|
||||
|
||||
man: xxhsum.1
|
||||
.PHONY: man
|
||||
man: xxhsum.1 ## generate man page from markdown source
|
||||
|
||||
.PHONY: clean-man
|
||||
clean-man:
|
||||
$(RM) xxhsum.1
|
||||
|
||||
preview-man: clean-man man
|
||||
.PHONY: preview-man
|
||||
preview-man: man
|
||||
man ./xxhsum.1
|
||||
|
||||
test: all namespaceTest check test-xxhsum-c c90test
|
||||
.PHONY: test
|
||||
test: DEBUGFLAGS += -DXXH_DEBUGLEVEL=1
|
||||
test: all namespaceTest check test-xxhsum-c c90test test-tools
|
||||
|
||||
test-all: test test32 armtest clangtest gpptest usan listL120 trailingWhitespace staticAnalyze
|
||||
.PHONY: test-inline
|
||||
test-inline:
|
||||
$(MAKE) -C tests test_multiInclude
|
||||
|
||||
.PHONY: test-all
|
||||
test-all: CFLAGS += -Werror
|
||||
test-all: test test32 clangtest cxxtest usan test-inline listL120 trailingWhitespace test-unicode
|
||||
|
||||
.PHONY: test-tools
|
||||
test-tools:
|
||||
CFLAGS=-Werror $(MAKE) -C tests/bench
|
||||
CFLAGS=-Werror $(MAKE) -C tests/collisions
|
||||
|
||||
.PHONY: listL120
|
||||
listL120: # extract lines >= 120 characters in *.{c,h}, by Takayuki Matsuoka (note : $$, for Makefile compatibility)
|
||||
listL120: # extract lines >= 120 characters in *.{c,h}, by Takayuki Matsuoka (note: $$, for Makefile compatibility)
|
||||
find . -type f -name '*.c' -o -name '*.h' | while read -r filename; do awk 'length > 120 {print FILENAME "(" FNR "): " $$0}' $$filename; done
|
||||
|
||||
.PHONY: trailingWhitespace
|
||||
trailingWhitespace:
|
||||
! grep -E "`printf '[ \\t]$$'`" *.1 *.c *.h LICENSE Makefile cmake_unofficial/CMakeLists.txt
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(RM) -r *.dSYM # Mac OS-X specific
|
||||
@$(RM) core *.o libxxhash.*
|
||||
@$(RM) xxhsum$(EXT) xxhsum32$(EXT) xxhsum_inlinedXXH$(EXT) xxh32sum xxh64sum
|
||||
@echo cleaning completed
|
||||
! $(GREP) -E "`printf '[ \\t]$$'`" xxhsum.1 *.c *.h LICENSE Makefile cmake_unofficial/CMakeLists.txt
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# =========================================================
|
||||
# make install is validated only for the following targets
|
||||
#-----------------------------------------------------------------------------
|
||||
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
||||
|
||||
.PHONY: list
|
||||
list:
|
||||
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
|
||||
# =========================================================
|
||||
ifneq (,$(filter Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS CYGWIN% , $(UNAME)))
|
||||
|
||||
DESTDIR ?=
|
||||
# directory variables : GNU conventions prefer lowercase
|
||||
# directory variables: GNU conventions prefer lowercase
|
||||
# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
|
||||
# support both lower and uppercase (BSD), use uppercase in script
|
||||
prefix ?= /usr/local
|
||||
PREFIX ?= $(prefix)
|
||||
exec_prefix ?= $(PREFIX)
|
||||
libdir ?= $(exec_prefix)/lib
|
||||
EXEC_PREFIX ?= $(exec_prefix)
|
||||
libdir ?= $(EXEC_PREFIX)/lib
|
||||
LIBDIR ?= $(libdir)
|
||||
includedir ?= $(PREFIX)/include
|
||||
INCLUDEDIR ?= $(includedir)
|
||||
bindir ?= $(exec_prefix)/bin
|
||||
bindir ?= $(EXEC_PREFIX)/bin
|
||||
BINDIR ?= $(bindir)
|
||||
datarootdir ?= $(PREFIX)/share
|
||||
mandir ?= $(datarootdir)/man
|
||||
man1dir ?= $(mandir)/man1
|
||||
|
||||
ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
||||
ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
|
||||
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
||||
else
|
||||
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(UNAME),OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
||||
MANDIR ?= $(PREFIX)/man/man1
|
||||
else
|
||||
MANDIR ?= $(man1dir)
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(shell uname),SunOS))
|
||||
ifneq (,$(filter $(UNAME),SunOS))
|
||||
INSTALL ?= ginstall
|
||||
else
|
||||
INSTALL ?= install
|
||||
@ -269,40 +411,84 @@ INSTALL_PROGRAM ?= $(INSTALL)
|
||||
INSTALL_DATA ?= $(INSTALL) -m 644
|
||||
|
||||
|
||||
PCLIBDIR ?= $(shell echo "$(LIBDIR)" | $(SED) -n $(SED_ERE_OPT) -e "s@^$(EXEC_PREFIX)(/|$$)@@p")
|
||||
PCINCDIR ?= $(shell echo "$(INCLUDEDIR)" | $(SED) -n $(SED_ERE_OPT) -e "s@^$(PREFIX)(/|$$)@@p")
|
||||
PCEXECDIR?= $(if $(filter $(PREFIX),$(EXEC_PREFIX)),$$\{prefix\},$(EXEC_PREFIX))
|
||||
|
||||
ifeq (,$(PCLIBDIR))
|
||||
# Additional prefix check is required, since the empty string is technically a
|
||||
# valid PCLIBDIR
|
||||
ifeq (,$(shell echo "$(LIBDIR)" | $(SED) -n $(SED_ERE_OPT) -e "\\@^$(EXEC_PREFIX)(/|$$)@ p"))
|
||||
$(error configured libdir ($(LIBDIR)) is outside of exec_prefix ($(EXEC_PREFIX)), can't generate pkg-config file)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (,$(PCINCDIR))
|
||||
# Additional prefix check is required, since the empty string is technically a
|
||||
# valid PCINCDIR
|
||||
ifeq (,$(shell echo "$(INCLUDEDIR)" | $(SED) -n $(SED_ERE_OPT) -e "\\@^$(PREFIX)(/|$$)@ p"))
|
||||
$(error configured includedir ($(INCLUDEDIR)) is outside of prefix ($(PREFIX)), can't generate pkg-config file)
|
||||
endif
|
||||
endif
|
||||
|
||||
libxxhash.pc: libxxhash.pc.in
|
||||
@echo creating pkgconfig
|
||||
$(Q)$(SED) $(SED_ERE_OPT) -e 's|@PREFIX@|$(PREFIX)|' \
|
||||
-e 's|@EXECPREFIX@|$(PCEXECDIR)|' \
|
||||
-e 's|@LIBDIR@|$(PCLIBDIR)|' \
|
||||
-e 's|@INCLUDEDIR@|$(PCINCDIR)|' \
|
||||
-e 's|@VERSION@|$(VERSION)|' \
|
||||
$< > $@
|
||||
|
||||
|
||||
.PHONY: install
|
||||
install: lib xxhsum
|
||||
install: lib libxxhash.pc xxhsum ## install libraries, CLI, links and man page
|
||||
@echo Installing libxxhash
|
||||
@$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)
|
||||
@$(INSTALL_DATA) libxxhash.a $(DESTDIR)$(LIBDIR)
|
||||
@$(INSTALL_PROGRAM) $(LIBXXH) $(DESTDIR)$(LIBDIR)
|
||||
@ln -sf $(LIBXXH) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT_MAJOR)
|
||||
@ln -sf $(LIBXXH) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT)
|
||||
@$(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR) # includes
|
||||
@$(INSTALL_DATA) xxhash.h $(DESTDIR)$(INCLUDEDIR)
|
||||
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)
|
||||
$(Q)$(INSTALL_DATA) libxxhash.a $(DESTDIR)$(LIBDIR)
|
||||
$(Q)$(INSTALL_PROGRAM) $(LIBXXH) $(DESTDIR)$(LIBDIR)
|
||||
$(Q)ln -sf $(LIBXXH) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT_MAJOR)
|
||||
$(Q)ln -sf $(LIBXXH) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT)
|
||||
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR) # includes
|
||||
$(Q)$(INSTALL_DATA) xxhash.h $(DESTDIR)$(INCLUDEDIR)
|
||||
$(Q)$(INSTALL_DATA) xxh3.h $(DESTDIR)$(INCLUDEDIR) # for compatibility, will be removed in v0.9.0
|
||||
ifeq ($(DISPATCH),1)
|
||||
$(Q)$(INSTALL_DATA) xxh_x86dispatch.h $(DESTDIR)$(INCLUDEDIR)
|
||||
endif
|
||||
@echo Installing pkgconfig
|
||||
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
|
||||
$(Q)$(INSTALL_DATA) libxxhash.pc $(DESTDIR)$(PKGCONFIGDIR)/
|
||||
@echo Installing xxhsum
|
||||
@$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
|
||||
@$(INSTALL_PROGRAM) xxhsum $(DESTDIR)$(BINDIR)/xxhsum
|
||||
@ln -sf xxhsum $(DESTDIR)$(BINDIR)/xxh32sum
|
||||
@ln -sf xxhsum $(DESTDIR)$(BINDIR)/xxh64sum
|
||||
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
|
||||
$(Q)$(INSTALL_PROGRAM) xxhsum $(DESTDIR)$(BINDIR)/xxhsum
|
||||
$(Q)ln -sf xxhsum $(DESTDIR)$(BINDIR)/xxh32sum
|
||||
$(Q)ln -sf xxhsum $(DESTDIR)$(BINDIR)/xxh64sum
|
||||
$(Q)ln -sf xxhsum $(DESTDIR)$(BINDIR)/xxh128sum
|
||||
@echo Installing man pages
|
||||
@$(INSTALL_DATA) xxhsum.1 $(DESTDIR)$(MANDIR)/xxhsum.1
|
||||
@ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh32sum.1
|
||||
@ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh64sum.1
|
||||
$(Q)$(INSTALL_DATA) xxhsum.1 $(DESTDIR)$(MANDIR)/xxhsum.1
|
||||
$(Q)ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh32sum.1
|
||||
$(Q)ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh64sum.1
|
||||
$(Q)ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh128sum.1
|
||||
@echo xxhash installation completed
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
@$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.a
|
||||
@$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT)
|
||||
@$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT_MAJOR)
|
||||
@$(RM) $(DESTDIR)$(LIBDIR)/$(LIBXXH)
|
||||
@$(RM) $(DESTDIR)$(INCLUDEDIR)/xxhash.h
|
||||
@$(RM) $(DESTDIR)$(BINDIR)/xxh32sum
|
||||
@$(RM) $(DESTDIR)$(BINDIR)/xxh64sum
|
||||
@$(RM) $(DESTDIR)$(BINDIR)/xxhsum
|
||||
@$(RM) $(DESTDIR)$(MANDIR)/xxh32sum.1
|
||||
@$(RM) $(DESTDIR)$(MANDIR)/xxh64sum.1
|
||||
@$(RM) $(DESTDIR)$(MANDIR)/xxhsum.1
|
||||
uninstall: ## uninstall libraries, CLI, links and man page
|
||||
$(Q)$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.a
|
||||
$(Q)$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT)
|
||||
$(Q)$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT_MAJOR)
|
||||
$(Q)$(RM) $(DESTDIR)$(LIBDIR)/$(LIBXXH)
|
||||
$(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/xxhash.h
|
||||
$(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/xxh3.h
|
||||
$(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/xxh_x86dispatch.h
|
||||
$(Q)$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libxxhash.pc
|
||||
$(Q)$(RM) $(DESTDIR)$(BINDIR)/xxh32sum
|
||||
$(Q)$(RM) $(DESTDIR)$(BINDIR)/xxh64sum
|
||||
$(Q)$(RM) $(DESTDIR)$(BINDIR)/xxh128sum
|
||||
$(Q)$(RM) $(DESTDIR)$(BINDIR)/xxhsum
|
||||
$(Q)$(RM) $(DESTDIR)$(MANDIR)/xxh32sum.1
|
||||
$(Q)$(RM) $(DESTDIR)$(MANDIR)/xxh64sum.1
|
||||
$(Q)$(RM) $(DESTDIR)$(MANDIR)/xxh128sum.1
|
||||
$(Q)$(RM) $(DESTDIR)$(MANDIR)/xxhsum.1
|
||||
@echo xxhsum successfully uninstalled
|
||||
|
||||
endif
|
||||
|
197
deps/xxHash/README.md
vendored
197
deps/xxHash/README.md
vendored
@ -1,8 +1,9 @@
|
||||
xxHash - Extremely fast hash algorithm
|
||||
======================================
|
||||
|
||||
<!-- TODO: Update. -->
|
||||
xxHash is an Extremely fast Hash algorithm, running at RAM speed limits.
|
||||
It successfully completes the [SMHasher](http://code.google.com/p/smhasher/wiki/SMHasher) test suite
|
||||
It successfully completes the [SMHasher](https://code.google.com/p/smhasher/wiki/SMHasher) test suite
|
||||
which evaluates collision, dispersion and randomness qualities of hash functions.
|
||||
Code is highly portable, and hashes are identical on all platforms (little / big endian).
|
||||
|
||||
@ -20,19 +21,21 @@ The benchmark uses SMHasher speed test, compiled with Visual 2010 on a Windows S
|
||||
The reference system uses a Core 2 Duo @3GHz
|
||||
|
||||
|
||||
| Name | Speed | Quality | Author |
|
||||
|---------------|----------|:-------:|------------------|
|
||||
| [xxHash] | 5.4 GB/s | 10 | Y.C. |
|
||||
| MurmurHash 3a | 2.7 GB/s | 10 | Austin Appleby |
|
||||
| SBox | 1.4 GB/s | 9 | Bret Mulvey |
|
||||
| Lookup3 | 1.2 GB/s | 9 | Bob Jenkins |
|
||||
| CityHash64 | 1.05 GB/s| 10 | Pike & Alakuijala|
|
||||
| FNV | 0.55 GB/s| 5 | Fowler, Noll, Vo |
|
||||
| CRC32 | 0.43 GB/s| 9 | |
|
||||
| MD5-32 | 0.33 GB/s| 10 | Ronald L.Rivest |
|
||||
| SHA1-32 | 0.28 GB/s| 10 | |
|
||||
| Name | Speed | Quality | Author |
|
||||
|---------------|--------------------|:-------:|-------------------|
|
||||
| [xxHash] | 5.4 GB/s | 10 | Y.C. |
|
||||
| MurmurHash 3a | 2.7 GB/s | 10 | Austin Appleby |
|
||||
| SBox | 1.4 GB/s | 9 | Bret Mulvey |
|
||||
| Lookup3 | 1.2 GB/s | 9 | Bob Jenkins |
|
||||
| CityHash64 | 1.05 GB/s | 10 | Pike & Alakuijala |
|
||||
| FNV | 0.55 GB/s | 5 | Fowler, Noll, Vo |
|
||||
| CRC32 | 0.43 GB/s † | 9 | |
|
||||
| MD5-32 | 0.33 GB/s | 10 | Ronald L.Rivest |
|
||||
| SHA1-32 | 0.28 GB/s | 10 | |
|
||||
|
||||
[xxHash]: http://www.xxhash.com
|
||||
[xxHash]: https://www.xxhash.com
|
||||
|
||||
Note †: SMHasher's CRC32 implementation is known to be slow. Faster implementations exist.
|
||||
|
||||
Q.Score is a measure of quality of the hash function.
|
||||
It depends on successfully passing SMHasher test set.
|
||||
@ -46,13 +49,13 @@ Note however that 32-bit applications will still run faster using the 32-bit ver
|
||||
SMHasher speed test, compiled using GCC 4.8.2, on Linux Mint 64-bit.
|
||||
The reference system uses a Core i5-3340M @2.7GHz
|
||||
|
||||
| Version | Speed on 64-bit | Speed on 32-bit |
|
||||
| Version | Speed on 64-bit | Speed on 32-bit |
|
||||
|------------|------------------|------------------|
|
||||
| XXH64 | 13.8 GB/s | 1.9 GB/s |
|
||||
| XXH32 | 6.8 GB/s | 6.0 GB/s |
|
||||
|
||||
This project also includes a command line utility, named `xxhsum`, offering similar features as `md5sum`,
|
||||
thanks to [Takayuki Matsuoka](https://github.com/t-mat) contributions.
|
||||
This project also includes a command line utility, named `xxhsum`, offering similar features to `md5sum`,
|
||||
thanks to [Takayuki Matsuoka](https://github.com/t-mat)'s contributions.
|
||||
|
||||
|
||||
### License
|
||||
@ -61,86 +64,142 @@ The library files `xxhash.c` and `xxhash.h` are BSD licensed.
|
||||
The utility `xxhsum` is GPL licensed.
|
||||
|
||||
|
||||
### New hash algorithms
|
||||
|
||||
Starting with `v0.7.0`, the library includes a new algorithm named `XXH3`,
|
||||
which is able to generate 64 and 128-bit hashes.
|
||||
|
||||
The new algorithm is much faster than its predecessors for both long and small inputs,
|
||||
which can be observed in the following graphs:
|
||||
|
||||
![XXH3, bargraph](https://user-images.githubusercontent.com/750081/61976096-b3a35f00-af9f-11e9-8229-e0afc506c6ec.png)
|
||||
|
||||
![XXH3, latency, random size](https://user-images.githubusercontent.com/750081/61976089-aedeab00-af9f-11e9-9239-e5375d6c080f.png)
|
||||
|
||||
To access these new prototypes, one needs to unlock their declaration, using the build macro `XXH_STATIC_LINKING_ONLY`.
|
||||
|
||||
The algorithm is currently in development, meaning its return values might still change in future versions.
|
||||
However, the API is stable, and can be used in production,
|
||||
typically for generation of ephemeral hashes (produced and consumed in same session).
|
||||
|
||||
`XXH3` has now reached "release candidate" status.
|
||||
If everything remains fine, its format will be "frozen" and become final.
|
||||
After which, return values of `XXH3` and `XXH128` will no longer change in future versions.
|
||||
`XXH3`'s return values will be officially finalized upon reaching `v0.8.0`.
|
||||
|
||||
|
||||
### Build modifiers
|
||||
|
||||
The following macros can be set at compilation time,
|
||||
they modify xxhash behavior. They are all disabled by default.
|
||||
The following macros can be set at compilation time to modify libxxhash's behavior. They are generally disabled by default.
|
||||
|
||||
- `XXH_INLINE_ALL` : Make all functions `inline`, with bodies directly included within `xxhash.h`.
|
||||
There is no need for an `xxhash.o` module in this case.
|
||||
Inlining functions is generally beneficial for speed on small keys.
|
||||
It's especially effective when key length is a compile time constant,
|
||||
with observed performance improvement in the +200% range .
|
||||
See [this article](https://fastcompression.blogspot.com/2018/03/xxhash-for-small-keys-impressive-power.html) for details.
|
||||
- `XXH_ACCEPT_NULL_INPUT_POINTER` : if set to `1`, when input is a null-pointer,
|
||||
xxhash result is the same as a zero-length key
|
||||
(instead of a dereference segfault).
|
||||
- `XXH_FORCE_MEMORY_ACCESS` : default method `0` uses a portable `memcpy()` notation.
|
||||
Method `1` uses a gcc-specific `packed` attribute, which can provide better performance for some targets.
|
||||
Method `2` forces unaligned reads, which is not standard compliant, but might sometimes be the only way to extract better performance.
|
||||
- `XXH_CPU_LITTLE_ENDIAN` : by default, endianess is determined at compile time.
|
||||
It's possible to skip auto-detection and force format to little-endian, by setting this macro to 1.
|
||||
Setting it to 0 forces big-endian.
|
||||
- `XXH_FORCE_NATIVE_FORMAT` : on big-endian systems : use native number representation.
|
||||
Breaks consistency with little-endian results.
|
||||
- `XXH_PRIVATE_API` : same impact as `XXH_INLINE_ALL`.
|
||||
Name underlines that symbols will not be published on library public interface.
|
||||
- `XXH_NAMESPACE` : prefix all symbols with the value of `XXH_NAMESPACE`.
|
||||
Useful to evade symbol naming collisions,
|
||||
in case of multiple inclusions of xxHash source code.
|
||||
Client applications can still use regular function name,
|
||||
symbols are automatically translated through `xxhash.h`.
|
||||
- `XXH_STATIC_LINKING_ONLY` : gives access to state declaration for static allocation.
|
||||
Incompatible with dynamic linking, due to risks of ABI changes.
|
||||
- `XXH_NO_LONG_LONG` : removes support for XXH64,
|
||||
for targets without 64-bit support.
|
||||
- `XXH_INLINE_ALL`: Make all functions `inline`, with implementations being directly included within `xxhash.h`.
|
||||
Inlining functions is beneficial for speed on small keys.
|
||||
It's _extremely effective_ when key length is expressed as _a compile time constant_,
|
||||
with performance improvements observed in the +200% range .
|
||||
See [this article](https://fastcompression.blogspot.com/2018/03/xxhash-for-small-keys-impressive-power.html) for details.
|
||||
- `XXH_PRIVATE_API`: same outcome as `XXH_INLINE_ALL`. Still available for legacy support.
|
||||
The name underlines that `XXH_*` symbols will not be exported.
|
||||
- `XXH_NAMESPACE`: Prefixes all symbols with the value of `XXH_NAMESPACE`.
|
||||
This macro can only use compilable character set.
|
||||
Useful to evade symbol naming collisions,
|
||||
in case of multiple inclusions of xxHash's source code.
|
||||
Client applications still use the regular function names,
|
||||
as symbols are automatically translated through `xxhash.h`.
|
||||
- `XXH_FORCE_MEMORY_ACCESS`: The default method `0` uses a portable `memcpy()` notation.
|
||||
Method `1` uses a gcc-specific `packed` attribute, which can provide better performance for some targets.
|
||||
Method `2` forces unaligned reads, which is not standards compliant, but might sometimes be the only way to extract better read performance.
|
||||
Method `3` uses a byteshift operation, which is best for old compilers which don't inline `memcpy()` or big-endian systems without a byteswap instruction
|
||||
- `XXH_FORCE_ALIGN_CHECK`: Use a faster direct read path when input is aligned.
|
||||
This option can result in dramatic performance improvement when input to hash is aligned on 32 or 64-bit boundaries,
|
||||
when running on architectures unable to load memory from unaligned addresses, or suffering a performance penalty from it.
|
||||
It is (slightly) detrimental on platform with good unaligned memory access performance (same instruction for both aligned and unaligned accesses).
|
||||
This option is automatically disabled on `x86`, `x64` and `aarch64`, and enabled on all other platforms.
|
||||
- `XXH_VECTOR` : manually select a vector instruction set (default: auto-selected at compilation time). Available instruction sets are `XXH_SCALAR`, `XXH_SSE2`, `XXH_AVX2`, `XXH_AVX512`, `XXH_NEON` and `XXH_VSX`. Compiler may require additional flags to ensure proper support (for example, `gcc` on linux will require `-mavx2` for AVX2, and `-mavx512f` for AVX512).
|
||||
- `XXH_NO_PREFETCH` : disable prefetching. XXH3 only.
|
||||
- `XXH_PREFETCH_DIST` : select prefecting distance. XXH3 only.
|
||||
- `XXH_NO_INLINE_HINTS`: By default, xxHash uses `__attribute__((always_inline))` and `__forceinline` to improve performance at the cost of code size.
|
||||
Defining this macro to 1 will mark all internal functions as `static`, allowing the compiler to decide whether to inline a function or not.
|
||||
This is very useful when optimizing for smallest binary size,
|
||||
and is automatically defined when compiling with `-O0`, `-Os`, `-Oz`, or `-fno-inline` on GCC and Clang.
|
||||
This may also increase performance depending on compiler and architecture.
|
||||
- `XXH_REROLL`: Reduces the size of the generated code by not unrolling some loops.
|
||||
Impact on performance may vary, depending on platform and algorithm.
|
||||
- `XXH_ACCEPT_NULL_INPUT_POINTER`: if set to `1`, when input is a `NULL` pointer,
|
||||
xxHash'd result is the same as a zero-length input
|
||||
(instead of a dereference segfault).
|
||||
Adds one branch at the beginning of each hash.
|
||||
- `XXH_STATIC_LINKING_ONLY`: gives access to the state declaration for static allocation.
|
||||
Incompatible with dynamic linking, due to risks of ABI changes.
|
||||
- `XXH_NO_LONG_LONG`: removes compilation of algorithms relying on 64-bit types (XXH3 and XXH64). Only XXH32 will be compiled.
|
||||
Useful for targets (architectures and compilers) without 64-bit support.
|
||||
- `XXH_IMPORT`: MSVC specific: should only be defined for dynamic linking, as it prevents linkage errors.
|
||||
- `XXH_CPU_LITTLE_ENDIAN`: By default, endianess is determined by a runtime test resolved at compile time.
|
||||
If, for some reason, the compiler cannot simplify the runtime test, it can cost performance.
|
||||
It's possible to skip auto-detection and simply state that the architecture is little-endian by setting this macro to 1.
|
||||
Setting it to 0 states big-endian.
|
||||
|
||||
For the Command Line Interface `xxhsum`, the following environment variables can also be set :
|
||||
- `DISPATCH=1` : use `xxh_x86dispatch.c`, to automatically select between `scalar`, `sse2`, `avx2` or `avx512` instruction set at runtime, depending on local host. This option is only valid for `x86`/`x64` systems.
|
||||
|
||||
|
||||
### Building xxHash - Using vcpkg
|
||||
|
||||
You can download and install xxHash using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
||||
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
./vcpkg install xxhash
|
||||
|
||||
The xxHash port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
Calling xxhash 64-bit variant from a C program :
|
||||
Calling xxhash 64-bit variant from a C program:
|
||||
|
||||
```
|
||||
```C
|
||||
#include "xxhash.h"
|
||||
|
||||
unsigned long long calcul_hash(const void* buffer, size_t length)
|
||||
{
|
||||
unsigned long long const seed = 0; /* or any other value */
|
||||
unsigned long long const hash = XXH64(buffer, length, seed);
|
||||
return hash;
|
||||
(...)
|
||||
XXH64_hash_t hash = XXH64(buffer, size, seed);
|
||||
}
|
||||
```
|
||||
|
||||
Using streaming variant is more involved, but makes it possible to provide data in multiple rounds :
|
||||
```
|
||||
Using streaming variant is more involved, but makes it possible to provide data incrementally:
|
||||
```C
|
||||
#include "stdlib.h" /* abort() */
|
||||
#include "xxhash.h"
|
||||
|
||||
|
||||
unsigned long long calcul_hash_streaming(someCustomType handler)
|
||||
XXH64_hash_t calcul_hash_streaming(FileHandler fh)
|
||||
{
|
||||
/* create a hash state */
|
||||
XXH64_state_t* const state = XXH64_createState();
|
||||
if (state==NULL) abort();
|
||||
|
||||
size_t const bufferSize = SOME_VALUE;
|
||||
size_t const bufferSize = SOME_SIZE;
|
||||
void* const buffer = malloc(bufferSize);
|
||||
if (buffer==NULL) abort();
|
||||
|
||||
unsigned long long const seed = 0; /* or any other value */
|
||||
XXH_errorcode const resetResult = XXH64_reset(state, seed);
|
||||
if (resetResult == XXH_ERROR) abort();
|
||||
/* Initialize state with selected seed */
|
||||
XXH64_hash_t const seed = 0; /* or any other value */
|
||||
if (XXH64_reset(state, seed) == XXH_ERROR) abort();
|
||||
|
||||
/* Feed the state with input data, any size, any number of times */
|
||||
(...)
|
||||
while ( /* any condition */ ) {
|
||||
size_t const length = get_more_data(buffer, bufferSize, handler); /* undescribed */
|
||||
XXH_errorcode const addResult = XXH64_update(state, buffer, length);
|
||||
if (addResult == XXH_ERROR) abort();
|
||||
size_t const length = get_more_data(buffer, bufferSize, fh);
|
||||
if (XXH64_update(state, buffer, length) == XXH_ERROR) abort();
|
||||
(...)
|
||||
}
|
||||
|
||||
(...)
|
||||
unsigned long long const hash = XXH64_digest(state);
|
||||
|
||||
/* Get the hash */
|
||||
XXH64_hash_t const hash = XXH64_digest(state);
|
||||
|
||||
/* State can be re-used; in this example, it is simply freed */
|
||||
free(buffer);
|
||||
XXH64_freeState(state);
|
||||
|
||||
@ -151,10 +210,10 @@ unsigned long long calcul_hash_streaming(someCustomType handler)
|
||||
|
||||
### Other programming languages
|
||||
|
||||
Beyond the C reference version,
|
||||
xxHash is also available on many programming languages,
|
||||
thanks to great contributors.
|
||||
They are [listed here](http://www.xxhash.com/#other-languages).
|
||||
Aside from the C reference version,
|
||||
xxHash is also available in many different programming languages,
|
||||
thanks to many great contributors.
|
||||
They are [listed here](https://www.xxhash.com/#other-languages).
|
||||
|
||||
|
||||
### Branch Policy
|
||||
|
113
deps/xxHash/appveyor.yml
vendored
113
deps/xxHash/appveyor.yml
vendored
@ -1,13 +1,44 @@
|
||||
#---------------------------------#
|
||||
# general configuration #
|
||||
#---------------------------------#
|
||||
version: 1.0.{build}
|
||||
max_jobs: 2
|
||||
|
||||
#---------------------------------#
|
||||
# environment configuration #
|
||||
#---------------------------------#
|
||||
clone_depth: 2
|
||||
environment:
|
||||
matrix:
|
||||
- COMPILER: "visual"
|
||||
ARCH: "x64"
|
||||
TEST_XXHSUM: "true"
|
||||
- COMPILER: "visual"
|
||||
ARCH: "x64"
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TEST_XXHSUM: "true"
|
||||
- COMPILER: "visual"
|
||||
ARCH: "Win32"
|
||||
TEST_XXHSUM: "true"
|
||||
- COMPILER: "visual"
|
||||
ARCH: "Win32"
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
TEST_XXHSUM: "true"
|
||||
- COMPILER: "visual"
|
||||
ARCH: "ARM"
|
||||
- COMPILER: "visual"
|
||||
ARCH: "ARM64"
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
# note: ARM64 is not available with Visual Studio 14 2015, which is default for Appveyor
|
||||
- COMPILER: "gcc"
|
||||
PLATFORM: "mingw64"
|
||||
- COMPILER: "gcc"
|
||||
PLATFORM: "mingw32"
|
||||
- COMPILER: "gcc"
|
||||
PLATFORM: "clang"
|
||||
|
||||
install:
|
||||
- ECHO Installing %COMPILER% %PLATFORM% %CONFIGURATION%
|
||||
- ECHO Installing %COMPILER% %PLATFORM% %ARCH%
|
||||
- MKDIR bin
|
||||
- if [%COMPILER%]==[gcc] SET PATH_ORIGINAL=%PATH%
|
||||
- if [%COMPILER%]==[gcc] (
|
||||
@ -15,56 +46,66 @@ install:
|
||||
SET "PATH_MINGW64=c:\msys64\mingw64\bin;c:\msys64\usr\bin" &&
|
||||
COPY C:\MinGW\bin\mingw32-make.exe C:\MinGW\bin\make.exe &&
|
||||
COPY C:\MinGW\bin\gcc.exe C:\MinGW\bin\cc.exe
|
||||
) else (
|
||||
IF [%PLATFORM%]==[x64] (SET ADDITIONALPARAM=/p:LibraryPath="C:\Program Files\Microsoft SDKs\Windows\v7.1\lib\x64;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64;C:\Program Files (x86)\Microsoft Visual Studio 10.0\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\lib\amd64;")
|
||||
)
|
||||
|
||||
#---------------------------------#
|
||||
# build configuration #
|
||||
#---------------------------------#
|
||||
build_script:
|
||||
- if [%PLATFORM%]==[mingw32] SET PATH=%PATH_MINGW32%;%PATH_ORIGINAL%
|
||||
- if [%PLATFORM%]==[mingw64] SET PATH=%PATH_MINGW64%;%PATH_ORIGINAL%
|
||||
- if [%PLATFORM%]==[clang] SET PATH=%PATH_MINGW64%;%PATH_ORIGINAL%
|
||||
- ECHO *** &&
|
||||
ECHO Building %COMPILER% %PLATFORM% %CONFIGURATION% &&
|
||||
ECHO ***
|
||||
- if [%PLATFORM%]==[clang] (clang -v)
|
||||
- if [%COMPILER%]==[gcc] (gcc -v)
|
||||
- if [%PLATFORM%]==[clang] SET PATH=%PATH_MINGW64%;%PATH_ORIGINAL%
|
||||
- ECHO ***
|
||||
- ECHO Building %COMPILER% %PLATFORM% %ARCH%
|
||||
- ECHO ***
|
||||
|
||||
- if [%COMPILER%]==[gcc] (
|
||||
if [%PLATFORM%]==[clang] (
|
||||
clang -v
|
||||
) ELSE (
|
||||
gcc -v
|
||||
)
|
||||
)
|
||||
- if [%COMPILER%]==[gcc] (
|
||||
echo ----- &&
|
||||
make -v &&
|
||||
echo ----- &&
|
||||
if not [%PLATFORM%]==[clang] (
|
||||
if [%PLATFORM%]==[mingw32] ( SET CPPFLAGS=-DPOOL_MT=0 ) &&
|
||||
make -B clean test MOREFLAGS=-Werror
|
||||
) ELSE (
|
||||
make -B clean test CC=clang MOREFLAGS="--target=x86_64-w64-mingw32 -Werror -Wconversion -Wno-sign-conversion"
|
||||
)
|
||||
SET CXXFLAGS=--std=c++14 &&
|
||||
make -B clean test CC=clang CXX=clang++ MOREFLAGS="--target=x86_64-w64-mingw32 -Werror -Wno-pass-failed" NO_C90_TEST=true
|
||||
) &&
|
||||
make -C tests/bench
|
||||
)
|
||||
# note 1: strict c90 tests with clang fail, due to (erroneous) presence on `inline` keyword in some included system file
|
||||
# note 2: multi-threading code doesn't work with mingw32, disabled through POOL_MT=0
|
||||
# note 3: clang requires C++14 to compile sort because its own code contains c++14-only code
|
||||
|
||||
- if [%COMPILER%]==[visual] (
|
||||
ECHO *** &&
|
||||
ECHO *** Building Visual Studio 2010 %PLATFORM%\%CONFIGURATION% &&
|
||||
ECHO *** &&
|
||||
msbuild "visual\VS2010\lz4.sln" %ADDITIONALPARAM% /m /verbosity:minimal /property:PlatformToolset=v100 /t:Clean,Build /p:Platform=%PLATFORM% /p:Configuration=%CONFIGURATION% /p:EnableWholeProgramOptimization=true /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" &&
|
||||
ECHO *** &&
|
||||
ECHO *** Building Visual Studio 2012 %PLATFORM%\%CONFIGURATION% &&
|
||||
ECHO *** &&
|
||||
msbuild "visual\VS2010\lz4.sln" /m /verbosity:minimal /property:PlatformToolset=v110 /t:Clean,Build /p:Platform=%PLATFORM% /p:Configuration=%CONFIGURATION% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" &&
|
||||
ECHO *** &&
|
||||
ECHO *** Building Visual Studio 2013 %PLATFORM%\%CONFIGURATION% &&
|
||||
ECHO *** &&
|
||||
msbuild "visual\VS2010\lz4.sln" /m /verbosity:minimal /property:PlatformToolset=v120 /t:Clean,Build /p:Platform=%PLATFORM% /p:Configuration=%CONFIGURATION% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" &&
|
||||
ECHO *** &&
|
||||
ECHO *** Building Visual Studio 2015 %PLATFORM%\%CONFIGURATION% &&
|
||||
ECHO *** &&
|
||||
msbuild "visual\VS2010\lz4.sln" /m /verbosity:minimal /property:PlatformToolset=v140 /t:Clean,Build /p:Platform=%PLATFORM% /p:Configuration=%CONFIGURATION% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" &&
|
||||
COPY visual\VS2010\bin\%PLATFORM%_%CONFIGURATION%\*.exe programs\
|
||||
cd cmake_unofficial &&
|
||||
cmake . -DCMAKE_BUILD_TYPE=Release -A %ARCH% -DXXHASH_C_FLAGS="/WX" &&
|
||||
cmake --build . --config Release
|
||||
)
|
||||
|
||||
#---------------------------------#
|
||||
# tests configuration #
|
||||
#---------------------------------#
|
||||
test_script:
|
||||
- ECHO *** &&
|
||||
ECHO Testing %COMPILER% %PLATFORM% %CONFIGURATION% &&
|
||||
ECHO ***
|
||||
- if not [%COMPILER%]==[unknown] (
|
||||
xxhsum -h &&
|
||||
xxhsum xxhsum.exe &&
|
||||
xxhsum -bi1 &&
|
||||
echo ------- xxhsum tested -------
|
||||
# note: can only run x86 and x64 binaries on Appveyor
|
||||
# note: if %COMPILER%==gcc, xxhsum was already tested within `make test`
|
||||
- if [%TEST_XXHSUM%]==[true] (
|
||||
ECHO *** &&
|
||||
ECHO Testing %COMPILER% %PLATFORM% %ARCH% &&
|
||||
ECHO *** &&
|
||||
cd Release &&
|
||||
xxhsum.exe -bi1 &&
|
||||
ECHO ------- xxhsum tested -------
|
||||
)
|
||||
|
||||
|
||||
#---------------------------------#
|
||||
# artifacts configuration #
|
||||
#---------------------------------#
|
||||
# none yet
|
||||
|
6
deps/xxHash/cmake_unofficial/.gitignore
vendored
6
deps/xxHash/cmake_unofficial/.gitignore
vendored
@ -8,7 +8,5 @@ cmake_install.cmake
|
||||
|
||||
# make compilation results
|
||||
|
||||
libxxhash.0.6.3.dylib
|
||||
libxxhash.0.dylib
|
||||
libxxhash.a
|
||||
libxxhash.dylib
|
||||
*.dylib
|
||||
*.a
|
||||
|
118
deps/xxHash/cmake_unofficial/CMakeLists.txt
vendored
118
deps/xxHash/cmake_unofficial/CMakeLists.txt
vendored
@ -3,7 +3,9 @@
|
||||
# the public domain worldwide. This software is distributed without
|
||||
# any warranty.
|
||||
#
|
||||
# For details, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
# For details, see <https://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
|
||||
|
||||
set(XXHASH_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
|
||||
@ -18,33 +20,44 @@ set(XXHASH_LIB_VERSION ${XXHASH_VERSION_STRING})
|
||||
set(XXHASH_LIB_SOVERSION "${XXHASH_VERSION_MAJOR}")
|
||||
mark_as_advanced(XXHASH_VERSION_MAJOR XXHASH_VERSION_MINOR XXHASH_VERSION_RELEASE XXHASH_VERSION_STRING XXHASH_LIB_VERSION XXHASH_LIB_SOVERSION)
|
||||
|
||||
option(BUILD_XXHSUM "Build the xxhsum binary" ON)
|
||||
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
||||
|
||||
if("${CMAKE_VERSION}" VERSION_LESS "3.0")
|
||||
project(XXHASH C)
|
||||
if("${CMAKE_VERSION}" VERSION_LESS "3.13")
|
||||
#message(WARNING "CMake ${CMAKE_VERSION} has no CMP0077 policy: options will erase uncached/untyped normal vars!")
|
||||
else()
|
||||
cmake_policy (SET CMP0048 NEW)
|
||||
project(XXHASH
|
||||
VERSION ${XXHASH_VERSION_STRING}
|
||||
LANGUAGES C)
|
||||
cmake_policy (SET CMP0077 NEW)
|
||||
endif()
|
||||
if("${CMAKE_VERSION}" VERSION_LESS "3.0")
|
||||
project(xxHash C)
|
||||
else()
|
||||
cmake_policy (SET CMP0048 NEW)
|
||||
project(xxHash
|
||||
VERSION ${XXHASH_VERSION_STRING}
|
||||
LANGUAGES C)
|
||||
endif()
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Project build type" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE
|
||||
PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
|
||||
endif()
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "xxHash build type: ${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
||||
set(XXHASH_BUILD_XXHSUM ON CACHE BOOL "Build the xxhsum binary")
|
||||
|
||||
# If XXHASH is being bundled in another project, we don't want to
|
||||
# install anything. However, we want to let people override this, so
|
||||
# we'll use the XXHASH_BUNDLED_MODE variable to let them do that; just
|
||||
# set it to OFF in your project before you add_subdirectory(xxhash/contrib/cmake_unofficial).
|
||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL "${CMAKE_SOURCE_DIR}")
|
||||
# Bundled mode hasn't been set one way or the other, set the default
|
||||
# depending on whether or not we are the top-level project.
|
||||
if("${XXHASH_PARENT_DIRECTORY}" STREQUAL "")
|
||||
# set it to OFF in your project before you add_subdirectory(xxhash/cmake_unofficial).
|
||||
if(NOT DEFINED XXHASH_BUNDLED_MODE)
|
||||
if("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
|
||||
set(XXHASH_BUNDLED_MODE OFF)
|
||||
else()
|
||||
set(XXHASH_BUNDLED_MODE ON)
|
||||
endif()
|
||||
endif()
|
||||
set(XXHASH_BUNDLED_MODE ${XXHASH_BUNDLED_MODE} CACHE BOOL "" FORCE)
|
||||
mark_as_advanced(XXHASH_BUNDLED_MODE)
|
||||
|
||||
# Allow people to choose whether to build shared or static libraries
|
||||
@ -53,20 +66,35 @@ mark_as_advanced(XXHASH_BUNDLED_MODE)
|
||||
include(CMakeDependentOption)
|
||||
CMAKE_DEPENDENT_OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON "NOT XXHASH_BUNDLED_MODE" OFF)
|
||||
|
||||
include_directories("${XXHASH_DIR}")
|
||||
|
||||
# libxxhash
|
||||
add_library(xxhash "${XXHASH_DIR}/xxhash.c")
|
||||
add_library(${PROJECT_NAME}::xxhash ALIAS xxhash)
|
||||
|
||||
target_include_directories(xxhash
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${XXHASH_DIR}>
|
||||
$<INSTALL_INTERFACE:include/>)
|
||||
if (BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(xxhash PUBLIC XXH_EXPORT)
|
||||
endif ()
|
||||
set_target_properties(xxhash PROPERTIES
|
||||
SOVERSION "${XXHASH_VERSION_STRING}"
|
||||
VERSION "${XXHASH_VERSION_STRING}")
|
||||
|
||||
# xxhsum
|
||||
add_executable(xxhsum "${XXHASH_DIR}/xxhsum.c")
|
||||
target_link_libraries(xxhsum xxhash)
|
||||
if(XXHASH_BUILD_XXHSUM)
|
||||
# xxhsum
|
||||
add_executable(xxhsum "${XXHASH_DIR}/xxhsum.c")
|
||||
add_executable(${PROJECT_NAME}::xxhsum ALIAS xxhsum)
|
||||
|
||||
target_link_libraries(xxhsum PRIVATE xxhash)
|
||||
target_include_directories(xxhsum PRIVATE "${XXHASH_DIR}")
|
||||
endif(XXHASH_BUILD_XXHSUM)
|
||||
|
||||
# Extra warning flags
|
||||
include (CheckCCompilerFlag)
|
||||
if (XXHASH_C_FLAGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XXHASH_C_FLAGS}")
|
||||
endif()
|
||||
foreach (flag
|
||||
-Wall -Wextra -Wcast-qual -Wcast-align -Wshadow
|
||||
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement
|
||||
@ -88,13 +116,53 @@ endforeach (flag)
|
||||
if(NOT XXHASH_BUNDLED_MODE)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
install(TARGETS xxhsum
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
install(TARGETS xxhash
|
||||
EXPORT xxHashTargets
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
install(FILES "${XXHASH_DIR}/xxhash.h"
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
install(FILES "${XXHASH_DIR}/xxhsum.1"
|
||||
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
|
||||
install(FILES "${XXHASH_DIR}/xxh3.h"
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
if(XXHASH_BUILD_XXHSUM)
|
||||
install(TARGETS xxhsum
|
||||
EXPORT xxHashTargets
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
install(FILES "${XXHASH_DIR}/xxhsum.1"
|
||||
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
|
||||
endif(XXHASH_BUILD_XXHSUM)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
set(xxHash_VERSION_CONFIG "${PROJECT_BINARY_DIR}/xxHashConfigVersion.cmake")
|
||||
set(xxHash_PROJECT_CONFIG "${PROJECT_BINARY_DIR}/xxHashConfig.cmake")
|
||||
set(xxHash_TARGETS_CONFIG "${PROJECT_BINARY_DIR}/xxHashTargets.cmake")
|
||||
set(xxHash_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/xxHash/")
|
||||
write_basic_package_version_file(${xxHash_VERSION_CONFIG}
|
||||
VERSION ${XXHASH_VERSION_STRING}
|
||||
COMPATIBILITY AnyNewerVersion)
|
||||
configure_package_config_file(
|
||||
${PROJECT_SOURCE_DIR}/xxHashConfig.cmake.in
|
||||
${xxHash_PROJECT_CONFIG}
|
||||
INSTALL_DESTINATION ${xxHash_CONFIG_INSTALL_DIR})
|
||||
if("${CMAKE_VERSION}" VERSION_LESS "3.0")
|
||||
set(XXHASH_EXPORT_SET xxhash)
|
||||
if(XXHASH_BUILD_XXHSUM)
|
||||
set(XXHASH_EXPORT_SET ${XXHASH_EXPORT_SET} xxhsum)
|
||||
endif()
|
||||
export(TARGETS ${XXHASH_EXPORT_SET}
|
||||
FILE ${xxHash_TARGETS_CONFIG}
|
||||
NAMESPACE ${PROJECT_NAME}::)
|
||||
else()
|
||||
export(EXPORT xxHashTargets
|
||||
FILE ${xxHash_TARGETS_CONFIG}
|
||||
NAMESPACE ${PROJECT_NAME}::)
|
||||
endif()
|
||||
|
||||
install(FILES ${xxHash_PROJECT_CONFIG} ${xxHash_VERSION_CONFIG}
|
||||
DESTINATION ${xxHash_CONFIG_INSTALL_DIR})
|
||||
install(EXPORT xxHashTargets
|
||||
DESTINATION ${xxHash_CONFIG_INSTALL_DIR}
|
||||
NAMESPACE ${PROJECT_NAME}::)
|
||||
endif(NOT XXHASH_BUNDLED_MODE)
|
||||
|
36
deps/xxHash/cmake_unofficial/README.md
vendored
36
deps/xxHash/cmake_unofficial/README.md
vendored
@ -1,6 +1,36 @@
|
||||
|
||||
## Usage
|
||||
|
||||
The `cmake` script present in this directory offers the following options :
|
||||
### Way 1: import targets
|
||||
Build xxHash targets:
|
||||
|
||||
cd </path/to/xxHash/>
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ../cmake_unofficial [options]
|
||||
cmake --build .
|
||||
cmake --build . --target install #optional
|
||||
|
||||
Where possible options are:
|
||||
- `-DXXHASH_BUILD_ENABLE_INLINE_API=<ON|OFF>`: adds xxhash.c for the `-DXXH_INLINE_ALL` api. ON by default.
|
||||
- `-DXXHASH_BUILD_XXHSUM=<ON|OFF>`: build the command line binary. ON by default
|
||||
- `-DBUILD_SHARED_LIBS=<ON|OFF>`: build dynamic library. ON by default.
|
||||
- `-DCMAKE_INSTALL_PREFIX=<path>`: use custom install prefix path.
|
||||
|
||||
Add lines into downstream CMakeLists.txt:
|
||||
|
||||
find_package(xxHash 0.7 CONFIG REQUIRED)
|
||||
...
|
||||
target_link_libraries(MyTarget PRIVATE xxHash::xxhash)
|
||||
|
||||
### Way 2: Add subdirectory
|
||||
Add lines into downstream CMakeLists.txt:
|
||||
|
||||
option(BUILD_SHARE_LIBS "Build shared libs" OFF) #optional
|
||||
...
|
||||
set(XXHASH_BUILD_ENABLE_INLINE_API OFF) #optional
|
||||
set(XXHASH_BUILD_XXHSUM OFF) #optional
|
||||
add_subdirectory(</path/to/xxHash/cmake_unofficial/> </path/to/xxHash/build/> EXCLUDE_FROM_ALL)
|
||||
...
|
||||
target_link_libraries(MyTarget PRIVATE xxHash::xxhash)
|
||||
|
||||
- `BUILD_XXHSUM` : build the command line binary. ON by default
|
||||
- `BUILD_SHARED_LIBS` : build dynamic library. ON by default.
|
||||
|
4
deps/xxHash/cmake_unofficial/xxHashConfig.cmake.in
vendored
Normal file
4
deps/xxHash/cmake_unofficial/xxHashConfig.cmake.in
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/xxHashTargets.cmake)
|
||||
|
9
deps/xxHash/doc/README.md
vendored
Normal file
9
deps/xxHash/doc/README.md
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
xxHash Specification
|
||||
=======================
|
||||
|
||||
This directory contains material defining the xxHash algorithm.
|
||||
It's described in [this specification document](xxhash_spec.md).
|
||||
|
||||
The algorithm is also be illustrated by a [simple educational library](https://github.com/easyaspi314/xxhash-clean),
|
||||
written by @easyaspi314 and designed for readability
|
||||
(as opposed to the reference library which is designed for speed).
|
206
deps/xxHash/doc/xxhash.cry
vendored
Normal file
206
deps/xxHash/doc/xxhash.cry
vendored
Normal file
@ -0,0 +1,206 @@
|
||||
module xxhash where
|
||||
|
||||
/**
|
||||
* The 32-bit variant of xxHash. The first argument is the sequence
|
||||
* of L bytes to hash. The second argument is a seed value.
|
||||
*/
|
||||
XXH32 : {L} (fin L) => [L][8] -> [32] -> [32]
|
||||
XXH32 input seed = XXH32_avalanche acc1
|
||||
where (stripes16 # stripes4 # stripes1) = input
|
||||
accR = foldl XXH32_rounds (XXH32_init seed) (split stripes16 : [L/16][16][8])
|
||||
accL = `(L % 2^^32) + if (`L:Integer) < 16
|
||||
then seed + PRIME32_5
|
||||
else XXH32_converge accR
|
||||
acc4 = foldl XXH32_digest4 accL (split stripes4 : [(L%16)/4][4][8])
|
||||
acc1 = foldl XXH32_digest1 acc4 (stripes1 : [L%4][8])
|
||||
|
||||
/**
|
||||
* The 64-bit variant of xxHash. The first argument is the sequence
|
||||
* of L bytes to hash. The second argument is a seed value.
|
||||
*/
|
||||
XXH64 : {L} (fin L) => [L][8] -> [64] -> [64]
|
||||
XXH64 input seed = XXH64_avalanche acc1
|
||||
where (stripes32 # stripes8 # stripes4 # stripes1) = input
|
||||
accR = foldl XXH64_rounds (XXH64_init seed) (split stripes32 : [L/32][32][8])
|
||||
accL = `(L % 2^^64) + if (`L:Integer) < 32
|
||||
then seed + PRIME64_5
|
||||
else XXH64_converge accR
|
||||
acc8 = foldl XXH64_digest8 accL (split stripes8 : [(L%32)/8][8][8])
|
||||
acc4 = foldl XXH64_digest4 acc8 (split stripes4 : [(L%8)/4][4][8])
|
||||
acc1 = foldl XXH64_digest1 acc4 (stripes1 : [L%4][8])
|
||||
|
||||
private
|
||||
|
||||
//Utility functions
|
||||
|
||||
/**
|
||||
* Combines a sequence of bytes into a word using the little-endian
|
||||
* convention.
|
||||
*/
|
||||
toLE bytes = join (reverse bytes)
|
||||
|
||||
//32-bit xxHash helper functions
|
||||
|
||||
//32-bit prime number constants
|
||||
PRIME32_1 = 0x9E3779B1 : [32]
|
||||
PRIME32_2 = 0x85EBCA77 : [32]
|
||||
PRIME32_3 = 0xC2B2AE3D : [32]
|
||||
PRIME32_4 = 0x27D4EB2F : [32]
|
||||
PRIME32_5 = 0x165667B1 : [32]
|
||||
|
||||
/**
|
||||
* The property shows that the hexadecimal representation of the
|
||||
* PRIME32 constants is the same as the binary representation.
|
||||
*/
|
||||
property PRIME32s_as_bits_correct =
|
||||
(PRIME32_1 == 0b10011110001101110111100110110001) /\
|
||||
(PRIME32_2 == 0b10000101111010111100101001110111) /\
|
||||
(PRIME32_3 == 0b11000010101100101010111000111101) /\
|
||||
(PRIME32_4 == 0b00100111110101001110101100101111) /\
|
||||
(PRIME32_5 == 0b00010110010101100110011110110001)
|
||||
|
||||
/**
|
||||
* This function initializes the four internal accumulators of XXH32.
|
||||
*/
|
||||
XXH32_init : [32] -> [4][32]
|
||||
XXH32_init seed = [acc1, acc2, acc3, acc4]
|
||||
where acc1 = seed + PRIME32_1 + PRIME32_2
|
||||
acc2 = seed + PRIME32_2
|
||||
acc3 = seed + 0
|
||||
acc4 = seed - PRIME32_1
|
||||
|
||||
/**
|
||||
* This processes a single lane of the main round function of XXH32.
|
||||
*/
|
||||
XXH32_round : [32] -> [32] -> [32]
|
||||
XXH32_round accN laneN = ((accN + laneN * PRIME32_2) <<< 13) * PRIME32_1
|
||||
|
||||
/**
|
||||
* This is the main round function of XXH32 and processes a stripe,
|
||||
* i.e. 4 lanes with 4 bytes each.
|
||||
*/
|
||||
XXH32_rounds : [4][32] -> [16][8] -> [4][32]
|
||||
XXH32_rounds accs stripe =
|
||||
[ XXH32_round accN (toLE laneN) | accN <- accs | laneN <- split stripe ]
|
||||
|
||||
/**
|
||||
* This function combines the four lane accumulators into a single
|
||||
* 32-bit value.
|
||||
*/
|
||||
XXH32_converge : [4][32] -> [32]
|
||||
XXH32_converge [acc1, acc2, acc3, acc4] =
|
||||
(acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18)
|
||||
|
||||
/**
|
||||
* This function digests a four byte lane
|
||||
*/
|
||||
XXH32_digest4 : [32] -> [4][8] -> [32]
|
||||
XXH32_digest4 acc lane = ((acc + toLE lane * PRIME32_3) <<< 17) * PRIME32_4
|
||||
|
||||
/**
|
||||
* This function digests a single byte lane
|
||||
*/
|
||||
XXH32_digest1 : [32] -> [8] -> [32]
|
||||
XXH32_digest1 acc lane = ((acc + (0 # lane) * PRIME32_5) <<< 11) * PRIME32_1
|
||||
|
||||
/**
|
||||
* This function ensures that all input bits have a chance to impact
|
||||
* any bit in the output digest, resulting in an unbiased
|
||||
* distribution.
|
||||
*/
|
||||
XXH32_avalanche : [32] -> [32]
|
||||
XXH32_avalanche acc0 = acc5
|
||||
where acc1 = acc0 ^ (acc0 >> 15)
|
||||
acc2 = acc1 * PRIME32_2
|
||||
acc3 = acc2 ^ (acc2 >> 13)
|
||||
acc4 = acc3 * PRIME32_3
|
||||
acc5 = acc4 ^ (acc4 >> 16)
|
||||
|
||||
//64-bit xxHash helper functions
|
||||
|
||||
//64-bit prime number constants
|
||||
PRIME64_1 = 0x9E3779B185EBCA87 : [64]
|
||||
PRIME64_2 = 0xC2B2AE3D27D4EB4F : [64]
|
||||
PRIME64_3 = 0x165667B19E3779F9 : [64]
|
||||
PRIME64_4 = 0x85EBCA77C2B2AE63 : [64]
|
||||
PRIME64_5 = 0x27D4EB2F165667C5 : [64]
|
||||
|
||||
/**
|
||||
* The property shows that the hexadecimal representation of the
|
||||
* PRIME64 constants is the same as the binary representation.
|
||||
*/
|
||||
property PRIME64s_as_bits_correct =
|
||||
(PRIME64_1 == 0b1001111000110111011110011011000110000101111010111100101010000111) /\
|
||||
(PRIME64_2 == 0b1100001010110010101011100011110100100111110101001110101101001111) /\
|
||||
(PRIME64_3 == 0b0001011001010110011001111011000110011110001101110111100111111001) /\
|
||||
(PRIME64_4 == 0b1000010111101011110010100111011111000010101100101010111001100011) /\
|
||||
(PRIME64_5 == 0b0010011111010100111010110010111100010110010101100110011111000101)
|
||||
|
||||
/**
|
||||
* This function initializes the four internal accumulators of XXH64.
|
||||
*/
|
||||
XXH64_init : [64] -> [4][64]
|
||||
XXH64_init seed = [acc1, acc2, acc3, acc4]
|
||||
where acc1 = seed + PRIME64_1 + PRIME64_2
|
||||
acc2 = seed + PRIME64_2
|
||||
acc3 = seed + 0
|
||||
acc4 = seed - PRIME64_1
|
||||
|
||||
/**
|
||||
* This processes a single lane of the main round function of XXH64.
|
||||
*/
|
||||
XXH64_round : [64] -> [64] -> [64]
|
||||
XXH64_round accN laneN = ((accN + laneN * PRIME64_2) <<< 31) * PRIME64_1
|
||||
|
||||
/**
|
||||
* This is the main round function of XXH64 and processes a stripe,
|
||||
* i.e. 4 lanes with 8 bytes each.
|
||||
*/
|
||||
XXH64_rounds : [4][64] -> [32][8] -> [4][64]
|
||||
XXH64_rounds accs stripe =
|
||||
[ XXH64_round accN (toLE laneN) | accN <- accs | laneN <- split stripe ]
|
||||
|
||||
/**
|
||||
* This is a helper function, used to merge the four lane accumulators.
|
||||
*/
|
||||
mergeAccumulator : [64] -> [64] -> [64]
|
||||
mergeAccumulator acc accN = (acc ^ XXH64_round 0 accN) * PRIME64_1 + PRIME64_4
|
||||
|
||||
/**
|
||||
* This function combines the four lane accumulators into a single
|
||||
* 64-bit value.
|
||||
*/
|
||||
XXH64_converge : [4][64] -> [64]
|
||||
XXH64_converge [acc1, acc2, acc3, acc4] =
|
||||
foldl mergeAccumulator ((acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18)) [acc1, acc2, acc3, acc4]
|
||||
|
||||
/**
|
||||
* This function digests an eight byte lane
|
||||
*/
|
||||
XXH64_digest8 : [64] -> [8][8] -> [64]
|
||||
XXH64_digest8 acc lane = ((acc ^ XXH64_round 0 (toLE lane)) <<< 27) * PRIME64_1 + PRIME64_4
|
||||
|
||||
/**
|
||||
* This function digests a four byte lane
|
||||
*/
|
||||
XXH64_digest4 : [64] -> [4][8] -> [64]
|
||||
XXH64_digest4 acc lane = ((acc ^ (0 # toLE lane) * PRIME64_1) <<< 23) * PRIME64_2 + PRIME64_3
|
||||
|
||||
/**
|
||||
* This function digests a single byte lane
|
||||
*/
|
||||
XXH64_digest1 : [64] -> [8] -> [64]
|
||||
XXH64_digest1 acc lane = ((acc ^ (0 # lane) * PRIME64_5) <<< 11) * PRIME64_1
|
||||
|
||||
/**
|
||||
* This function ensures that all input bits have a chance to impact
|
||||
* any bit in the output digest, resulting in an unbiased
|
||||
* distribution.
|
||||
*/
|
||||
XXH64_avalanche : [64] -> [64]
|
||||
XXH64_avalanche acc0 = acc5
|
||||
where acc1 = acc0 ^ (acc0 >> 33)
|
||||
acc2 = acc1 * PRIME64_2
|
||||
acc3 = acc2 ^ (acc2 >> 29)
|
||||
acc4 = acc3 * PRIME64_3
|
||||
acc5 = acc4 ^ (acc4 >> 32)
|
92
deps/xxHash/doc/xxhash_spec.md
vendored
92
deps/xxHash/doc/xxhash_spec.md
vendored
@ -16,7 +16,7 @@ Distribution of this document is unlimited.
|
||||
|
||||
### Version
|
||||
|
||||
0.1.0 (15/01/18)
|
||||
0.1.1 (10/10/18)
|
||||
|
||||
|
||||
Table of Contents
|
||||
@ -31,25 +31,25 @@ Table of Contents
|
||||
Introduction
|
||||
----------------
|
||||
|
||||
This document describes the xxHash digest algorithm, for both 32 and 64 variants, named `XXH32` and `XXH64`. The algorithm takes as input a message of arbitrary length and an optional seed value, it then produces an output of 32 or 64-bit as "fingerprint" or "digest".
|
||||
This document describes the xxHash digest algorithm for both 32-bit and 64-bit variants, named `XXH32` and `XXH64`. The algorithm takes an input a message of arbitrary length and an optional seed value, then produces an output of 32 or 64-bit as "fingerprint" or "digest".
|
||||
|
||||
xxHash is primarily designed for speed. It is labelled non-cryptographic, and is not meant to avoid intentional collisions (same digest for 2 different messages), or to prevent producing a message with predefined digest.
|
||||
xxHash is primarily designed for speed. It is labeled non-cryptographic, and is not meant to avoid intentional collisions (same digest for 2 different messages), or to prevent producing a message with a predefined digest.
|
||||
|
||||
XXH32 is designed to be fast on 32-bits machines.
|
||||
XXH64 is designed to be fast on 64-bits machines.
|
||||
XXH32 is designed to be fast on 32-bit machines.
|
||||
XXH64 is designed to be fast on 64-bit machines.
|
||||
Both variants produce different output.
|
||||
However, a given variant shall produce exactly the same output, irrespective of the cpu / os used. In particular, the result remains identical whatever the endianness and width of the cpu.
|
||||
However, a given variant shall produce exactly the same output, irrespective of the cpu / os used. In particular, the result remains identical whatever the endianness and width of the cpu is.
|
||||
|
||||
### Operation notations
|
||||
|
||||
All operations are performed modulo {32,64} bits. Arithmetic overflows are expected.
|
||||
`XXH32` uses 32-bit modular operations. `XXH64` uses 64-bit modular operations.
|
||||
|
||||
- `+` : denote modular addition
|
||||
- `*` : denote modular multiplication
|
||||
- `X <<< s` : denote the value obtained by circularly shifting (rotating) `X` left by `s` bit positions.
|
||||
- `X >> s` : denote the value obtained by shifting `X` right by s bit positions. Upper `s` bits become `0`.
|
||||
- `X xor Y` : denote the bit-wise XOR of `X` and `Y` (same width).
|
||||
- `+`: denotes modular addition
|
||||
- `*`: denotes modular multiplication
|
||||
- `X <<< s`: denotes the value obtained by circularly shifting (rotating) `X` left by `s` bit positions.
|
||||
- `X >> s`: denotes the value obtained by shifting `X` right by s bit positions. Upper `s` bits become `0`.
|
||||
- `X xor Y`: denotes the bit-wise XOR of `X` and `Y` (same width).
|
||||
|
||||
|
||||
XXH32 Algorithm Description
|
||||
@ -61,15 +61,17 @@ We begin by supposing that we have a message of any length `L` as input, and tha
|
||||
|
||||
The algorithm collect and transform input in _stripes_ of 16 bytes. The transforms are stored inside 4 "accumulators", each one storing an unsigned 32-bit value. Each accumulator can be processed independently in parallel, speeding up processing for cpu with multiple execution units.
|
||||
|
||||
The algorithm uses 32-bits addition, multiplication, rotate, shift and xor operations. Many operations require some 32-bits prime number constants, all defined below :
|
||||
The algorithm uses 32-bits addition, multiplication, rotate, shift and xor operations. Many operations require some 32-bits prime number constants, all defined below:
|
||||
|
||||
static const u32 PRIME32_1 = 2654435761U;
|
||||
static const u32 PRIME32_2 = 2246822519U;
|
||||
static const u32 PRIME32_3 = 3266489917U;
|
||||
static const u32 PRIME32_4 = 668265263U;
|
||||
static const u32 PRIME32_5 = 374761393U;
|
||||
static const u32 PRIME32_1 = 0x9E3779B1U; // 0b10011110001101110111100110110001
|
||||
static const u32 PRIME32_2 = 0x85EBCA77U; // 0b10000101111010111100101001110111
|
||||
static const u32 PRIME32_3 = 0xC2B2AE3DU; // 0b11000010101100101010111000111101
|
||||
static const u32 PRIME32_4 = 0x27D4EB2FU; // 0b00100111110101001110101100101111
|
||||
static const u32 PRIME32_5 = 0x165667B1U; // 0b00010110010101100110011110110001
|
||||
|
||||
### Step 1. Initialise internal accumulators
|
||||
These constants are prime numbers, and feature a good mix of bits 1 and 0, neither too regular, nor too dissymmetric. These properties help dispersion capabilities.
|
||||
|
||||
### Step 1. Initialize internal accumulators
|
||||
|
||||
Each accumulator gets an initial value based on optional `seed` input. Since the `seed` is optional, it can be `0`.
|
||||
|
||||
@ -78,11 +80,11 @@ Each accumulator gets an initial value based on optional `seed` input. Since the
|
||||
u32 acc3 = seed + 0;
|
||||
u32 acc4 = seed - PRIME32_1;
|
||||
|
||||
#### Special case : input is less than 16 bytes
|
||||
#### Special case: input is less than 16 bytes
|
||||
|
||||
When input is too small (< 16 bytes), the algorithm will not process any stripe. Consequently, it will not make use of parallel accumulators.
|
||||
When the input is too small (< 16 bytes), the algorithm will not process any stripes. Consequently, it will not make use of parallel accumulators.
|
||||
|
||||
In which case, a simplified initialization is performed, using a single accumulator :
|
||||
In this case, a simplified initialization is performed, using a single accumulator:
|
||||
|
||||
u32 acc = seed + PRIME32_5;
|
||||
|
||||
@ -96,7 +98,7 @@ The first lane is used to update accumulator 1, the second lane is used to updat
|
||||
|
||||
Each lane read its associated 32-bit value using __little-endian__ convention.
|
||||
|
||||
For each {lane, accumulator}, the update process is called a _round_, and applies the following formula :
|
||||
For each {lane, accumulator}, the update process is called a _round_, and applies the following formula:
|
||||
|
||||
accN = accN + (laneN * PRIME32_2);
|
||||
accN = accN <<< 13;
|
||||
@ -104,12 +106,12 @@ For each {lane, accumulator}, the update process is called a _round_, and applie
|
||||
|
||||
This shuffles the bits so that any bit from input _lane_ impacts several bits in output _accumulator_. All operations are performed modulo 2^32.
|
||||
|
||||
Input is consumed one full stripe at a time. Step 2 is looped as many times as necessary to consume the whole input, except the last remaining bytes which cannot form a stripe (< 16 bytes).
|
||||
Input is consumed one full stripe at a time. Step 2 is looped as many times as necessary to consume the whole input, except for the last remaining bytes which cannot form a stripe (< 16 bytes).
|
||||
When that happens, move to step 3.
|
||||
|
||||
### Step 3. Accumulator convergence
|
||||
|
||||
All 4 lane accumulators from previous steps are merged to produce a single remaining accumulator of same width (32-bit). The associated formula is as follows :
|
||||
All 4 lane accumulators from the previous steps are merged to produce a single remaining accumulator of the same width (32-bit). The associated formula is as follows:
|
||||
|
||||
acc = (acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18);
|
||||
|
||||
@ -124,7 +126,7 @@ Note that, if input length is so large that it requires more than 32-bits, only
|
||||
### Step 5. Consume remaining input
|
||||
|
||||
There may be up to 15 bytes remaining to consume from the input.
|
||||
The final stage will digest them according to following pseudo-code :
|
||||
The final stage will digest them according to following pseudo-code:
|
||||
|
||||
while (remainingLength >= 4) {
|
||||
lane = read_32bit_little_endian(input_ptr);
|
||||
@ -164,17 +166,19 @@ XXH64 Algorithm Description
|
||||
|
||||
### Overview
|
||||
|
||||
`XXH64` algorithm structure is very similar to `XXH32` one. The major difference is that `XXH64` uses 64-bit arithmetic, speeding up memory transfer for 64-bit compliant systems, but also relying on cpu capability to efficiently perform 64-bit operations.
|
||||
`XXH64`'s algorithm structure is very similar to `XXH32` one. The major difference is that `XXH64` uses 64-bit arithmetic, speeding up memory transfer for 64-bit compliant systems, but also relying on cpu capability to efficiently perform 64-bit operations.
|
||||
|
||||
The algorithm collects and transforms input in _stripes_ of 32 bytes. The transforms are stored inside 4 "accumulators", each one storing an unsigned 64-bit value. Each accumulator can be processed independently in parallel, speeding up processing for cpu with multiple execution units.
|
||||
|
||||
The algorithm uses 64-bit addition, multiplication, rotate, shift and xor operations. Many operations require some 64-bit prime number constants, all defined below :
|
||||
The algorithm uses 64-bit addition, multiplication, rotate, shift and xor operations. Many operations require some 64-bit prime number constants, all defined below:
|
||||
|
||||
static const u64 PRIME64_1 = 11400714785074694791ULL;
|
||||
static const u64 PRIME64_2 = 14029467366897019727ULL;
|
||||
static const u64 PRIME64_3 = 1609587929392839161ULL;
|
||||
static const u64 PRIME64_4 = 9650029242287828579ULL;
|
||||
static const u64 PRIME64_5 = 2870177450012600261ULL;
|
||||
static const u64 PRIME64_1 = 0x9E3779B185EBCA87ULL; // 0b1001111000110111011110011011000110000101111010111100101010000111
|
||||
static const u64 PRIME64_2 = 0xC2B2AE3D27D4EB4FULL; // 0b1100001010110010101011100011110100100111110101001110101101001111
|
||||
static const u64 PRIME64_3 = 0x165667B19E3779F9ULL; // 0b0001011001010110011001111011000110011110001101110111100111111001
|
||||
static const u64 PRIME64_4 = 0x85EBCA77C2B2AE63ULL; // 0b1000010111101011110010100111011111000010101100101010111001100011
|
||||
static const u64 PRIME64_5 = 0x27D4EB2F165667C5ULL; // 0b0010011111010100111010110010111100010110010101100110011111000101
|
||||
|
||||
These constants are prime numbers, and feature a good mix of bits 1 and 0, neither too regular, nor too dissymmetric. These properties help dispersion capabilities.
|
||||
|
||||
### Step 1. Initialise internal accumulators
|
||||
|
||||
@ -185,11 +189,11 @@ Each accumulator gets an initial value based on optional `seed` input. Since the
|
||||
u64 acc3 = seed + 0;
|
||||
u64 acc4 = seed - PRIME64_1;
|
||||
|
||||
#### Special case : input is less than 32 bytes
|
||||
#### Special case: input is less than 32 bytes
|
||||
|
||||
When input is too small (< 32 bytes), the algorithm will not process any stripe. Consequently, it will not make use of parallel accumulators.
|
||||
When the input is too small (< 32 bytes), the algorithm will not process any stripes. Consequently, it will not make use of parallel accumulators.
|
||||
|
||||
In which case, a simplified initialization is performed, using a single accumulator :
|
||||
In this case, a simplified initialization is performed, using a single accumulator:
|
||||
|
||||
u64 acc = seed + PRIME64_5;
|
||||
|
||||
@ -203,7 +207,7 @@ The first lane is used to update accumulator 1, the second lane is used to updat
|
||||
|
||||
Each lane read its associated 64-bit value using __little-endian__ convention.
|
||||
|
||||
For each {lane, accumulator}, the update process is called a _round_, and applies the following formula :
|
||||
For each {lane, accumulator}, the update process is called a _round_, and applies the following formula:
|
||||
|
||||
round(accN,laneN):
|
||||
accN = accN + (laneN * PRIME64_2);
|
||||
@ -212,21 +216,21 @@ For each {lane, accumulator}, the update process is called a _round_, and applie
|
||||
|
||||
This shuffles the bits so that any bit from input _lane_ impacts several bits in output _accumulator_. All operations are performed modulo 2^64.
|
||||
|
||||
Input is consumed one full stripe at a time. Step 2 is looped as many times as necessary to consume the whole input, except the last remaining bytes which cannot form a stripe (< 32 bytes).
|
||||
Input is consumed one full stripe at a time. Step 2 is looped as many times as necessary to consume the whole input, except for the last remaining bytes which cannot form a stripe (< 32 bytes).
|
||||
When that happens, move to step 3.
|
||||
|
||||
### Step 3. Accumulator convergence
|
||||
|
||||
All 4 lane accumulators from previous steps are merged to produce a single remaining accumulator of same width (64-bit). The associated formula is as follows.
|
||||
|
||||
Note that accumulator convergence is more complex than 32-bit variant, and requires to define another function called _mergeAccumulator()_ :
|
||||
Note that accumulator convergence is more complex than 32-bit variant, and requires to define another function called _mergeAccumulator()_:
|
||||
|
||||
mergeAccumulator(acc,accN):
|
||||
acc = acc xor round(0, accN);
|
||||
acc = acc * PRIME64_1
|
||||
return acc + PRIME64_4;
|
||||
|
||||
which is then used in the convergence formula :
|
||||
which is then used in the convergence formula:
|
||||
|
||||
acc = (acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18);
|
||||
acc = mergeAccumulator(acc, acc1);
|
||||
@ -243,7 +247,7 @@ The input total length is presumed known at this stage. This step is just about
|
||||
### Step 5. Consume remaining input
|
||||
|
||||
There may be up to 31 bytes remaining to consume from the input.
|
||||
The final stage will digest them according to following pseudo-code :
|
||||
The final stage will digest them according to following pseudo-code:
|
||||
|
||||
while (remainingLength >= 8) {
|
||||
lane = read_64bit_little_endian(input_ptr);
|
||||
@ -295,17 +299,19 @@ The algorithm allows input to be streamed and processed in multiple steps. In su
|
||||
|
||||
On 64-bit systems, the 64-bit variant `XXH64` is generally faster to compute, so it is a recommended variant, even when only 32-bit are needed.
|
||||
|
||||
On 32-bit systems though, positions are reversed : `XXH64` performance is reduced, due to its usage of 64-bit arithmetic. `XXH32` becomes a faster variant.
|
||||
On 32-bit systems though, positions are reversed: `XXH64` performance is reduced, due to its usage of 64-bit arithmetic. `XXH32` becomes a faster variant.
|
||||
|
||||
|
||||
Reference Implementation
|
||||
----------------------------------------
|
||||
|
||||
A reference library written in C is available at http://www.xxhash.com .
|
||||
A reference library written in C is available at https://www.xxhash.com.
|
||||
The web page also links to multiple other implementations written in many different languages.
|
||||
It links to the [github project page](https://github.com/Cyan4973/xxHash) where an [issue board](https://github.com/Cyan4973/xxHash/issues) can be used for further public discussions on the topic.
|
||||
|
||||
|
||||
Version changes
|
||||
--------------------
|
||||
v0.1.0 : initial release
|
||||
v0.7.3: Minor fixes
|
||||
v0.1.1: added a note on rationale for selection of constants
|
||||
v0.1.0: initial release
|
||||
|
15
deps/xxHash/libxxhash.pc.in
vendored
Normal file
15
deps/xxHash/libxxhash.pc.in
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# xxHash - Extremely fast hash algorithm
|
||||
# Copyright (C) 2012-2020, Yann Collet, Facebook
|
||||
# BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
|
||||
|
||||
prefix=@PREFIX@
|
||||
exec_prefix=@EXECPREFIX@
|
||||
includedir=${prefix}/@INCLUDEDIR@
|
||||
libdir=${exec_prefix}/@LIBDIR@
|
||||
|
||||
Name: xxhash
|
||||
Description: extremely fast hash algorithm
|
||||
URL: https://www.xxhash.com/
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lxxhash
|
||||
Cflags: -I${includedir}
|
83
deps/xxHash/tests/Makefile
vendored
Normal file
83
deps/xxHash/tests/Makefile
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
CFLAGS += -Wall -Wextra -Wundef -g
|
||||
|
||||
NM = nm
|
||||
GREP = grep
|
||||
|
||||
# Define *.exe as extension for Windows systems
|
||||
ifneq (,$(filter Windows%,$(OS)))
|
||||
EXT =.exe
|
||||
else
|
||||
EXT =
|
||||
endif
|
||||
|
||||
ifneq (,$(filter %UTF-8,$(LANG)))
|
||||
ENABLE_UNICODE ?= 1
|
||||
else
|
||||
ENABLE_UNICODE ?= 0
|
||||
endif
|
||||
|
||||
.PHONY: default
|
||||
default: all
|
||||
|
||||
.PHONY: all
|
||||
all: test
|
||||
|
||||
.PHONY: test
|
||||
test: test_multiInclude test_unicode
|
||||
|
||||
.PHONY: test_multiInclude
|
||||
test_multiInclude:
|
||||
@$(MAKE) clean
|
||||
# compile without xxhash.o, ensure symbols exist within target
|
||||
# Note: built using only default rules
|
||||
$(MAKE) multiInclude
|
||||
@$(MAKE) clean
|
||||
# compile with xxhash.o, to detect duplicated symbols
|
||||
$(MAKE) multiInclude_withxxhash
|
||||
@$(MAKE) clean
|
||||
# Note: XXH_INLINE_ALL with XXH_NAMESPACE is currently disabled
|
||||
# compile with XXH_NAMESPACE
|
||||
# CPPFLAGS=-DXXH_NAMESPACE=TESTN_ $(MAKE) multiInclude_withxxhash
|
||||
# no symbol prefixed TESTN_ should exist
|
||||
# ! $(NM) multiInclude_withxxhash | $(GREP) TESTN_
|
||||
#$(MAKE) clean
|
||||
# compile with XXH_NAMESPACE and without xxhash.o
|
||||
# CPPFLAGS=-DXXH_NAMESPACE=TESTN_ $(MAKE) multiInclude
|
||||
# no symbol prefixed TESTN_ should exist
|
||||
# ! $(NM) multiInclude | $(GREP) TESTN_
|
||||
#@$(MAKE) clean
|
||||
|
||||
.PHONY: test_ppc_redefine
|
||||
test_ppc_redefine: ppc_define.c
|
||||
@$(MAKE) clean
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c $^
|
||||
|
||||
xxhsum$(EXT): ../xxhash.c ../xxhash.h ../xxhsum.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) ../xxhash.c ../xxhsum.c -o $@
|
||||
|
||||
# Make sure that Unicode filenames work.
|
||||
# https://github.com/Cyan4973/xxHash/issues/293
|
||||
.PHONY: test_unicode
|
||||
ifeq (0,$(ENABLE_UNICODE))
|
||||
test_unicode:
|
||||
@echo "Skipping Unicode test, your terminal doesn't appear to support UTF-8."
|
||||
@echo "Try with ENABLE_UNICODE=1"
|
||||
else
|
||||
test_unicode: xxhsum$(EXT) generate_unicode_test.c
|
||||
# Generate a Unicode filename test dynamically
|
||||
# to keep UTF-8 out of the source tree.
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) generate_unicode_test.c -o generate_unicode_test$(EXT)
|
||||
./generate_unicode_test$(EXT)
|
||||
$(SHELL) ./unicode_test.sh
|
||||
endif
|
||||
|
||||
xxhash.o: ../xxhash.c ../xxhash.h
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -c -o $@ $<
|
||||
|
||||
multiInclude_withxxhash: multiInclude.o xxhash.o
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^
|
||||
|
||||
clean:
|
||||
@$(RM) *.o
|
||||
@$(RM) multiInclude multiInclude_withxxhash
|
||||
@$(RM) *.unicode generate_unicode_test$(EXT) unicode_test.* xxhsum$(EXT)
|
11
deps/xxHash/tests/bench/.gitignore
vendored
Normal file
11
deps/xxHash/tests/bench/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# build artifacts
|
||||
|
||||
*.o
|
||||
benchHash
|
||||
benchHash32
|
||||
benchHash_avx2
|
||||
benchHash_hw
|
||||
|
||||
# test files
|
||||
|
||||
test*
|
339
deps/xxHash/tests/bench/LICENSE
vendored
Normal file
339
deps/xxHash/tests/bench/LICENSE
vendored
Normal file
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
67
deps/xxHash/tests/bench/Makefile
vendored
Normal file
67
deps/xxHash/tests/bench/Makefile
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
# ################################################################
|
||||
# xxHash benchHash Makefile
|
||||
# Copyright (C) 2019-2020 Yann Collet
|
||||
#
|
||||
# GPL v2 License
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# You can contact the author at:
|
||||
# - xxHash homepage: https://www.xxhash.com
|
||||
# - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
# ################################################################
|
||||
# benchHash: A generic benchmark for hash algorithms
|
||||
# measuring throughput, latency and bandwidth
|
||||
# ################################################################
|
||||
|
||||
|
||||
CPPFLAGS += -I../.. # directory of xxHash source files
|
||||
CFLAGS ?= -O3
|
||||
CFLAGS += -std=c99 -Wall -Wextra -Wstrict-aliasing=1
|
||||
CFLAGS += $(MOREFLAGS) # custom way to add flags
|
||||
CXXFLAGS ?= -O3
|
||||
LDFLAGS += $(MOREFLAGS)
|
||||
|
||||
|
||||
OBJ_LIST = main.o bhDisplay.o benchHash.o benchfn.o timefn.o
|
||||
|
||||
|
||||
default: benchHash
|
||||
|
||||
all: benchHash
|
||||
|
||||
benchHash32: CFLAGS += -m32
|
||||
benchHash32: CXXFLAGS += -m32
|
||||
|
||||
benchHash_avx2: CFLAGS += -mavx2
|
||||
benchHash_avx2: CXXFLAGS += -mavx2
|
||||
|
||||
benchHash_hw: CPPFLAGS += -DHARDWARE_SUPPORT
|
||||
benchHash_hw: CFLAGS += -mavx2 -maes
|
||||
benchHash_hw: CXXFLAGS += -mavx2 -mpclmul -std=c++14
|
||||
|
||||
benchHash benchHash32 benchHash_avx2 benchHash_nosimd benchHash_hw: $(OBJ_LIST)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
|
||||
|
||||
|
||||
main.o: bhDisplay.h hashes.h
|
||||
|
||||
bhDisplay.o: bhDisplay.h benchHash.h
|
||||
|
||||
benchHash.o: benchHash.h
|
||||
|
||||
|
||||
clean:
|
||||
$(RM) *.o benchHash benchHash32 benchHash_avx2 benchHash_hw
|
164
deps/xxHash/tests/bench/benchHash.c
vendored
Normal file
164
deps/xxHash/tests/bench/benchHash.c
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Hash benchmark module
|
||||
* Part of the xxHash project
|
||||
* Copyright (C) 2019-2020 Yann Collet
|
||||
*
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
/* benchmark hash functions */
|
||||
|
||||
#include <stdlib.h> // malloc
|
||||
#include <assert.h>
|
||||
|
||||
#include "benchHash.h"
|
||||
|
||||
|
||||
static void initBuffer(void* buffer, size_t size)
|
||||
{
|
||||
const unsigned long long k1 = 11400714785074694791ULL; /* 0b1001111000110111011110011011000110000101111010111100101010000111 */
|
||||
const unsigned long long k2 = 14029467366897019727ULL; /* 0b1100001010110010101011100011110100100111110101001110101101001111 */
|
||||
unsigned long long acc = k2;
|
||||
unsigned char* const p = (unsigned char*)buffer;
|
||||
for (size_t s = 0; s < size; s++) {
|
||||
acc *= k1;
|
||||
p[s] = (unsigned char)(acc >> 56);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define MARGIN_FOR_LATENCY 1024
|
||||
#define START_MASK (MARGIN_FOR_LATENCY-1)
|
||||
|
||||
typedef size_t (*sizeFunction_f)(size_t targetSize);
|
||||
|
||||
/*
|
||||
* bench_hash_internal():
|
||||
* Benchmarks hashfn repeateadly over single input of size `size`
|
||||
* return: nb of hashes per second
|
||||
*/
|
||||
static double
|
||||
bench_hash_internal(BMK_benchFn_t hashfn, void* payload,
|
||||
size_t nbBlocks, sizeFunction_f selectSize, size_t size,
|
||||
unsigned total_time_ms, unsigned iter_time_ms)
|
||||
{
|
||||
BMK_timedFnState_shell shell;
|
||||
BMK_timedFnState_t* const txf = BMK_initStatic_timedFnState(&shell, sizeof(shell), total_time_ms, iter_time_ms);
|
||||
assert(txf != NULL);
|
||||
|
||||
size_t const srcSize = (size_t)size;
|
||||
size_t const srcBufferSize = srcSize + MARGIN_FOR_LATENCY;
|
||||
void* const srcBuffer = malloc(srcBufferSize);
|
||||
assert(srcBuffer != NULL);
|
||||
initBuffer(srcBuffer, srcBufferSize);
|
||||
#define FAKE_DSTSIZE 32
|
||||
size_t const dstSize = FAKE_DSTSIZE;
|
||||
char dstBuffer_static[FAKE_DSTSIZE] = {0};
|
||||
|
||||
#define NB_BLOCKS_MAX 1024
|
||||
const void* srcBuffers[NB_BLOCKS_MAX];
|
||||
size_t srcSizes[NB_BLOCKS_MAX];
|
||||
void* dstBuffers[NB_BLOCKS_MAX];
|
||||
size_t dstCapacities[NB_BLOCKS_MAX];
|
||||
assert(nbBlocks < NB_BLOCKS_MAX);
|
||||
|
||||
assert(size > 0);
|
||||
for (size_t n=0; n < nbBlocks; n++) {
|
||||
srcBuffers[n] = srcBuffer;
|
||||
srcSizes[n] = selectSize(size);
|
||||
dstBuffers[n] = dstBuffer_static;
|
||||
dstCapacities[n] = dstSize;
|
||||
}
|
||||
|
||||
|
||||
BMK_benchParams_t params = {
|
||||
.benchFn = hashfn,
|
||||
.benchPayload = payload,
|
||||
.initFn = NULL,
|
||||
.initPayload = NULL,
|
||||
.errorFn = NULL,
|
||||
.blockCount = nbBlocks,
|
||||
.srcBuffers = srcBuffers,
|
||||
.srcSizes = srcSizes,
|
||||
.dstBuffers = dstBuffers,
|
||||
.dstCapacities = dstCapacities,
|
||||
.blockResults = NULL
|
||||
};
|
||||
BMK_runOutcome_t result;
|
||||
|
||||
while (!BMK_isCompleted_TimedFn(txf)) {
|
||||
result = BMK_benchTimedFn(txf, params);
|
||||
assert(BMK_isSuccessful_runOutcome(result));
|
||||
}
|
||||
|
||||
BMK_runTime_t const runTime = BMK_extract_runTime(result);
|
||||
|
||||
free(srcBuffer);
|
||||
assert(runTime.nanoSecPerRun != 0);
|
||||
return (1000000000U / runTime.nanoSecPerRun) * nbBlocks;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static size_t rand_1_N(size_t N) { return ((size_t)rand() % N) + 1; }
|
||||
|
||||
static size_t identity(size_t s) { return s; }
|
||||
|
||||
static size_t
|
||||
benchLatency(const void* src, size_t srcSize,
|
||||
void* dst, size_t dstCapacity,
|
||||
void* customPayload)
|
||||
{
|
||||
(void)dst; (void)dstCapacity;
|
||||
BMK_benchFn_t benchfn = (BMK_benchFn_t)customPayload;
|
||||
static size_t hash = 0;
|
||||
|
||||
const void* const start = (const char*)src + (hash & START_MASK);
|
||||
|
||||
return hash = benchfn(start, srcSize, dst, dstCapacity, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef SIZE_TO_HASH_PER_ROUND
|
||||
# define SIZE_TO_HASH_PER_ROUND 200000
|
||||
#endif
|
||||
|
||||
#ifndef NB_HASH_ROUNDS_MAX
|
||||
# define NB_HASH_ROUNDS_MAX 1000
|
||||
#endif
|
||||
|
||||
double bench_hash(BMK_benchFn_t hashfn,
|
||||
BMK_benchMode benchMode,
|
||||
size_t size, BMK_sizeMode sizeMode,
|
||||
unsigned total_time_ms, unsigned iter_time_ms)
|
||||
{
|
||||
sizeFunction_f const sizef = (sizeMode == BMK_fixedSize) ? identity : rand_1_N;
|
||||
BMK_benchFn_t const benchfn = (benchMode == BMK_throughput) ? hashfn : benchLatency;
|
||||
BMK_benchFn_t const payload = (benchMode == BMK_throughput) ? NULL : hashfn;
|
||||
|
||||
size_t nbBlocks = (SIZE_TO_HASH_PER_ROUND / size) + 1;
|
||||
if (nbBlocks > NB_HASH_ROUNDS_MAX) nbBlocks = NB_HASH_ROUNDS_MAX;
|
||||
|
||||
return bench_hash_internal(benchfn, payload,
|
||||
nbBlocks, sizef, size,
|
||||
total_time_ms, iter_time_ms);
|
||||
}
|
67
deps/xxHash/tests/bench/benchHash.h
vendored
Normal file
67
deps/xxHash/tests/bench/benchHash.h
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Hash benchmark module
|
||||
* Part of the xxHash project
|
||||
* Copyright (C) 2019-2020 Yann Collet
|
||||
*
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BENCH_HASH_H_983426678
|
||||
#define BENCH_HASH_H_983426678
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* === Dependencies === */
|
||||
|
||||
#include "benchfn.h" /* BMK_benchFn_t */
|
||||
|
||||
|
||||
/* === Declarations === */
|
||||
|
||||
typedef enum { BMK_throughput, BMK_latency } BMK_benchMode;
|
||||
|
||||
typedef enum { BMK_fixedSize, /* hash always `size` bytes */
|
||||
BMK_randomSize, /* hash a random nb of bytes, between 1 and `size` (inclusive) */
|
||||
} BMK_sizeMode;
|
||||
|
||||
/*
|
||||
* bench_hash():
|
||||
* Returns speed expressed as nb hashes per second.
|
||||
* total_time_ms: time spent benchmarking the hash function with given parameters
|
||||
* iter_time_ms: time spent for one round. If multiple rounds are run,
|
||||
* bench_hash() will report the speed of best round.
|
||||
*/
|
||||
double bench_hash(BMK_benchFn_t hashfn,
|
||||
BMK_benchMode benchMode,
|
||||
size_t size, BMK_sizeMode sizeMode,
|
||||
unsigned total_time_ms, unsigned iter_time_ms);
|
||||
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BENCH_HASH_H_983426678 */
|
252
deps/xxHash/tests/bench/benchfn.c
vendored
Normal file
252
deps/xxHash/tests/bench/benchfn.c
vendored
Normal file
@ -0,0 +1,252 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2020 Yann Collet, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under both the BSD-style license (found in the
|
||||
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
* You may select, at your option, one of the above-listed licenses.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* *************************************
|
||||
* Includes
|
||||
***************************************/
|
||||
#include <stdlib.h> /* malloc, free */
|
||||
#include <string.h> /* memset */
|
||||
#undef NDEBUG /* assert must not be disabled */
|
||||
#include <assert.h> /* assert */
|
||||
|
||||
#include "timefn.h" /* UTIL_time_t, UTIL_getTime */
|
||||
#include "benchfn.h"
|
||||
|
||||
|
||||
/* *************************************
|
||||
* Constants
|
||||
***************************************/
|
||||
#define TIMELOOP_MICROSEC SEC_TO_MICRO /* 1 second */
|
||||
#define TIMELOOP_NANOSEC (1*1000000000ULL) /* 1 second */
|
||||
|
||||
#define KB *(1 <<10)
|
||||
#define MB *(1 <<20)
|
||||
#define GB *(1U<<30)
|
||||
|
||||
|
||||
/* *************************************
|
||||
* Debug errors
|
||||
***************************************/
|
||||
#if defined(DEBUG) && (DEBUG >= 1)
|
||||
# include <stdio.h> /* fprintf */
|
||||
# define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
|
||||
# define DEBUGOUTPUT(...) { if (DEBUG) DISPLAY(__VA_ARGS__); }
|
||||
#else
|
||||
# define DEBUGOUTPUT(...)
|
||||
#endif
|
||||
|
||||
|
||||
/* error without displaying */
|
||||
#define RETURN_QUIET_ERROR(retValue, ...) { \
|
||||
DEBUGOUTPUT("%s: %i: \n", __FILE__, __LINE__); \
|
||||
DEBUGOUTPUT("Error : "); \
|
||||
DEBUGOUTPUT(__VA_ARGS__); \
|
||||
DEBUGOUTPUT(" \n"); \
|
||||
return retValue; \
|
||||
}
|
||||
|
||||
|
||||
/* *************************************
|
||||
* Benchmarking an arbitrary function
|
||||
***************************************/
|
||||
|
||||
int BMK_isSuccessful_runOutcome(BMK_runOutcome_t outcome)
|
||||
{
|
||||
return outcome.error_tag_never_ever_use_directly == 0;
|
||||
}
|
||||
|
||||
/* warning : this function will stop program execution if outcome is invalid !
|
||||
* check outcome validity first, using BMK_isValid_runResult() */
|
||||
BMK_runTime_t BMK_extract_runTime(BMK_runOutcome_t outcome)
|
||||
{
|
||||
assert(outcome.error_tag_never_ever_use_directly == 0);
|
||||
return outcome.internal_never_ever_use_directly;
|
||||
}
|
||||
|
||||
size_t BMK_extract_errorResult(BMK_runOutcome_t outcome)
|
||||
{
|
||||
assert(outcome.error_tag_never_ever_use_directly != 0);
|
||||
return outcome.error_result_never_ever_use_directly;
|
||||
}
|
||||
|
||||
static BMK_runOutcome_t BMK_runOutcome_error(size_t errorResult)
|
||||
{
|
||||
BMK_runOutcome_t b;
|
||||
memset(&b, 0, sizeof(b));
|
||||
b.error_tag_never_ever_use_directly = 1;
|
||||
b.error_result_never_ever_use_directly = errorResult;
|
||||
return b;
|
||||
}
|
||||
|
||||
static BMK_runOutcome_t BMK_setValid_runTime(BMK_runTime_t runTime)
|
||||
{
|
||||
BMK_runOutcome_t outcome;
|
||||
outcome.error_tag_never_ever_use_directly = 0;
|
||||
outcome.internal_never_ever_use_directly = runTime;
|
||||
return outcome;
|
||||
}
|
||||
|
||||
|
||||
/* initFn will be measured once, benchFn will be measured `nbLoops` times */
|
||||
/* initFn is optional, provide NULL if none */
|
||||
/* benchFn must return a size_t value that errorFn can interpret */
|
||||
/* takes # of blocks and list of size & stuff for each. */
|
||||
/* can report result of benchFn for each block into blockResult. */
|
||||
/* blockResult is optional, provide NULL if this information is not required */
|
||||
/* note : time per loop can be reported as zero if run time < timer resolution */
|
||||
BMK_runOutcome_t BMK_benchFunction(BMK_benchParams_t p,
|
||||
unsigned nbLoops)
|
||||
{
|
||||
/* init */
|
||||
{ size_t i;
|
||||
for (i = 0; i < p.blockCount; i++) {
|
||||
memset(p.dstBuffers[i], 0xE5, p.dstCapacities[i]); /* warm up and erase result buffer */
|
||||
} }
|
||||
|
||||
/* benchmark */
|
||||
{ UTIL_time_t const clockStart = UTIL_getTime();
|
||||
size_t dstSize = 0;
|
||||
unsigned loopNb, blockNb;
|
||||
nbLoops += !nbLoops; /* minimum nbLoops is 1 */
|
||||
if (p.initFn != NULL) p.initFn(p.initPayload);
|
||||
for (loopNb = 0; loopNb < nbLoops; loopNb++) {
|
||||
for (blockNb = 0; blockNb < p.blockCount; blockNb++) {
|
||||
size_t const res = p.benchFn(p.srcBuffers[blockNb], p.srcSizes[blockNb],
|
||||
p.dstBuffers[blockNb], p.dstCapacities[blockNb],
|
||||
p.benchPayload);
|
||||
if (loopNb == 0) {
|
||||
if (p.blockResults != NULL) p.blockResults[blockNb] = res;
|
||||
if ((p.errorFn != NULL) && (p.errorFn(res))) {
|
||||
RETURN_QUIET_ERROR(BMK_runOutcome_error(res),
|
||||
"Function benchmark failed on block %u (of size %u) with error %i",
|
||||
blockNb, (unsigned)p.srcSizes[blockNb], (int)res);
|
||||
}
|
||||
dstSize += res;
|
||||
} }
|
||||
} /* for (loopNb = 0; loopNb < nbLoops; loopNb++) */
|
||||
|
||||
{ PTime const totalTime = UTIL_clockSpanNano(clockStart);
|
||||
BMK_runTime_t rt;
|
||||
rt.nanoSecPerRun = (double)totalTime / nbLoops;
|
||||
rt.sumOfReturn = dstSize;
|
||||
return BMK_setValid_runTime(rt);
|
||||
} }
|
||||
}
|
||||
|
||||
|
||||
/* ==== Benchmarking any function, providing intermediate results ==== */
|
||||
|
||||
struct BMK_timedFnState_s {
|
||||
PTime timeSpent_ns;
|
||||
PTime timeBudget_ns;
|
||||
PTime runBudget_ns;
|
||||
BMK_runTime_t fastestRun;
|
||||
unsigned nbLoops;
|
||||
UTIL_time_t coolTime;
|
||||
}; /* typedef'd to BMK_timedFnState_t within bench.h */
|
||||
|
||||
BMK_timedFnState_t* BMK_createTimedFnState(unsigned total_ms, unsigned run_ms)
|
||||
{
|
||||
BMK_timedFnState_t* const r = (BMK_timedFnState_t*)malloc(sizeof(*r));
|
||||
if (r == NULL) return NULL; /* malloc() error */
|
||||
BMK_resetTimedFnState(r, total_ms, run_ms);
|
||||
return r;
|
||||
}
|
||||
|
||||
void BMK_freeTimedFnState(BMK_timedFnState_t* state) { free(state); }
|
||||
|
||||
BMK_timedFnState_t*
|
||||
BMK_initStatic_timedFnState(void* buffer, size_t size, unsigned total_ms, unsigned run_ms)
|
||||
{
|
||||
typedef char check_size[ 2 * (sizeof(BMK_timedFnState_shell) >= sizeof(struct BMK_timedFnState_s)) - 1]; /* static assert : a compilation failure indicates that BMK_timedFnState_shell is not large enough */
|
||||
typedef struct { check_size c; BMK_timedFnState_t tfs; } tfs_align; /* force tfs to be aligned at its next best position */
|
||||
size_t const tfs_alignment = offsetof(tfs_align, tfs); /* provides the minimal alignment restriction for BMK_timedFnState_t */
|
||||
BMK_timedFnState_t* const r = (BMK_timedFnState_t*)buffer;
|
||||
if (buffer == NULL) return NULL;
|
||||
if (size < sizeof(struct BMK_timedFnState_s)) return NULL;
|
||||
if ((size_t)buffer % tfs_alignment) return NULL; /* buffer must be properly aligned */
|
||||
BMK_resetTimedFnState(r, total_ms, run_ms);
|
||||
return r;
|
||||
}
|
||||
|
||||
void BMK_resetTimedFnState(BMK_timedFnState_t* timedFnState, unsigned total_ms, unsigned run_ms)
|
||||
{
|
||||
if (!total_ms) total_ms = 1 ;
|
||||
if (!run_ms) run_ms = 1;
|
||||
if (run_ms > total_ms) run_ms = total_ms;
|
||||
timedFnState->timeSpent_ns = 0;
|
||||
timedFnState->timeBudget_ns = (PTime)total_ms * TIMELOOP_NANOSEC / 1000;
|
||||
timedFnState->runBudget_ns = (PTime)run_ms * TIMELOOP_NANOSEC / 1000;
|
||||
timedFnState->fastestRun.nanoSecPerRun = (double)TIMELOOP_NANOSEC * 2000000000; /* hopefully large enough : must be larger than any potential measurement */
|
||||
timedFnState->fastestRun.sumOfReturn = (size_t)(-1LL);
|
||||
timedFnState->nbLoops = 1;
|
||||
timedFnState->coolTime = UTIL_getTime();
|
||||
}
|
||||
|
||||
/* Tells if nb of seconds set in timedFnState for all runs is spent.
|
||||
* note : this function will return 1 if BMK_benchFunctionTimed() has actually errored. */
|
||||
int BMK_isCompleted_TimedFn(const BMK_timedFnState_t* timedFnState)
|
||||
{
|
||||
return (timedFnState->timeSpent_ns >= timedFnState->timeBudget_ns);
|
||||
}
|
||||
|
||||
|
||||
#undef MIN
|
||||
#define MIN(a,b) ( (a) < (b) ? (a) : (b) )
|
||||
|
||||
#define MINUSABLETIME (TIMELOOP_NANOSEC / 2) /* 0.5 seconds */
|
||||
|
||||
BMK_runOutcome_t BMK_benchTimedFn(BMK_timedFnState_t* cont,
|
||||
BMK_benchParams_t p)
|
||||
{
|
||||
PTime const runBudget_ns = cont->runBudget_ns;
|
||||
PTime const runTimeMin_ns = runBudget_ns / 2;
|
||||
BMK_runTime_t bestRunTime = cont->fastestRun;
|
||||
|
||||
for (;;) {
|
||||
BMK_runOutcome_t const runResult = BMK_benchFunction(p, cont->nbLoops);
|
||||
|
||||
if (!BMK_isSuccessful_runOutcome(runResult)) { /* error : move out */
|
||||
return runResult;
|
||||
}
|
||||
|
||||
{ BMK_runTime_t const newRunTime = BMK_extract_runTime(runResult);
|
||||
double const loopDuration_ns = newRunTime.nanoSecPerRun * cont->nbLoops;
|
||||
|
||||
cont->timeSpent_ns += (unsigned long long)loopDuration_ns;
|
||||
|
||||
/* estimate nbLoops for next run to last approximately 1 second */
|
||||
if (loopDuration_ns > (runBudget_ns / 50)) {
|
||||
double const fastestRun_ns = MIN(bestRunTime.nanoSecPerRun, newRunTime.nanoSecPerRun);
|
||||
cont->nbLoops = (unsigned)(runBudget_ns / fastestRun_ns) + 1;
|
||||
} else {
|
||||
/* previous run was too short : blindly increase workload by x multiplier */
|
||||
const unsigned multiplier = 10;
|
||||
assert(cont->nbLoops < ((unsigned)-1) / multiplier); /* avoid overflow */
|
||||
cont->nbLoops *= multiplier;
|
||||
}
|
||||
|
||||
if (loopDuration_ns < runTimeMin_ns) {
|
||||
/* When benchmark run time is too small : don't report results.
|
||||
* increased risks of rounding errors */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (newRunTime.nanoSecPerRun < bestRunTime.nanoSecPerRun) {
|
||||
bestRunTime = newRunTime;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} /* while (!completed) */
|
||||
|
||||
return BMK_setValid_runTime(bestRunTime);
|
||||
}
|
183
deps/xxHash/tests/bench/benchfn.h
vendored
Normal file
183
deps/xxHash/tests/bench/benchfn.h
vendored
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2020 Yann Collet, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under both the BSD-style license (found in the
|
||||
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
* You may select, at your option, one of the above-listed licenses.
|
||||
*/
|
||||
|
||||
|
||||
/* benchfn :
|
||||
* benchmark any function on a set of input
|
||||
* providing result in nanoSecPerRun
|
||||
* or detecting and returning an error
|
||||
*/
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef BENCH_FN_H_23876
|
||||
#define BENCH_FN_H_23876
|
||||
|
||||
/* === Dependencies === */
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
|
||||
/* ==== Benchmark any function, iterated on a set of blocks ==== */
|
||||
|
||||
/* BMK_runTime_t: valid result return type */
|
||||
|
||||
typedef struct {
|
||||
double nanoSecPerRun; /* time per iteration (over all blocks) */
|
||||
size_t sumOfReturn; /* sum of return values */
|
||||
} BMK_runTime_t;
|
||||
|
||||
|
||||
/* BMK_runOutcome_t:
|
||||
* type expressing the outcome of a benchmark run by BMK_benchFunction(),
|
||||
* which can be either valid or invalid.
|
||||
* benchmark outcome can be invalid if errorFn is provided.
|
||||
* BMK_runOutcome_t must be considered "opaque" : never access its members directly.
|
||||
* Instead, use its assigned methods :
|
||||
* BMK_isSuccessful_runOutcome, BMK_extract_runTime, BMK_extract_errorResult.
|
||||
* The structure is only described here to allow its allocation on stack. */
|
||||
|
||||
typedef struct {
|
||||
BMK_runTime_t internal_never_ever_use_directly;
|
||||
size_t error_result_never_ever_use_directly;
|
||||
int error_tag_never_ever_use_directly;
|
||||
} BMK_runOutcome_t;
|
||||
|
||||
|
||||
/* prototypes for benchmarked functions */
|
||||
typedef size_t (*BMK_benchFn_t)(const void* src, size_t srcSize, void* dst, size_t dstCapacity, void* customPayload);
|
||||
typedef size_t (*BMK_initFn_t)(void* initPayload);
|
||||
typedef unsigned (*BMK_errorFn_t)(size_t);
|
||||
|
||||
|
||||
/* BMK_benchFunction() parameters are provided via the following structure.
|
||||
* A structure is preferable for readability,
|
||||
* as the number of parameters required is fairly large.
|
||||
* No initializer is provided, because it doesn't make sense to provide some "default" :
|
||||
* all parameters must be specified by the caller.
|
||||
* optional parameters are labelled explicitly, and accept value NULL when not used */
|
||||
typedef struct {
|
||||
BMK_benchFn_t benchFn; /* the function to benchmark, over the set of blocks */
|
||||
void* benchPayload; /* pass custom parameters to benchFn :
|
||||
* (*benchFn)(srcBuffers[i], srcSizes[i], dstBuffers[i], dstCapacities[i], benchPayload) */
|
||||
BMK_initFn_t initFn; /* (*initFn)(initPayload) is run once per run, at the beginning. */
|
||||
void* initPayload; /* Both arguments can be NULL, in which case nothing is run. */
|
||||
BMK_errorFn_t errorFn; /* errorFn will check each return value of benchFn over each block, to determine if it failed or not.
|
||||
* errorFn can be NULL, in which case no check is performed.
|
||||
* errorFn must return 0 when benchFn was successful, and >= 1 if it detects an error.
|
||||
* Execution is stopped as soon as an error is detected.
|
||||
* the triggering return value can be retrieved using BMK_extract_errorResult(). */
|
||||
size_t blockCount; /* number of blocks to operate benchFn on.
|
||||
* It's also the size of all array parameters :
|
||||
* srcBuffers, srcSizes, dstBuffers, dstCapacities, blockResults */
|
||||
const void *const * srcBuffers; /* read-only array of buffers to be operated on by benchFn */
|
||||
const size_t* srcSizes; /* read-only array containing sizes of srcBuffers */
|
||||
void *const * dstBuffers; /* array of buffers to be written into by benchFn. This array is not optional, it must be provided even if unused by benchfn. */
|
||||
const size_t* dstCapacities; /* read-only array containing capacities of dstBuffers. This array must be present. */
|
||||
size_t* blockResults; /* Optional: store the return value of benchFn for each block. Use NULL if this result is not requested. */
|
||||
} BMK_benchParams_t;
|
||||
|
||||
|
||||
/* BMK_benchFunction() :
|
||||
* This function benchmarks benchFn and initFn, providing a result.
|
||||
*
|
||||
* params : see description of BMK_benchParams_t above.
|
||||
* nbLoops: defines number of times benchFn is run over the full set of blocks.
|
||||
* Minimum value is 1. A 0 is interpreted as a 1.
|
||||
*
|
||||
* @return: can express either an error or a successful result.
|
||||
* Use BMK_isSuccessful_runOutcome() to check if benchmark was successful.
|
||||
* If yes, extract the result with BMK_extract_runTime(),
|
||||
* it will contain :
|
||||
* .sumOfReturn : the sum of all return values of benchFn through all of blocks
|
||||
* .nanoSecPerRun : time per run of benchFn + (time for initFn / nbLoops)
|
||||
* .sumOfReturn is generally intended for functions which return a # of bytes written into dstBuffer,
|
||||
* in which case, this value will be the total amount of bytes written into dstBuffer.
|
||||
*
|
||||
* blockResults : when provided (!= NULL), and when benchmark is successful,
|
||||
* params.blockResults contains all return values of `benchFn` over all blocks.
|
||||
* when provided (!= NULL), and when benchmark failed,
|
||||
* params.blockResults contains return values of `benchFn` over all blocks preceding and including the failed block.
|
||||
*/
|
||||
BMK_runOutcome_t BMK_benchFunction(BMK_benchParams_t params, unsigned nbLoops);
|
||||
|
||||
|
||||
|
||||
/* check first if the benchmark was successful or not */
|
||||
int BMK_isSuccessful_runOutcome(BMK_runOutcome_t outcome);
|
||||
|
||||
/* If the benchmark was successful, extract the result.
|
||||
* note : this function will abort() program execution if benchmark failed !
|
||||
* always check if benchmark was successful first !
|
||||
*/
|
||||
BMK_runTime_t BMK_extract_runTime(BMK_runOutcome_t outcome);
|
||||
|
||||
/* when benchmark failed, it means one invocation of `benchFn` failed.
|
||||
* The failure was detected by `errorFn`, operating on return values of `benchFn`.
|
||||
* Returns the faulty return value.
|
||||
* note : this function will abort() program execution if benchmark did not failed.
|
||||
* always check if benchmark failed first !
|
||||
*/
|
||||
size_t BMK_extract_errorResult(BMK_runOutcome_t outcome);
|
||||
|
||||
|
||||
|
||||
/* ==== Benchmark any function, returning intermediate results ==== */
|
||||
|
||||
/* state information tracking benchmark session */
|
||||
typedef struct BMK_timedFnState_s BMK_timedFnState_t;
|
||||
|
||||
/* BMK_benchTimedFn() :
|
||||
* Similar to BMK_benchFunction(), most arguments being identical.
|
||||
* Automatically determines `nbLoops` so that each result is regularly produced at interval of about run_ms.
|
||||
* Note : minimum `nbLoops` is 1, therefore a run may last more than run_ms, and possibly even more than total_ms.
|
||||
* Usage - initialize timedFnState, select benchmark duration (total_ms) and each measurement duration (run_ms)
|
||||
* call BMK_benchTimedFn() repetitively, each measurement is supposed to last about run_ms
|
||||
* Check if total time budget is spent or exceeded, using BMK_isCompleted_TimedFn()
|
||||
*/
|
||||
BMK_runOutcome_t BMK_benchTimedFn(BMK_timedFnState_t* timedFnState,
|
||||
BMK_benchParams_t params);
|
||||
|
||||
/* Tells if duration of all benchmark runs has exceeded total_ms
|
||||
*/
|
||||
int BMK_isCompleted_TimedFn(const BMK_timedFnState_t* timedFnState);
|
||||
|
||||
/* BMK_createTimedFnState() and BMK_resetTimedFnState() :
|
||||
* Create/Set BMK_timedFnState_t for next benchmark session,
|
||||
* which shall last a minimum of total_ms milliseconds,
|
||||
* producing intermediate results, paced at interval of (approximately) run_ms.
|
||||
*/
|
||||
BMK_timedFnState_t* BMK_createTimedFnState(unsigned total_ms, unsigned run_ms);
|
||||
void BMK_resetTimedFnState(BMK_timedFnState_t* timedFnState, unsigned total_ms, unsigned run_ms);
|
||||
void BMK_freeTimedFnState(BMK_timedFnState_t* state);
|
||||
|
||||
|
||||
/* BMK_timedFnState_shell and BMK_initStatic_timedFnState() :
|
||||
* Makes it possible to statically allocate a BMK_timedFnState_t on stack.
|
||||
* BMK_timedFnState_shell is only there to allocate space,
|
||||
* never ever access its members.
|
||||
* BMK_timedFnState_t() actually accepts any buffer.
|
||||
* It will check if provided buffer is large enough and is correctly aligned,
|
||||
* and will return NULL if conditions are not respected.
|
||||
*/
|
||||
#define BMK_TIMEDFNSTATE_SIZE 64
|
||||
typedef union {
|
||||
char never_access_space[BMK_TIMEDFNSTATE_SIZE];
|
||||
long long alignment_enforcer; /* must be aligned on 8-bytes boundaries */
|
||||
} BMK_timedFnState_shell;
|
||||
BMK_timedFnState_t* BMK_initStatic_timedFnState(void* buffer, size_t size, unsigned total_ms, unsigned run_ms);
|
||||
|
||||
|
||||
#endif /* BENCH_FN_H_23876 */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
159
deps/xxHash/tests/bench/bhDisplay.c
vendored
Normal file
159
deps/xxHash/tests/bench/bhDisplay.c
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
/*
|
||||
* CSV Display module for the hash benchmark program
|
||||
* Part of the xxHash project
|
||||
* Copyright (C) 2019-2020 Yann Collet
|
||||
*
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at :
|
||||
* - xxHash homepage : https://www.xxhash.com
|
||||
* - xxHash source repository : https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
|
||||
/* === Dependencies === */
|
||||
|
||||
#include <stdlib.h> /* rand */
|
||||
#include <stdio.h> /* printf */
|
||||
#include <assert.h>
|
||||
|
||||
#include "benchHash.h"
|
||||
#include "bhDisplay.h"
|
||||
|
||||
|
||||
/* === benchmark large input === */
|
||||
|
||||
#define MB_UNIT 1000000
|
||||
#define BENCH_LARGE_ITER_MS 490
|
||||
#define BENCH_LARGE_TOTAL_MS 1010
|
||||
static void bench_oneHash_largeInput(Bench_Entry hashDesc, int minlog, int maxlog)
|
||||
{
|
||||
printf("%-7s", hashDesc.name);
|
||||
for (int sizelog=minlog; sizelog<=maxlog; sizelog++) {
|
||||
size_t const inputSize = (size_t)1 << sizelog;
|
||||
double const nbhps = bench_hash(hashDesc.hash, BMK_throughput,
|
||||
inputSize, BMK_fixedSize,
|
||||
BENCH_LARGE_TOTAL_MS, BENCH_LARGE_ITER_MS);
|
||||
printf(",%6.0f", nbhps * inputSize / MB_UNIT); fflush(NULL);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void bench_largeInput(Bench_Entry const* hashDescTable, int nbHashes, int minlog, int maxlog)
|
||||
{
|
||||
assert(maxlog < 31);
|
||||
assert(minlog >= 0);
|
||||
printf("benchmarking large inputs : from %u bytes (log%i) to %u MB (log%i) \n",
|
||||
1U << minlog, minlog,
|
||||
(1U << maxlog) >> 20, maxlog);
|
||||
for (int i=0; i<nbHashes; i++)
|
||||
bench_oneHash_largeInput(hashDescTable[i], minlog, maxlog);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* === Benchmark small inputs === */
|
||||
|
||||
#define BENCH_SMALL_ITER_MS 170
|
||||
#define BENCH_SMALL_TOTAL_MS 490
|
||||
static void bench_throughput_oneHash_smallInputs(Bench_Entry hashDesc, size_t sizeMin, size_t sizeMax)
|
||||
{
|
||||
printf("%-7s", hashDesc.name);
|
||||
for (size_t s=sizeMin; s<sizeMax+1; s++) {
|
||||
double const nbhps = bench_hash(hashDesc.hash, BMK_throughput,
|
||||
s, BMK_fixedSize,
|
||||
BENCH_SMALL_TOTAL_MS, BENCH_SMALL_ITER_MS);
|
||||
printf(",%10.0f", nbhps); fflush(NULL);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void bench_throughput_smallInputs(Bench_Entry const* hashDescTable, int nbHashes, size_t sizeMin, size_t sizeMax)
|
||||
{
|
||||
printf("Throughput small inputs of fixed size : \n");
|
||||
for (int i=0; i<nbHashes; i++)
|
||||
bench_throughput_oneHash_smallInputs(hashDescTable[i], sizeMin, sizeMax);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* === Latency measurements (small keys) === */
|
||||
|
||||
static void bench_latency_oneHash_smallInputs(Bench_Entry hashDesc, size_t size_min, size_t size_max)
|
||||
{
|
||||
printf("%-7s", hashDesc.name);
|
||||
for (size_t s=size_min; s<size_max+1; s++) {
|
||||
double const nbhps = bench_hash(hashDesc.hash, BMK_latency,
|
||||
s, BMK_fixedSize,
|
||||
BENCH_SMALL_TOTAL_MS, BENCH_SMALL_ITER_MS);
|
||||
printf(",%10.0f", nbhps); fflush(NULL);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void bench_latency_smallInputs(Bench_Entry const* hashDescTable, int nbHashes, size_t size_min, size_t size_max)
|
||||
{
|
||||
printf("Latency for small inputs of fixed size : \n");
|
||||
for (int i=0; i<nbHashes; i++)
|
||||
bench_latency_oneHash_smallInputs(hashDescTable[i], size_min, size_max);
|
||||
}
|
||||
|
||||
|
||||
/* === Random input Length === */
|
||||
|
||||
static void bench_randomInputLength_withOneHash(Bench_Entry hashDesc, size_t size_min, size_t size_max)
|
||||
{
|
||||
printf("%-7s", hashDesc.name);
|
||||
for (size_t s=size_min; s<size_max+1; s++) {
|
||||
srand((unsigned)s); /* ensure random sequence of length will be the same for a given s */
|
||||
double const nbhps = bench_hash(hashDesc.hash, BMK_throughput,
|
||||
s, BMK_randomSize,
|
||||
BENCH_SMALL_TOTAL_MS, BENCH_SMALL_ITER_MS);
|
||||
printf(",%10.0f", nbhps); fflush(NULL);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void bench_throughput_randomInputLength(Bench_Entry const* hashDescTable, int nbHashes, size_t size_min, size_t size_max)
|
||||
{
|
||||
printf("benchmarking random size inputs [1-N] : \n");
|
||||
for (int i=0; i<nbHashes; i++)
|
||||
bench_randomInputLength_withOneHash(hashDescTable[i], size_min, size_max);
|
||||
}
|
||||
|
||||
|
||||
/* === Latency with Random input Length === */
|
||||
|
||||
static void bench_latency_oneHash_randomInputLength(Bench_Entry hashDesc, size_t size_min, size_t size_max)
|
||||
{
|
||||
printf("%-7s", hashDesc.name);
|
||||
for (size_t s=size_min; s<size_max+1; s++) {
|
||||
srand((unsigned)s); /* ensure random sequence of length will be the same for a given s */
|
||||
double const nbhps = bench_hash(hashDesc.hash, BMK_latency,
|
||||
s, BMK_randomSize,
|
||||
BENCH_SMALL_TOTAL_MS, BENCH_SMALL_ITER_MS);
|
||||
printf(",%10.0f", nbhps); fflush(NULL);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void bench_latency_randomInputLength(Bench_Entry const* hashDescTable, int nbHashes, size_t size_min, size_t size_max)
|
||||
{
|
||||
printf("Latency for small inputs of random size [1-N] : \n");
|
||||
for (int i=0; i<nbHashes; i++)
|
||||
bench_latency_oneHash_randomInputLength(hashDescTable[i], size_min, size_max);
|
||||
}
|
61
deps/xxHash/tests/bench/bhDisplay.h
vendored
Normal file
61
deps/xxHash/tests/bench/bhDisplay.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* CSV Display module for the hash benchmark program
|
||||
* Part of the xxHash project
|
||||
* Copyright (C) 2019-2020 Yann Collet
|
||||
*
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
#ifndef BH_DISPLAY_H_192088098
|
||||
#define BH_DISPLAY_H_192088098
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* === Dependencies === */
|
||||
|
||||
#include "benchfn.h" /* BMK_benchFn_t */
|
||||
|
||||
|
||||
/* === Declarations === */
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
BMK_benchFn_t hash;
|
||||
} Bench_Entry;
|
||||
|
||||
void bench_largeInput(Bench_Entry const* hashDescTable, int nbHashes, int sizeLogMin, int sizeLogMax);
|
||||
|
||||
void bench_throughput_smallInputs(Bench_Entry const* hashDescTable, int nbHashes, size_t sizeMin, size_t sizeMax);
|
||||
void bench_throughput_randomInputLength(Bench_Entry const* hashDescTable, int nbHashes, size_t sizeMin, size_t sizeMax);
|
||||
|
||||
void bench_latency_smallInputs(Bench_Entry const* hashDescTable, int nbHashes, size_t sizeMin, size_t sizeMax);
|
||||
void bench_latency_randomInputLength(Bench_Entry const* hashDescTable, int nbHashes, size_t sizeMin, size_t sizeMax);
|
||||
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BH_DISPLAY_H_192088098 */
|
118
deps/xxHash/tests/bench/hashes.h
vendored
Normal file
118
deps/xxHash/tests/bench/hashes.h
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* List hash algorithms to benchmark
|
||||
* Part of xxHash project
|
||||
* Copyright (C) 2019-2020 Yann Collet
|
||||
*
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
|
||||
/* === Dependencies === */
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
|
||||
/* ==================================================
|
||||
* Non-portable hash algorithms
|
||||
* =============================================== */
|
||||
|
||||
|
||||
#ifdef HARDWARE_SUPPORT
|
||||
|
||||
/*
|
||||
* List any hash algorithms that depend on specific hardware support,
|
||||
* including for example:
|
||||
* - Hardware crc32c
|
||||
* - Hardware AES support
|
||||
* - Carryless Multipliers (clmul)
|
||||
* - AVX2
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* ==================================================
|
||||
* List of hashes
|
||||
* ==================================================
|
||||
* Each hash must be wrapped in a thin redirector conformant with the BMK_benchfn_t.
|
||||
* BMK_benchfn_t is generic, not specifically designed for hashes.
|
||||
* For hashes, the following parameters are expected to be useless:
|
||||
* dst, dstCapacity, customPayload.
|
||||
*
|
||||
* The result of each hash is assumed to be provided as function return value.
|
||||
* This condition is important for latency measurements.
|
||||
*/
|
||||
|
||||
/* === xxHash === */
|
||||
#define XXH_INLINE_ALL
|
||||
#include "xxhash.h"
|
||||
|
||||
size_t XXH32_wrapper(const void* src, size_t srcSize, void* dst, size_t dstCapacity, void* customPayload)
|
||||
{
|
||||
(void)dst; (void)dstCapacity; (void)customPayload;
|
||||
return (size_t) XXH32(src, srcSize, 0);
|
||||
}
|
||||
|
||||
|
||||
size_t XXH64_wrapper(const void* src, size_t srcSize, void* dst, size_t dstCapacity, void* customPayload)
|
||||
{
|
||||
(void)dst; (void)dstCapacity; (void)customPayload;
|
||||
return (size_t) XXH64(src, srcSize, 0);
|
||||
}
|
||||
|
||||
|
||||
size_t xxh3_wrapper(const void* src, size_t srcSize, void* dst, size_t dstCapacity, void* customPayload)
|
||||
{
|
||||
(void)dst; (void)dstCapacity; (void)customPayload;
|
||||
return (size_t) XXH3_64bits(src, srcSize);
|
||||
}
|
||||
|
||||
|
||||
size_t XXH128_wrapper(const void* src, size_t srcSize, void* dst, size_t dstCapacity, void* customPayload)
|
||||
{
|
||||
(void)dst; (void)dstCapacity; (void)customPayload;
|
||||
return (size_t) XXH3_128bits(src, srcSize).low64;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ==================================================
|
||||
* Table of hashes
|
||||
* =============================================== */
|
||||
|
||||
#include "bhDisplay.h" /* Bench_Entry */
|
||||
|
||||
#ifndef HARDWARE_SUPPORT
|
||||
# define NB_HASHES 4
|
||||
#else
|
||||
# define NB_HASHES 4
|
||||
#endif
|
||||
|
||||
Bench_Entry const hashCandidates[NB_HASHES] = {
|
||||
{ "xxh3" , xxh3_wrapper },
|
||||
{ "XXH32" , XXH32_wrapper },
|
||||
{ "XXH64" , XXH64_wrapper },
|
||||
{ "XXH128", XXH128_wrapper },
|
||||
#ifdef HARDWARE_SUPPORT
|
||||
/* list here codecs which require specific hardware support, such SSE4.1, PCLMUL, AVX2, etc. */
|
||||
#endif
|
||||
};
|
220
deps/xxHash/tests/bench/main.c
vendored
Normal file
220
deps/xxHash/tests/bench/main.c
vendored
Normal file
@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Main program to benchmark hash functions
|
||||
* Part of the xxHash project
|
||||
* Copyright (C) 2019-2020 Yann Collet
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
|
||||
/* === dependencies === */
|
||||
|
||||
#include <stdio.h> /* printf */
|
||||
#include <limits.h> /* INT_MAX */
|
||||
#include "bhDisplay.h" /* bench_x */
|
||||
|
||||
|
||||
/* === defines list of hashes `hashCandidates` and NB_HASHES *** */
|
||||
|
||||
#include "hashes.h"
|
||||
|
||||
|
||||
/* === parse command line === */
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
/*!
|
||||
* readIntFromChar():
|
||||
* Allows and interprets K, KB, KiB, M, MB and MiB suffix.
|
||||
* Will also modify `*stringPtr`, advancing it to position where it stopped reading.
|
||||
*/
|
||||
static int readIntFromChar(const char** stringPtr)
|
||||
{
|
||||
static int const max = (INT_MAX / 10) - 1;
|
||||
int result = 0;
|
||||
while ((**stringPtr >='0') && (**stringPtr <='9')) {
|
||||
assert(result < max);
|
||||
result *= 10;
|
||||
result += (unsigned)(**stringPtr - '0');
|
||||
(*stringPtr)++ ;
|
||||
}
|
||||
if ((**stringPtr=='K') || (**stringPtr=='M')) {
|
||||
int const maxK = INT_MAX >> 10;
|
||||
assert(result < maxK);
|
||||
result <<= 10;
|
||||
if (**stringPtr=='M') {
|
||||
assert(result < maxK);
|
||||
result <<= 10;
|
||||
}
|
||||
(*stringPtr)++; /* skip `K` or `M` */
|
||||
if (**stringPtr=='i') (*stringPtr)++;
|
||||
if (**stringPtr=='B') (*stringPtr)++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* longCommand():
|
||||
* Checks if string is the same as longCommand.
|
||||
* If yes, @return 1, otherwise @return 0
|
||||
*/
|
||||
static int isCommand(const char* string, const char* longCommand)
|
||||
{
|
||||
assert(string);
|
||||
assert(longCommand);
|
||||
size_t const comSize = strlen(longCommand);
|
||||
return !strncmp(string, longCommand, comSize);
|
||||
}
|
||||
|
||||
/*
|
||||
* longCommandWArg():
|
||||
* Checks if *stringPtr is the same as longCommand.
|
||||
* If yes, @return 1 and advances *stringPtr to the position which immediately
|
||||
* follows longCommand.
|
||||
* @return 0 and doesn't modify *stringPtr otherwise.
|
||||
*/
|
||||
static int longCommandWArg(const char** stringPtr, const char* longCommand)
|
||||
{
|
||||
assert(stringPtr);
|
||||
assert(longCommand);
|
||||
size_t const comSize = strlen(longCommand);
|
||||
int const result = isCommand(*stringPtr, longCommand);
|
||||
if (result) *stringPtr += comSize;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* === default values - can be redefined at compilation time === */
|
||||
|
||||
#ifndef SMALL_SIZE_MIN_DEFAULT
|
||||
# define SMALL_SIZE_MIN_DEFAULT 1
|
||||
#endif
|
||||
#ifndef SMALL_SIZE_MAX_DEFAULT
|
||||
# define SMALL_SIZE_MAX_DEFAULT 127
|
||||
#endif
|
||||
#ifndef LARGE_SIZELOG_MIN_DEFAULT
|
||||
# define LARGE_SIZELOG_MIN_DEFAULT 9
|
||||
#endif
|
||||
#ifndef LARGE_SIZELOG_MAX_DEFAULT
|
||||
# define LARGE_SIZELOG_MAX_DEFAULT 27
|
||||
#endif
|
||||
|
||||
|
||||
static int display_hash_names(void)
|
||||
{
|
||||
int i;
|
||||
printf("available hashes : \n");
|
||||
for (i=0; i<NB_HASHES; i++) {
|
||||
printf("%s, ", hashCandidates[i].name);
|
||||
}
|
||||
printf("\b\b \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @return: hashID (necessarily between 0 and NB_HASHES) if present
|
||||
* -1 on error (hname not present)
|
||||
*/
|
||||
static int hashID(const char* hname)
|
||||
{
|
||||
int id;
|
||||
assert(hname);
|
||||
for (id=0; id < NB_HASHES; id++) {
|
||||
assert(hashCandidates[id].name);
|
||||
if (strlen(hname) != strlen(hashCandidates[id].name)) continue;
|
||||
if (isCommand(hname, hashCandidates[id].name)) return id;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int help(const char* exename)
|
||||
{
|
||||
printf("Usage: %s [options]... [hash]\n", exename);
|
||||
printf("Runs various benchmarks at various lengths for the listed hash functions\n");
|
||||
printf("and outputs them in a CSV format.\n\n");
|
||||
printf("Options: \n");
|
||||
printf(" --list Name available hash algorithms and exit \n");
|
||||
printf(" --mins=LEN Starting length for small size bench (default: %i) \n", SMALL_SIZE_MIN_DEFAULT);
|
||||
printf(" --maxs=LEN End length for small size bench (default: %i) \n", SMALL_SIZE_MAX_DEFAULT);
|
||||
printf(" --minl=LEN Starting log2(length) for large size bench (default: %i) \n", LARGE_SIZELOG_MIN_DEFAULT);
|
||||
printf(" --maxl=LEN End log2(length) for large size bench (default: %i) \n", LARGE_SIZELOG_MAX_DEFAULT);
|
||||
printf(" [hash] Optional, bench all available hashes if not provided \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int badusage(const char* exename)
|
||||
{
|
||||
printf("Bad command ... \n");
|
||||
help(exename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
const char* const exename = argv[0];
|
||||
int hashNb = 0;
|
||||
int nb_h_test = NB_HASHES;
|
||||
int largeTest_log_min = LARGE_SIZELOG_MIN_DEFAULT;
|
||||
int largeTest_log_max = LARGE_SIZELOG_MAX_DEFAULT;
|
||||
size_t smallTest_size_min = SMALL_SIZE_MIN_DEFAULT;
|
||||
size_t smallTest_size_max = SMALL_SIZE_MAX_DEFAULT;
|
||||
|
||||
int arg_nb;
|
||||
for (arg_nb = 1; arg_nb < argc; arg_nb++) {
|
||||
const char** arg = argv + arg_nb;
|
||||
if (isCommand(*arg, "-h")) { assert(argc >= 1); return help(exename); }
|
||||
if (isCommand(*arg, "--list")) { return display_hash_names(); }
|
||||
if (longCommandWArg(arg, "--n=")) { nb_h_test = readIntFromChar(arg); continue; } /* hidden command */
|
||||
if (longCommandWArg(arg, "--minl=")) { largeTest_log_min = readIntFromChar(arg); continue; }
|
||||
if (longCommandWArg(arg, "--maxl=")) { largeTest_log_max = readIntFromChar(arg); continue; }
|
||||
if (longCommandWArg(arg, "--mins=")) { smallTest_size_min = (size_t)readIntFromChar(arg); continue; }
|
||||
if (longCommandWArg(arg, "--maxs=")) { smallTest_size_max = (size_t)readIntFromChar(arg); continue; }
|
||||
/* not a command: must be a hash name */
|
||||
hashNb = hashID(*arg);
|
||||
if (hashNb >= 0) {
|
||||
nb_h_test = 1;
|
||||
} else {
|
||||
/* not a hash name: error */
|
||||
return badusage(exename);
|
||||
}
|
||||
}
|
||||
|
||||
/* border case (requires (mis)using hidden command `--n=#`) */
|
||||
if (hashNb + nb_h_test > NB_HASHES) {
|
||||
printf("wrong hash selection \n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf(" === benchmarking %i hash functions === \n", nb_h_test);
|
||||
if (largeTest_log_max >= largeTest_log_min) {
|
||||
bench_largeInput(hashCandidates+hashNb, nb_h_test, largeTest_log_min, largeTest_log_max);
|
||||
}
|
||||
if (smallTest_size_max >= smallTest_size_min) {
|
||||
bench_throughput_smallInputs(hashCandidates+hashNb, nb_h_test, smallTest_size_min, smallTest_size_max);
|
||||
bench_throughput_randomInputLength(hashCandidates+hashNb, nb_h_test, smallTest_size_min, smallTest_size_max);
|
||||
bench_latency_smallInputs(hashCandidates+hashNb, nb_h_test, smallTest_size_min, smallTest_size_max);
|
||||
bench_latency_randomInputLength(hashCandidates+hashNb, nb_h_test, smallTest_size_min, smallTest_size_max);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
168
deps/xxHash/tests/bench/timefn.c
vendored
Normal file
168
deps/xxHash/tests/bench/timefn.c
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Yann Collet, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under both the BSD-style license (found in the
|
||||
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
* You may select, at your option, one of the above-listed licenses.
|
||||
*/
|
||||
|
||||
|
||||
/* === Dependencies === */
|
||||
|
||||
#include "timefn.h"
|
||||
|
||||
|
||||
/*-****************************************
|
||||
* Time functions
|
||||
******************************************/
|
||||
|
||||
#if defined(_WIN32) /* Windows */
|
||||
|
||||
#include <stdlib.h> /* abort */
|
||||
#include <stdio.h> /* perror */
|
||||
|
||||
UTIL_time_t UTIL_getTime(void) { UTIL_time_t x; QueryPerformanceCounter(&x); return x; }
|
||||
|
||||
PTime UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd)
|
||||
{
|
||||
static LARGE_INTEGER ticksPerSecond;
|
||||
static int init = 0;
|
||||
if (!init) {
|
||||
if (!QueryPerformanceFrequency(&ticksPerSecond)) {
|
||||
perror("timefn::QueryPerformanceFrequency");
|
||||
abort();
|
||||
}
|
||||
init = 1;
|
||||
}
|
||||
return 1000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart;
|
||||
}
|
||||
|
||||
PTime UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd)
|
||||
{
|
||||
static LARGE_INTEGER ticksPerSecond;
|
||||
static int init = 0;
|
||||
if (!init) {
|
||||
if (!QueryPerformanceFrequency(&ticksPerSecond)) {
|
||||
perror("timefn::QueryPerformanceFrequency");
|
||||
abort();
|
||||
}
|
||||
init = 1;
|
||||
}
|
||||
return 1000000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
|
||||
UTIL_time_t UTIL_getTime(void) { return mach_absolute_time(); }
|
||||
|
||||
PTime UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd)
|
||||
{
|
||||
static mach_timebase_info_data_t rate;
|
||||
static int init = 0;
|
||||
if (!init) {
|
||||
mach_timebase_info(&rate);
|
||||
init = 1;
|
||||
}
|
||||
return (((clockEnd - clockStart) * (PTime)rate.numer) / ((PTime)rate.denom))/1000ULL;
|
||||
}
|
||||
|
||||
PTime UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd)
|
||||
{
|
||||
static mach_timebase_info_data_t rate;
|
||||
static int init = 0;
|
||||
if (!init) {
|
||||
mach_timebase_info(&rate);
|
||||
init = 1;
|
||||
}
|
||||
return ((clockEnd - clockStart) * (PTime)rate.numer) / ((PTime)rate.denom);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#elif (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */) \
|
||||
&& defined(TIME_UTC) /* C11 requires timespec_get, but FreeBSD 11 lacks it, while still claiming C11 compliance */
|
||||
|
||||
#include <stdlib.h> /* abort */
|
||||
#include <stdio.h> /* perror */
|
||||
|
||||
UTIL_time_t UTIL_getTime(void)
|
||||
{
|
||||
/* time must be initialized, othersize it may fail msan test.
|
||||
* No good reason, likely a limitation of timespec_get() for some target */
|
||||
UTIL_time_t time = UTIL_TIME_INITIALIZER;
|
||||
if (timespec_get(&time, TIME_UTC) != TIME_UTC) {
|
||||
perror("timefn::timespec_get");
|
||||
abort();
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
static UTIL_time_t UTIL_getSpanTime(UTIL_time_t begin, UTIL_time_t end)
|
||||
{
|
||||
UTIL_time_t diff;
|
||||
if (end.tv_nsec < begin.tv_nsec) {
|
||||
diff.tv_sec = (end.tv_sec - 1) - begin.tv_sec;
|
||||
diff.tv_nsec = (end.tv_nsec + 1000000000ULL) - begin.tv_nsec;
|
||||
} else {
|
||||
diff.tv_sec = end.tv_sec - begin.tv_sec;
|
||||
diff.tv_nsec = end.tv_nsec - begin.tv_nsec;
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
|
||||
PTime UTIL_getSpanTimeMicro(UTIL_time_t begin, UTIL_time_t end)
|
||||
{
|
||||
UTIL_time_t const diff = UTIL_getSpanTime(begin, end);
|
||||
PTime micro = 0;
|
||||
micro += 1000000ULL * diff.tv_sec;
|
||||
micro += diff.tv_nsec / 1000ULL;
|
||||
return micro;
|
||||
}
|
||||
|
||||
PTime UTIL_getSpanTimeNano(UTIL_time_t begin, UTIL_time_t end)
|
||||
{
|
||||
UTIL_time_t const diff = UTIL_getSpanTime(begin, end);
|
||||
PTime nano = 0;
|
||||
nano += 1000000000ULL * diff.tv_sec;
|
||||
nano += diff.tv_nsec;
|
||||
return nano;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else /* relies on standard C90 (note : clock_t measurements can be wrong when using multi-threading) */
|
||||
|
||||
UTIL_time_t UTIL_getTime(void) { return clock(); }
|
||||
PTime UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC; }
|
||||
PTime UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC; }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* returns time span in microseconds */
|
||||
PTime UTIL_clockSpanMicro(UTIL_time_t clockStart )
|
||||
{
|
||||
UTIL_time_t const clockEnd = UTIL_getTime();
|
||||
return UTIL_getSpanTimeMicro(clockStart, clockEnd);
|
||||
}
|
||||
|
||||
/* returns time span in microseconds */
|
||||
PTime UTIL_clockSpanNano(UTIL_time_t clockStart )
|
||||
{
|
||||
UTIL_time_t const clockEnd = UTIL_getTime();
|
||||
return UTIL_getSpanTimeNano(clockStart, clockEnd);
|
||||
}
|
||||
|
||||
void UTIL_waitForNextTick(void)
|
||||
{
|
||||
UTIL_time_t const clockStart = UTIL_getTime();
|
||||
UTIL_time_t clockEnd;
|
||||
do {
|
||||
clockEnd = UTIL_getTime();
|
||||
} while (UTIL_getSpanTimeNano(clockStart, clockEnd) == 0);
|
||||
}
|
89
deps/xxHash/tests/bench/timefn.h
vendored
Normal file
89
deps/xxHash/tests/bench/timefn.h
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2020 Yann Collet, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under both the BSD-style license (found in the
|
||||
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
* You may select, at your option, one of the above-listed licenses.
|
||||
*/
|
||||
|
||||
#ifndef TIME_FN_H_MODULE_287987
|
||||
#define TIME_FN_H_MODULE_287987
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*-****************************************
|
||||
* Dependencies
|
||||
******************************************/
|
||||
#include <sys/types.h> /* utime */
|
||||
#if defined(_MSC_VER)
|
||||
# include <sys/utime.h> /* utime */
|
||||
#else
|
||||
# include <utime.h> /* utime */
|
||||
#endif
|
||||
#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
|
||||
|
||||
|
||||
|
||||
/*-****************************************
|
||||
* Local Types
|
||||
******************************************/
|
||||
|
||||
#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
|
||||
# include <stdint.h>
|
||||
typedef uint64_t PTime; /* Precise Time */
|
||||
#else
|
||||
typedef unsigned long long PTime; /* does not support compilers without long long support */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*-****************************************
|
||||
* Time functions
|
||||
******************************************/
|
||||
#if defined(_WIN32) /* Windows */
|
||||
|
||||
#include <Windows.h> /* LARGE_INTEGER */
|
||||
typedef LARGE_INTEGER UTIL_time_t;
|
||||
#define UTIL_TIME_INITIALIZER { { 0, 0 } }
|
||||
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
|
||||
#include <mach/mach_time.h>
|
||||
typedef PTime UTIL_time_t;
|
||||
#define UTIL_TIME_INITIALIZER 0
|
||||
|
||||
#elif (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */) \
|
||||
&& defined(TIME_UTC) /* C11 requires timespec_get, but FreeBSD 11 lacks it, while still claiming C11 compliance */
|
||||
|
||||
typedef struct timespec UTIL_time_t;
|
||||
#define UTIL_TIME_INITIALIZER { 0, 0 }
|
||||
|
||||
#else /* relies on standard C90 (note : clock_t measurements can be wrong when using multi-threading) */
|
||||
|
||||
typedef clock_t UTIL_time_t;
|
||||
#define UTIL_TIME_INITIALIZER 0
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
UTIL_time_t UTIL_getTime(void);
|
||||
PTime UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd);
|
||||
PTime UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd);
|
||||
|
||||
#define SEC_TO_MICRO ((PTime)1000000)
|
||||
PTime UTIL_clockSpanMicro(UTIL_time_t clockStart);
|
||||
PTime UTIL_clockSpanNano(UTIL_time_t clockStart);
|
||||
|
||||
void UTIL_waitForNextTick(void);
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TIME_FN_H_MODULE_287987 */
|
2
deps/xxHash/tests/collisions/.gitignore
vendored
Normal file
2
deps/xxHash/tests/collisions/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
#build artefacts
|
||||
collisionsTest
|
339
deps/xxHash/tests/collisions/LICENSE
vendored
Normal file
339
deps/xxHash/tests/collisions/LICENSE
vendored
Normal file
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
74
deps/xxHash/tests/collisions/Makefile
vendored
Normal file
74
deps/xxHash/tests/collisions/Makefile
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
# Brute force collision tester for 64-bit hashes
|
||||
# Part of xxHash project
|
||||
# Copyright (C) 2019-2020 Yann Collet
|
||||
#
|
||||
# GPL v2 License
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# You can contact the author at:
|
||||
# - xxHash homepage: https://www.xxhash.com
|
||||
# - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
#
|
||||
|
||||
SRC_DIRS = ./ ../../ allcodecs/
|
||||
VPATH = $(SRC_DIRS)
|
||||
CPPFLAGS += $(addprefix -I ,$(SRC_DIRS))
|
||||
CFLAGS ?= -std=c99 \
|
||||
-Wall -Wextra -Wconversion
|
||||
CXXFLAGS ?= -Wall -Wextra -Wconversion -std=c++11
|
||||
LDFLAGS += -pthread
|
||||
TESTHASHES = 110000000
|
||||
|
||||
HASH_SRC := $(sort $(wildcard allcodecs/*.c allcodecs/*.cc))
|
||||
HASH_OBJ := $(patsubst %.c,%.o,$(HASH_SRC))
|
||||
|
||||
|
||||
.PHONY: default
|
||||
default: release
|
||||
|
||||
.PHONY: all
|
||||
all: release
|
||||
|
||||
collisionsTest: main.o pool.o threading.o sort.o $(HASH_OBJ)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
|
||||
|
||||
main.o: hashes.h xxhash.h
|
||||
|
||||
release: CXXFLAGS += -O3
|
||||
release: CFLAGS += -O3
|
||||
release: collisionsTest
|
||||
|
||||
debug: CXXFLAGS += -g3 -O0 -DDEBUG
|
||||
debug: CFLAGS += -g3 -O0 -DDEBUG
|
||||
debug: collisionsTest
|
||||
|
||||
.PHONY: check
|
||||
check: test
|
||||
|
||||
.PHONY: test
|
||||
test: debug
|
||||
@echo ""
|
||||
@echo "## $(TESTHASHES) hashes with original and 0 threads"
|
||||
@time ./collisionsTest --nbh=$(TESTHASHES)
|
||||
@echo ""
|
||||
@echo "## $(TESTHASHES) hashes with original and 4 threads"
|
||||
@time ./collisionsTest --nbh=$(TESTHASHES) --threadlog=2
|
||||
@echo ""
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) *.o allcodecs/*.o
|
||||
$(RM) collisionsTest
|
122
deps/xxHash/tests/collisions/README.md
vendored
Normal file
122
deps/xxHash/tests/collisions/README.md
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
|
||||
__collisionsTest__ is a brute force hash analyzer
|
||||
which will measure a 64-bit hash algorithm's collision rate
|
||||
by generating billions of hashes,
|
||||
and comparing the result to an "ideal" target.
|
||||
|
||||
The test requires a very large amount of memory.
|
||||
By default, it will generate 24 billion of 64-bit hashes,
|
||||
requiring __192 GB of RAM__ for their storage.
|
||||
The number of hashes can be modified using command `--nbh=`.
|
||||
Be aware that testing the collision ratio of 64-bit hashes
|
||||
requires a very large amount of hashes (several billion) for meaningful measurements.
|
||||
|
||||
To reduce RAM usage, an optional filter can be requested, with `--filter`.
|
||||
It reduces the nb of candidates to analyze, hence associated RAM budget.
|
||||
Note that the filter itself requires a lot of RAM
|
||||
(32 GB by default, can be modified using `--filterlog=`,
|
||||
a too small filter will not be efficient, aim at ~2 bytes per hash),
|
||||
and reading and writing into filter cost a significant CPU budget,
|
||||
so this method is slower.
|
||||
It also doesn't allow advanced analysis of partial bitfields,
|
||||
since most hashes will be discarded and not stored.
|
||||
|
||||
When using the filter, the RAM budget consists of the filter and a list of candidates,
|
||||
which will be a fraction of the original hash list.
|
||||
Using default settings (24 billion hashes, 32 GB filter),
|
||||
the number of potential candidates should be reduced to less than 2 billion,
|
||||
requiring ~14 GB for their storage.
|
||||
Such a result also depends on hash algorithm's efficiency.
|
||||
The number of effective candidates is likely to be lower, at ~ 1 billion,
|
||||
but storage must allocate an upper bound.
|
||||
|
||||
For the default test, the expected "optimal" collision rate for a 64-bit hash function is ~18 collisions.
|
||||
|
||||
#### How to build
|
||||
```
|
||||
make
|
||||
```
|
||||
|
||||
Note: the code is a mix of C99 and C++14,
|
||||
it's not compatible with a C90-only compiler.
|
||||
|
||||
#### Build modifier
|
||||
|
||||
- `SLAB5`: use alternative pattern generator, friendlier for weak hash algorithms
|
||||
- `POOL_MT`: if `=0`, disable multi-threading code (enabled by default)
|
||||
|
||||
#### How to integrate any hash in the tester
|
||||
|
||||
The build script will compile files found in `./allcodecs`.
|
||||
Put the source code here.
|
||||
This also works if the hash is a single `*.h` file.
|
||||
|
||||
The glue happens in `hashes.h`.
|
||||
In this file, there are 2 sections:
|
||||
- Adds the required `#include "header.h"`, and creates a wrapper
|
||||
to respect the format expected by the function pointer.
|
||||
- Adds the wrapper, along with the name and an indication of the output width,
|
||||
to the table, at the end of `hashes.h`
|
||||
|
||||
Build with `make`. Locate your new hash with `./collisionsTest -h`,
|
||||
it should be listed.
|
||||
|
||||
|
||||
#### Usage
|
||||
|
||||
```
|
||||
usage: ./collisionsTest [hashName] [opt]
|
||||
|
||||
list of hashNames: (...)
|
||||
|
||||
Optional parameters:
|
||||
--nbh=NB Select nb of hashes to generate (25769803776 by default)
|
||||
--filter Enable the filter. Slower, but reduces memory usage for same nb of hashes.
|
||||
--threadlog=NB Use 2^NB threads
|
||||
--len=NB Select length of input (255 bytes by default)
|
||||
```
|
||||
|
||||
#### Some advises on how to setup a collisions test
|
||||
|
||||
Most tests are primarily driven by the amount of RAM available.
|
||||
Here's a method to decide the size of the test.
|
||||
|
||||
Presuming that RAM budget is not plentiful, for this example 32 GB,
|
||||
the `--filter` mode is actually compulsory to measure anything meaningful.
|
||||
Let's plan 50% of memory for the filter, that's 16 GB.
|
||||
This will be good enough to filter about 10% less hashes than this size.
|
||||
Let's round down to 14 G.
|
||||
|
||||
By requesting 14G, the expectation is that the program will automatically
|
||||
size the filter to 16 GB, and expect to store ~1G candidates,
|
||||
leaving enough room to breeze for the system.
|
||||
|
||||
The command line becomes:
|
||||
```
|
||||
./collisionsTest --nbh=14G --filter NameOfHash
|
||||
```
|
||||
|
||||
#### Examples:
|
||||
|
||||
Here are a few results produced with this tester:
|
||||
|
||||
| Algorithm | Input Len | Nb Hashes | Expected | Nb Collisions | Notes |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| __XXH3__ | 255 | 100 Gi | 312.5 | 326 | |
|
||||
| __XXH64__ | 255 | 100 Gi | 312.5 | 294 | |
|
||||
| __XXH128__ low64 | 512 | 100 Gi | 312.5 | 321 | |
|
||||
| __XXH128__ high64| 512 | 100 Gi | 312.5 | 325 | |
|
||||
| __XXH128__ | 255 | 100 Gi | 0.0 | 0 | a 128-bit hash is expected to generate 0 collisions |
|
||||
|
||||
Test on small inputs:
|
||||
|
||||
| Algorithm | Input Len | Nb Hashes | Expected | Nb Collisions | Notes |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| __XXH64__ | 8 | 100 Gi | 312.5 | __0__ | `XXH64` is bijective for `len==8` |
|
||||
| __XXH3__ | 8 | 100 Gi | 312.5 | __0__ | `XXH3` is also bijective for `len==8` |
|
||||
| __XXH3__ | 16 | 100 Gi | 312.5 | 332 | |
|
||||
| __XXH3__ | 32 | 14 Gi | 6.1 | 3 | |
|
||||
| __XXH128__ | 16 | 25 Gi | 0.0 | 0 | test range 9-16 |
|
||||
| __XXH128__ | 32 | 25 Gi | 0.0 | 0 | test range 17-128 |
|
||||
| __XXH128__ | 100 | 13 Gi | 0.0 | 0 | test range 17-128 |
|
||||
| __XXH128__ | 200 | 13 Gi | 0.0 | 0 | test range 129-240 |
|
1
deps/xxHash/tests/collisions/allcodecs/README.md
vendored
Normal file
1
deps/xxHash/tests/collisions/allcodecs/README.md
vendored
Normal file
@ -0,0 +1 @@
|
||||
Put in this directory all hash algorithms to test
|
38
deps/xxHash/tests/collisions/allcodecs/dummy.c
vendored
Normal file
38
deps/xxHash/tests/collisions/allcodecs/dummy.c
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* dummy.c, a fake hash algorithm, just to test integration capabilities.
|
||||
* Part of the xxHash project
|
||||
* Copyright (C) 2020 Yann Collet
|
||||
*
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
|
||||
#include <dummy.h>
|
||||
|
||||
unsigned badsum32(const void* input, size_t len, unsigned seed)
|
||||
{
|
||||
unsigned sum = seed;
|
||||
const unsigned char* in8 = input;
|
||||
size_t c;
|
||||
for (c=0; c<len; c++)
|
||||
sum += in8[c];
|
||||
return sum;
|
||||
}
|
45
deps/xxHash/tests/collisions/allcodecs/dummy.h
vendored
Normal file
45
deps/xxHash/tests/collisions/allcodecs/dummy.h
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* dummy.c,
|
||||
* A fake hash algorithm, just to test integration capabilities.
|
||||
* Part of the xxHash project
|
||||
* Copyright (C) 2020 Yann Collet
|
||||
*
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
#ifndef DUMMY_H_987987
|
||||
#define DUMMY_H_987987
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
unsigned badsum32(const void* input, size_t len, unsigned seed);
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DUMMY_H_987987 */
|
127
deps/xxHash/tests/collisions/hashes.h
vendored
Normal file
127
deps/xxHash/tests/collisions/hashes.h
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* List of hashes for the brute force collision tester
|
||||
* Part of xxHash project
|
||||
* Copyright (C) 2019-2020 Yann Collet
|
||||
*
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
#ifndef HASHES_H_1235465
|
||||
#define HASHES_H_1235465
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
#include <stdint.h> /* uint64_t */
|
||||
#define XXH_INLINE_ALL /* XXH128_hash_t */
|
||||
#include "xxhash.h"
|
||||
|
||||
|
||||
/* return type */
|
||||
|
||||
typedef union {
|
||||
uint64_t h64;
|
||||
XXH128_hash_t h128;
|
||||
} UniHash;
|
||||
|
||||
UniHash uniHash32(uint64_t v32)
|
||||
{ UniHash unih;
|
||||
unih.h64 = v32;
|
||||
return unih;
|
||||
}
|
||||
|
||||
UniHash uniHash64(uint64_t v64)
|
||||
{ UniHash unih;
|
||||
unih.h64 = v64;
|
||||
return unih;
|
||||
}
|
||||
|
||||
UniHash uniHash128(XXH128_hash_t v128)
|
||||
{ UniHash unih;
|
||||
unih.h128 = v128;
|
||||
return unih;
|
||||
}
|
||||
|
||||
|
||||
/* === xxHash === */
|
||||
|
||||
UniHash XXH3_wrapper (const void* data, size_t size)
|
||||
{
|
||||
return uniHash64( XXH3_64bits(data, size) );
|
||||
}
|
||||
|
||||
UniHash XXH128_wrapper (const void* data, size_t size)
|
||||
{
|
||||
return uniHash128( XXH3_128bits(data, size) );
|
||||
}
|
||||
|
||||
UniHash XXH128l_wrapper (const void* data, size_t size)
|
||||
{
|
||||
return uniHash64( XXH3_128bits(data, size).low64 );
|
||||
}
|
||||
|
||||
UniHash XXH128h_wrapper (const void* data, size_t size)
|
||||
{
|
||||
return uniHash64( XXH3_128bits(data, size).high64 );
|
||||
}
|
||||
|
||||
UniHash XXH64_wrapper (const void* data, size_t size)
|
||||
{
|
||||
return uniHash64 ( XXH64(data, size, 0) );
|
||||
}
|
||||
|
||||
UniHash XXH32_wrapper (const void* data, size_t size)
|
||||
{
|
||||
return uniHash32( XXH32(data, size, 0) );
|
||||
}
|
||||
|
||||
/* === Dummy integration example === */
|
||||
|
||||
#include "dummy.h"
|
||||
|
||||
UniHash badsum32_wrapper (const void* data, size_t size)
|
||||
{
|
||||
return uniHash32( badsum32(data, size, 0) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* === Table === */
|
||||
|
||||
typedef UniHash (*hashfn) (const void* data, size_t size);
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
hashfn fn;
|
||||
int bits;
|
||||
} hashDescription;
|
||||
|
||||
#define HASH_FN_TOTAL 7
|
||||
|
||||
hashDescription hashfnTable[HASH_FN_TOTAL] = {
|
||||
{ "xxh3" , XXH3_wrapper, 64 },
|
||||
{ "xxh64" , XXH64_wrapper, 64 },
|
||||
{ "xxh128", XXH128_wrapper, 128 },
|
||||
{ "xxh128l", XXH128l_wrapper, 64 },
|
||||
{ "xxh128h", XXH128h_wrapper, 64 },
|
||||
{ "xxh32" , XXH32_wrapper, 32 },
|
||||
{ "badsum32",badsum32_wrapper, 32 },
|
||||
};
|
||||
|
||||
#endif /* HASHES_H_1235465 */
|
1124
deps/xxHash/tests/collisions/main.c
vendored
Normal file
1124
deps/xxHash/tests/collisions/main.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
344
deps/xxHash/tests/collisions/pool.c
vendored
Normal file
344
deps/xxHash/tests/collisions/pool.c
vendored
Normal file
@ -0,0 +1,344 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2020 Yann Collet, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under both the BSD-style license (found in the
|
||||
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
* You may select, at your option, one of the above-listed licenses.
|
||||
*/
|
||||
|
||||
|
||||
/* ====== Dependencies ======= */
|
||||
#include <stddef.h> /* size_t */
|
||||
#include <stdlib.h> /* malloc, calloc, free */
|
||||
#include <string.h> /* memcpy */
|
||||
#include <assert.h>
|
||||
|
||||
#include "pool.h"
|
||||
|
||||
|
||||
/* ====== Compiler specifics ====== */
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
|
||||
#endif
|
||||
|
||||
|
||||
/* === Build Macro === */
|
||||
|
||||
#ifndef POOL_MT // can be defined on command line
|
||||
# define POOL_MT 1
|
||||
#endif
|
||||
|
||||
|
||||
/* === Implementation === */
|
||||
|
||||
#if POOL_MT
|
||||
|
||||
#include "threading.h" /* pthread adaptation */
|
||||
|
||||
/* A job is a function and an opaque argument */
|
||||
typedef struct POOL_job_s {
|
||||
POOL_function function;
|
||||
void *opaque;
|
||||
} POOL_job;
|
||||
|
||||
struct POOL_ctx_s {
|
||||
/* Keep track of the threads */
|
||||
ZSTD_pthread_t* threads;
|
||||
size_t threadCapacity;
|
||||
size_t threadLimit;
|
||||
|
||||
/* The queue is a circular buffer */
|
||||
POOL_job *queue;
|
||||
size_t queueHead;
|
||||
size_t queueTail;
|
||||
size_t queueSize;
|
||||
|
||||
/* The number of threads working on jobs */
|
||||
size_t numThreadsBusy;
|
||||
/* Indicates if the queue is empty */
|
||||
int queueEmpty;
|
||||
|
||||
/* The mutex protects the queue */
|
||||
ZSTD_pthread_mutex_t queueMutex;
|
||||
/* Condition variable for pushers to wait on when the queue is full */
|
||||
ZSTD_pthread_cond_t queuePushCond;
|
||||
/* Condition variables for poppers to wait on when the queue is empty */
|
||||
ZSTD_pthread_cond_t queuePopCond;
|
||||
/* Indicates if the queue is shutting down */
|
||||
int shutdown;
|
||||
};
|
||||
|
||||
/* POOL_thread() :
|
||||
* Work thread for the thread pool.
|
||||
* Waits for jobs and executes them.
|
||||
* @returns : NULL on failure else non-null.
|
||||
*/
|
||||
static void* POOL_thread(void* opaque)
|
||||
{
|
||||
POOL_ctx* const ctx = (POOL_ctx*)opaque;
|
||||
if (!ctx) { return NULL; }
|
||||
for (;;) {
|
||||
/* Lock the mutex and wait for a non-empty queue or until shutdown */
|
||||
ZSTD_pthread_mutex_lock(&ctx->queueMutex);
|
||||
|
||||
while ( ctx->queueEmpty
|
||||
|| (ctx->numThreadsBusy >= ctx->threadLimit) ) {
|
||||
if (ctx->shutdown) {
|
||||
/* even if !queueEmpty, (possible if numThreadsBusy >= threadLimit),
|
||||
* a few threads will be shutdown while !queueEmpty,
|
||||
* but enough threads will remain active to finish the queue */
|
||||
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
|
||||
return opaque;
|
||||
}
|
||||
ZSTD_pthread_cond_wait(&ctx->queuePopCond, &ctx->queueMutex);
|
||||
}
|
||||
/* Pop a job off the queue */
|
||||
{ POOL_job const job = ctx->queue[ctx->queueHead];
|
||||
ctx->queueHead = (ctx->queueHead + 1) % ctx->queueSize;
|
||||
ctx->numThreadsBusy++;
|
||||
ctx->queueEmpty = ctx->queueHead == ctx->queueTail;
|
||||
/* Unlock the mutex, signal a pusher, and run the job */
|
||||
ZSTD_pthread_cond_signal(&ctx->queuePushCond);
|
||||
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
|
||||
|
||||
job.function(job.opaque);
|
||||
|
||||
/* If the intended queue size was 0, signal after finishing job */
|
||||
ZSTD_pthread_mutex_lock(&ctx->queueMutex);
|
||||
ctx->numThreadsBusy--;
|
||||
if (ctx->queueSize == 1) {
|
||||
ZSTD_pthread_cond_signal(&ctx->queuePushCond);
|
||||
}
|
||||
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
|
||||
}
|
||||
} /* for (;;) */
|
||||
assert(0); /* Unreachable */
|
||||
}
|
||||
|
||||
POOL_ctx* POOL_create(size_t numThreads, size_t queueSize)
|
||||
{
|
||||
POOL_ctx* ctx;
|
||||
/* Check parameters */
|
||||
if (!numThreads) { return NULL; }
|
||||
/* Allocate the context and zero initialize */
|
||||
ctx = (POOL_ctx*)calloc(1, sizeof(POOL_ctx));
|
||||
if (!ctx) { return NULL; }
|
||||
/* Initialize the job queue.
|
||||
* It needs one extra space since one space is wasted to differentiate
|
||||
* empty and full queues.
|
||||
*/
|
||||
ctx->queueSize = queueSize + 1;
|
||||
ctx->queue = (POOL_job*)malloc(ctx->queueSize * sizeof(POOL_job));
|
||||
ctx->queueHead = 0;
|
||||
ctx->queueTail = 0;
|
||||
ctx->numThreadsBusy = 0;
|
||||
ctx->queueEmpty = 1;
|
||||
(void)ZSTD_pthread_mutex_init(&ctx->queueMutex, NULL);
|
||||
(void)ZSTD_pthread_cond_init(&ctx->queuePushCond, NULL);
|
||||
(void)ZSTD_pthread_cond_init(&ctx->queuePopCond, NULL);
|
||||
ctx->shutdown = 0;
|
||||
/* Allocate space for the thread handles */
|
||||
ctx->threads = (ZSTD_pthread_t*)malloc(numThreads * sizeof(ZSTD_pthread_t));
|
||||
ctx->threadCapacity = 0;
|
||||
/* Check for errors */
|
||||
if (!ctx->threads || !ctx->queue) { POOL_free(ctx); return NULL; }
|
||||
/* Initialize the threads */
|
||||
{ size_t i;
|
||||
for (i = 0; i < numThreads; ++i) {
|
||||
if (ZSTD_pthread_create(&ctx->threads[i], NULL, &POOL_thread, ctx)) {
|
||||
ctx->threadCapacity = i;
|
||||
POOL_free(ctx);
|
||||
return NULL;
|
||||
} }
|
||||
ctx->threadCapacity = numThreads;
|
||||
ctx->threadLimit = numThreads;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/*! POOL_join() :
|
||||
Shutdown the queue, wake any sleeping threads, and join all of the threads.
|
||||
*/
|
||||
static void POOL_join(POOL_ctx* ctx) {
|
||||
/* Shut down the queue */
|
||||
ZSTD_pthread_mutex_lock(&ctx->queueMutex);
|
||||
ctx->shutdown = 1;
|
||||
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
|
||||
|
||||
/* Wake up sleeping threads */
|
||||
ZSTD_pthread_cond_broadcast(&ctx->queuePushCond);
|
||||
ZSTD_pthread_cond_broadcast(&ctx->queuePopCond);
|
||||
|
||||
/* Join all of the threads */
|
||||
{ size_t i;
|
||||
for (i = 0; i < ctx->threadCapacity; ++i) {
|
||||
ZSTD_pthread_join(ctx->threads[i], NULL); /* note : could fail */
|
||||
} }
|
||||
}
|
||||
|
||||
void POOL_free(POOL_ctx *ctx) {
|
||||
if (!ctx) { return; }
|
||||
POOL_join(ctx);
|
||||
ZSTD_pthread_mutex_destroy(&ctx->queueMutex);
|
||||
ZSTD_pthread_cond_destroy(&ctx->queuePushCond);
|
||||
ZSTD_pthread_cond_destroy(&ctx->queuePopCond);
|
||||
free(ctx->queue);
|
||||
free(ctx->threads);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t POOL_sizeof(POOL_ctx *ctx) {
|
||||
if (ctx==NULL) return 0; /* supports sizeof NULL */
|
||||
return sizeof(*ctx)
|
||||
+ ctx->queueSize * sizeof(POOL_job)
|
||||
+ ctx->threadCapacity * sizeof(ZSTD_pthread_t);
|
||||
}
|
||||
|
||||
|
||||
/* @return : 0 on success, 1 on error */
|
||||
static int POOL_resize_internal(POOL_ctx* ctx, size_t numThreads)
|
||||
{
|
||||
if (numThreads <= ctx->threadCapacity) {
|
||||
if (!numThreads) return 1;
|
||||
ctx->threadLimit = numThreads;
|
||||
return 0;
|
||||
}
|
||||
/* numThreads > threadCapacity */
|
||||
{ ZSTD_pthread_t* const threadPool = (ZSTD_pthread_t*)malloc(numThreads * sizeof(ZSTD_pthread_t));
|
||||
if (!threadPool) return 1;
|
||||
/* replace existing thread pool */
|
||||
memcpy(threadPool, ctx->threads, ctx->threadCapacity * sizeof(*threadPool));
|
||||
free(ctx->threads);
|
||||
ctx->threads = threadPool;
|
||||
/* Initialize additional threads */
|
||||
{ size_t threadId;
|
||||
for (threadId = ctx->threadCapacity; threadId < numThreads; ++threadId) {
|
||||
if (ZSTD_pthread_create(&threadPool[threadId], NULL, &POOL_thread, ctx)) {
|
||||
ctx->threadCapacity = threadId;
|
||||
return 1;
|
||||
} }
|
||||
} }
|
||||
/* successfully expanded */
|
||||
ctx->threadCapacity = numThreads;
|
||||
ctx->threadLimit = numThreads;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* @return : 0 on success, 1 on error */
|
||||
int POOL_resize(POOL_ctx* ctx, size_t numThreads)
|
||||
{
|
||||
int result;
|
||||
if (ctx==NULL) return 1;
|
||||
ZSTD_pthread_mutex_lock(&ctx->queueMutex);
|
||||
result = POOL_resize_internal(ctx, numThreads);
|
||||
ZSTD_pthread_cond_broadcast(&ctx->queuePopCond);
|
||||
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if the queue is full and 0 otherwise.
|
||||
*
|
||||
* When queueSize is 1 (pool was created with an intended queueSize of 0),
|
||||
* then a queue is empty if there is a thread free _and_ no job is waiting.
|
||||
*/
|
||||
static int isQueueFull(POOL_ctx const* ctx) {
|
||||
if (ctx->queueSize > 1) {
|
||||
return ctx->queueHead == ((ctx->queueTail + 1) % ctx->queueSize);
|
||||
} else {
|
||||
return (ctx->numThreadsBusy == ctx->threadLimit) ||
|
||||
!ctx->queueEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void POOL_add_internal(POOL_ctx* ctx, POOL_function function, void *opaque)
|
||||
{
|
||||
POOL_job const job = {function, opaque};
|
||||
assert(ctx != NULL);
|
||||
if (ctx->shutdown) return;
|
||||
|
||||
ctx->queueEmpty = 0;
|
||||
ctx->queue[ctx->queueTail] = job;
|
||||
ctx->queueTail = (ctx->queueTail + 1) % ctx->queueSize;
|
||||
ZSTD_pthread_cond_signal(&ctx->queuePopCond);
|
||||
}
|
||||
|
||||
void POOL_add(POOL_ctx* ctx, POOL_function function, void* opaque)
|
||||
{
|
||||
assert(ctx != NULL);
|
||||
ZSTD_pthread_mutex_lock(&ctx->queueMutex);
|
||||
/* Wait until there is space in the queue for the new job */
|
||||
while (isQueueFull(ctx) && (!ctx->shutdown)) {
|
||||
ZSTD_pthread_cond_wait(&ctx->queuePushCond, &ctx->queueMutex);
|
||||
}
|
||||
POOL_add_internal(ctx, function, opaque);
|
||||
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
|
||||
}
|
||||
|
||||
|
||||
int POOL_tryAdd(POOL_ctx* ctx, POOL_function function, void* opaque)
|
||||
{
|
||||
assert(ctx != NULL);
|
||||
ZSTD_pthread_mutex_lock(&ctx->queueMutex);
|
||||
if (isQueueFull(ctx)) {
|
||||
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
|
||||
return 0;
|
||||
}
|
||||
POOL_add_internal(ctx, function, opaque);
|
||||
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#else /* POOL_MT not defined */
|
||||
|
||||
/* ========================== */
|
||||
/* No multi-threading support */
|
||||
/* ========================== */
|
||||
|
||||
|
||||
/* We don't need any data, but if it is empty, malloc() might return NULL. */
|
||||
struct POOL_ctx_s {
|
||||
int dummy;
|
||||
};
|
||||
static POOL_ctx g_ctx;
|
||||
|
||||
POOL_ctx* POOL_create(size_t numThreads, size_t queueSize) {
|
||||
(void)numThreads;
|
||||
(void)queueSize;
|
||||
return &g_ctx;
|
||||
}
|
||||
|
||||
void POOL_free(POOL_ctx* ctx) {
|
||||
assert(!ctx || ctx == &g_ctx);
|
||||
(void)ctx;
|
||||
}
|
||||
|
||||
int POOL_resize(POOL_ctx* ctx, size_t numThreads) {
|
||||
(void)ctx; (void)numThreads;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void POOL_add(POOL_ctx* ctx, POOL_function function, void* opaque) {
|
||||
(void)ctx;
|
||||
function(opaque);
|
||||
}
|
||||
|
||||
int POOL_tryAdd(POOL_ctx* ctx, POOL_function function, void* opaque) {
|
||||
(void)ctx;
|
||||
function(opaque);
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t POOL_sizeof(POOL_ctx* ctx) {
|
||||
if (ctx==NULL) return 0; /* supports sizeof NULL */
|
||||
assert(ctx == &g_ctx);
|
||||
return sizeof(*ctx);
|
||||
}
|
||||
|
||||
#endif /* ZSTD_MULTITHREAD */
|
80
deps/xxHash/tests/collisions/pool.h
vendored
Normal file
80
deps/xxHash/tests/collisions/pool.h
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2020 Yann Collet, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under both the BSD-style license (found in the
|
||||
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
* You may select, at your option, one of the above-listed licenses.
|
||||
*/
|
||||
|
||||
#ifndef POOL_H
|
||||
#define POOL_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
typedef struct POOL_ctx_s POOL_ctx;
|
||||
|
||||
/*! POOL_create() :
|
||||
* Create a thread pool with at most `numThreads` threads.
|
||||
* `numThreads` must be at least 1.
|
||||
* The maximum number of queued jobs before blocking is `queueSize`.
|
||||
* @return : POOL_ctx pointer on success, else NULL.
|
||||
*/
|
||||
POOL_ctx* POOL_create(size_t numThreads, size_t queueSize);
|
||||
|
||||
/*! POOL_free() :
|
||||
* Free a thread pool returned by POOL_create().
|
||||
*/
|
||||
void POOL_free(POOL_ctx* ctx);
|
||||
|
||||
/*! POOL_resize() :
|
||||
* Expands or shrinks pool's number of threads.
|
||||
* This is more efficient than releasing + creating a new context,
|
||||
* since it tries to preserve and re-use existing threads.
|
||||
* `numThreads` must be at least 1.
|
||||
* @return : 0 when resize was successful,
|
||||
* !0 (typically 1) if there is an error.
|
||||
* note : only numThreads can be resized, queueSize remains unchanged.
|
||||
*/
|
||||
int POOL_resize(POOL_ctx* ctx, size_t numThreads);
|
||||
|
||||
/*! POOL_sizeof() :
|
||||
* @return threadpool memory usage
|
||||
* note : compatible with NULL (returns 0 in this case)
|
||||
*/
|
||||
size_t POOL_sizeof(POOL_ctx* ctx);
|
||||
|
||||
/*! POOL_function :
|
||||
* The function type that can be added to a thread pool.
|
||||
*/
|
||||
typedef void (*POOL_function)(void*);
|
||||
|
||||
/*! POOL_add() :
|
||||
* Add the job `function(opaque)` to the thread pool. `ctx` must be valid.
|
||||
* Possibly blocks until there is room in the queue.
|
||||
* Note : The function may be executed asynchronously,
|
||||
* therefore, `opaque` must live until function has been completed.
|
||||
*/
|
||||
void POOL_add(POOL_ctx* ctx, POOL_function function, void* opaque);
|
||||
|
||||
|
||||
/*! POOL_tryAdd() :
|
||||
* Add the job `function(opaque)` to thread pool _if_ a worker is available.
|
||||
* Returns immediately even if not (does not block).
|
||||
* @return : 1 if successful, 0 if not.
|
||||
*/
|
||||
int POOL_tryAdd(POOL_ctx* ctx, POOL_function function, void* opaque);
|
||||
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
59
deps/xxHash/tests/collisions/sort.cc
vendored
Normal file
59
deps/xxHash/tests/collisions/sort.cc
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* sort.cc - C++ sort functions
|
||||
* Copyright (C) 2019-2020 Yann Collet
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
/*
|
||||
* C++ sort functions tend to run faster than C ones due to templates allowing
|
||||
* inline optimizations.
|
||||
* Also, glibc's qsort() seems to inflate memory usage, resulting in OOM
|
||||
* crashes on the test server.
|
||||
*/
|
||||
|
||||
#include <algorithm> // std::sort
|
||||
#define XXH_INLINE_ALL // XXH128_cmp
|
||||
#include <xxhash.h>
|
||||
|
||||
#include "sort.hh"
|
||||
|
||||
void sort64(uint64_t* table, size_t size)
|
||||
{
|
||||
std::sort(table, table + size);
|
||||
}
|
||||
|
||||
#include <stdlib.h> // qsort
|
||||
|
||||
void sort128(XXH128_hash_t* table, size_t size)
|
||||
{
|
||||
#if 0
|
||||
// C++ sort using a custom function object
|
||||
struct {
|
||||
bool operator()(XXH128_hash_t a, XXH128_hash_t b) const
|
||||
{
|
||||
return XXH128_cmp(&a, &b);
|
||||
}
|
||||
} customLess;
|
||||
std::sort(table, table + size, customLess);
|
||||
#else
|
||||
qsort(table, size, sizeof(*table), XXH128_cmp);
|
||||
#endif
|
||||
}
|
40
deps/xxHash/tests/collisions/sort.hh
vendored
Normal file
40
deps/xxHash/tests/collisions/sort.hh
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* sort.hh - headers for C++ sort functions
|
||||
* Copyright (C) 2019-2020 Yann Collet
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at :
|
||||
* - xxHash homepage : https://www.xxhash.com
|
||||
* - xxHash source repository : https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h> // size
|
||||
#include <stdint.h> // uint64_t
|
||||
#define XXH_STATIC_LINKING_ONLY // XXH128_hash_t
|
||||
#include "xxhash.h"
|
||||
|
||||
void sort64(uint64_t* table, size_t size);
|
||||
|
||||
void sort128(XXH128_hash_t* table, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern C
|
||||
#endif
|
82
deps/xxHash/tests/collisions/threading.c
vendored
Normal file
82
deps/xxHash/tests/collisions/threading.c
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Copyright (c) 2016 Tino Reichardt
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under both the BSD-style license (found in the
|
||||
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - zstdmt source repository: https://github.com/mcmilk/zstdmt
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file will hold wrapper for systems, which do not support pthreads
|
||||
*/
|
||||
|
||||
|
||||
/* === Build Macro === */
|
||||
|
||||
#ifndef POOL_MT // can be defined on command line
|
||||
# define POOL_MT 1
|
||||
#endif
|
||||
|
||||
|
||||
/* create fake symbol to avoid empty translation unit warning */
|
||||
int g_ZSTD_threading_useles_symbol;
|
||||
|
||||
#if POOL_MT && defined(_WIN32)
|
||||
|
||||
/**
|
||||
* Windows minimalist Pthread Wrapper
|
||||
*/
|
||||
|
||||
|
||||
/* === Dependencies === */
|
||||
#include <process.h>
|
||||
#include <errno.h>
|
||||
#include "threading.h"
|
||||
|
||||
|
||||
/* === Implementation === */
|
||||
|
||||
static unsigned __stdcall worker(void *arg)
|
||||
{
|
||||
ZSTD_pthread_t* const thread = (ZSTD_pthread_t*) arg;
|
||||
thread->arg = thread->start_routine(thread->arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZSTD_pthread_create(ZSTD_pthread_t* thread, const void* unused,
|
||||
void* (*start_routine) (void*), void* arg)
|
||||
{
|
||||
(void)unused;
|
||||
thread->arg = arg;
|
||||
thread->start_routine = start_routine;
|
||||
thread->handle = (HANDLE) _beginthreadex(NULL, 0, worker, thread, 0, NULL);
|
||||
|
||||
if (!thread->handle)
|
||||
return errno;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZSTD_pthread_join(ZSTD_pthread_t thread, void **value_ptr)
|
||||
{
|
||||
DWORD result;
|
||||
|
||||
if (!thread.handle) return 0;
|
||||
|
||||
result = WaitForSingleObject(thread.handle, INFINITE);
|
||||
switch (result) {
|
||||
case WAIT_OBJECT_0:
|
||||
if (value_ptr) *value_ptr = thread.arg;
|
||||
return 0;
|
||||
case WAIT_ABANDONED:
|
||||
return EINVAL;
|
||||
default:
|
||||
return (int)GetLastError();
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* POOL_MT */
|
124
deps/xxHash/tests/collisions/threading.h
vendored
Normal file
124
deps/xxHash/tests/collisions/threading.h
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
/**
|
||||
* Copyright (c) 2016 Tino Reichardt
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under both the BSD-style license (found in the
|
||||
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - zstdmt source repository: https://github.com/mcmilk/zstdmt
|
||||
*/
|
||||
|
||||
#ifndef THREADING_H_938743
|
||||
#define THREADING_H_938743
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* === Build Macro === */
|
||||
|
||||
#ifndef POOL_MT // can be defined on command line
|
||||
# define POOL_MT 1
|
||||
#endif
|
||||
|
||||
|
||||
/* === Implementation === */
|
||||
|
||||
#if POOL_MT && defined(_WIN32)
|
||||
|
||||
/**
|
||||
* Define windows version before include
|
||||
*/
|
||||
#undef WINVER
|
||||
#define WINVER 0x0600
|
||||
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0600
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* mutex */
|
||||
#define ZSTD_pthread_mutex_t CRITICAL_SECTION
|
||||
#define ZSTD_pthread_mutex_init(a, b) ((void)(b), InitializeCriticalSection((a)), 0)
|
||||
#define ZSTD_pthread_mutex_destroy(a) DeleteCriticalSection((a))
|
||||
#define ZSTD_pthread_mutex_lock(a) EnterCriticalSection((a))
|
||||
#define ZSTD_pthread_mutex_unlock(a) LeaveCriticalSection((a))
|
||||
|
||||
/* condition variable */
|
||||
#define ZSTD_pthread_cond_t CONDITION_VARIABLE
|
||||
#define ZSTD_pthread_cond_init(a, b) ((void)(b), InitializeConditionVariable((a)), 0)
|
||||
#define ZSTD_pthread_cond_destroy(a) ((void)(a))
|
||||
#define ZSTD_pthread_cond_wait(a, b) SleepConditionVariableCS((a), (b), INFINITE)
|
||||
#define ZSTD_pthread_cond_signal(a) WakeConditionVariable((a))
|
||||
#define ZSTD_pthread_cond_broadcast(a) WakeAllConditionVariable((a))
|
||||
|
||||
/* ZSTD_pthread_create() and ZSTD_pthread_join() */
|
||||
typedef struct {
|
||||
HANDLE handle;
|
||||
void* (*start_routine)(void*);
|
||||
void* arg;
|
||||
} ZSTD_pthread_t;
|
||||
|
||||
int ZSTD_pthread_create(ZSTD_pthread_t* thread, const void* unused,
|
||||
void* (*start_routine) (void*), void* arg);
|
||||
|
||||
int ZSTD_pthread_join(ZSTD_pthread_t thread, void** value_ptr);
|
||||
|
||||
/**
|
||||
* add here more wrappers as required
|
||||
*/
|
||||
|
||||
|
||||
#elif POOL_MT /* posix assumed ; need a better detection method */
|
||||
/* === POSIX Systems === */
|
||||
# include <pthread.h>
|
||||
|
||||
#define ZSTD_pthread_mutex_t pthread_mutex_t
|
||||
#define ZSTD_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
|
||||
#define ZSTD_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
|
||||
#define ZSTD_pthread_mutex_lock(a) pthread_mutex_lock((a))
|
||||
#define ZSTD_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
|
||||
|
||||
#define ZSTD_pthread_cond_t pthread_cond_t
|
||||
#define ZSTD_pthread_cond_init(a, b) pthread_cond_init((a), (b))
|
||||
#define ZSTD_pthread_cond_destroy(a) pthread_cond_destroy((a))
|
||||
#define ZSTD_pthread_cond_wait(a, b) pthread_cond_wait((a), (b))
|
||||
#define ZSTD_pthread_cond_signal(a) pthread_cond_signal((a))
|
||||
#define ZSTD_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
|
||||
|
||||
#define ZSTD_pthread_t pthread_t
|
||||
#define ZSTD_pthread_create(a, b, c, d) pthread_create((a), (b), (c), (d))
|
||||
#define ZSTD_pthread_join(a, b) pthread_join((a),(b))
|
||||
|
||||
#else /* POOL_MT == 0 */
|
||||
/* No multithreading support */
|
||||
|
||||
typedef int ZSTD_pthread_mutex_t;
|
||||
#define ZSTD_pthread_mutex_init(a, b) ((void)(a), (void)(b), 0)
|
||||
#define ZSTD_pthread_mutex_destroy(a) ((void)(a))
|
||||
#define ZSTD_pthread_mutex_lock(a) ((void)(a))
|
||||
#define ZSTD_pthread_mutex_unlock(a) ((void)(a))
|
||||
|
||||
typedef int ZSTD_pthread_cond_t;
|
||||
#define ZSTD_pthread_cond_init(a, b) ((void)(a), (void)(b), 0)
|
||||
#define ZSTD_pthread_cond_destroy(a) ((void)(a))
|
||||
#define ZSTD_pthread_cond_wait(a, b) ((void)(a), (void)(b))
|
||||
#define ZSTD_pthread_cond_signal(a) ((void)(a))
|
||||
#define ZSTD_pthread_cond_broadcast(a) ((void)(a))
|
||||
|
||||
/* do not use ZSTD_pthread_t */
|
||||
|
||||
#endif /* POOL_MT */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* THREADING_H_938743 */
|
154
deps/xxHash/tests/generate_unicode_test.c
vendored
Normal file
154
deps/xxHash/tests/generate_unicode_test.c
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Generates a Unicode test for xxhsum without using Unicode in the source files.
|
||||
*
|
||||
* Copyright (C) 2020 Devin Hussey (easyaspi314)
|
||||
*
|
||||
* BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Certain terminals don't properly handle UTF-8 (i.e. rxvt and command prompt
|
||||
* in the default codepage), and that can cause issues when editing text.
|
||||
*
|
||||
* We use this C file to generate a file with a Unicode filename, a file with
|
||||
* a checksum of said file, and both a Windows batch script and a Unix shell
|
||||
* script to test the file.
|
||||
*/
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS /* Silence warnings on MSVC */
|
||||
#include <stdio.h>
|
||||
|
||||
/* Use a Japanese filename, something that can't be cheated with ANSI.
|
||||
* yuniko-do.unicode (literally unicode.unicode) */
|
||||
|
||||
/* Use raw hex values to ensure that the output is well-formed UTF-8. It is also more C90 compliant. */
|
||||
static const char FILENAME[] = {
|
||||
(char)0xe3, (char)0x83, (char)0xa6, /* U+30e6: Katakana letter yu */
|
||||
(char)0xe3, (char)0x83, (char)0x8b, /* U+30cb: Katakana letter ni */
|
||||
(char)0xe3, (char)0x82, (char)0xb3, /* U+30b3: Katakana letter ko */
|
||||
(char)0xe3, (char)0x83, (char)0xbc, /* U+30fc: Katakana-Hiragana prolonged sound mark (dash) */
|
||||
(char)0xe3, (char)0x83, (char)0x89, /* U+30c9: Katakana letter do */
|
||||
'.','u','n','i','c','o','d','e','\0' /* ".unicode" (so we can glob in make clean and .gitignore) */
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
/* The same text as above, but encoded in Windows UTF-16. */
|
||||
static const wchar_t WFILENAME[] = { 0x30e6, 0x30cb, 0x30b3, 0x30fc, 0x30c9, L'.', L'u', L'n', L'i', L'c', L'o', L'd', L'e', L'\0' };
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
FILE *f, *script, *checksum;
|
||||
|
||||
/* Create our Unicode file. Use _wfopen on Windows as fopen doesn't support Unicode filenames. */
|
||||
#ifdef _WIN32
|
||||
if (!(f = _wfopen(WFILENAME, L"wb"))) return 1;
|
||||
#else
|
||||
if (!(f = fopen(FILENAME, "wb"))) return 1;
|
||||
#endif
|
||||
fprintf(f, "test\n");
|
||||
fclose(f);
|
||||
|
||||
/* XXH64 checksum file with the precalculated checksum for said file. */
|
||||
if (!(checksum = fopen("unicode_test.xxh64", "wb")))
|
||||
return 1;
|
||||
fprintf(checksum, "2d7f1808da1fa63c %s\n", FILENAME);
|
||||
fclose(checksum);
|
||||
|
||||
|
||||
/* Create two scripts for both Windows and Unix. */
|
||||
|
||||
/* Generate a Windows batch script. Always insert CRLF manually. */
|
||||
if (!(script = fopen("unicode_test.bat", "wb")))
|
||||
return 1;
|
||||
|
||||
/* Disable echoing the commands. We do that ourselves the naive way. */
|
||||
fprintf(script, "@echo off\r\n");
|
||||
|
||||
/* Change to codepage 65001 to enable UTF-8 support. */
|
||||
fprintf(script, "chcp 65001 >NUL 2>&1\r\n");
|
||||
|
||||
/* First test a Unicode filename */
|
||||
fprintf(script, "echo Testing filename provided on command line...\r\n");
|
||||
fprintf(script, "echo xxhsum.exe \"%s\"\r\n", FILENAME);
|
||||
fprintf(script, "xxhsum.exe \"%s\"\r\n", FILENAME);
|
||||
|
||||
/* Bail on error */
|
||||
fprintf(script, "if %%ERRORLEVEL%% neq 0 (\r\n");
|
||||
fprintf(script, " exit /B %%ERRORLEVEL%%\r\n");
|
||||
fprintf(script, ")\r\n");
|
||||
|
||||
/* Then test a checksum file. */
|
||||
fprintf(script, "echo Testing a checksum file...\r\n");
|
||||
fprintf(script, "echo xxhsum.exe -c unicode_test.xxh64\r\n");
|
||||
fprintf(script, "xxhsum.exe -c unicode_test.xxh64\r\n");
|
||||
|
||||
fprintf(script, "exit /B %%ERRORLEVEL%%\r\n");
|
||||
|
||||
fclose(script);
|
||||
|
||||
/* Generate a Unix shell script */
|
||||
if (!(script = fopen("unicode_test.sh", "wb")))
|
||||
return 1;
|
||||
|
||||
fprintf(script, "#!/bin/sh\n");
|
||||
/*
|
||||
* Some versions of MSYS, MinGW and Cygwin do not support UTF-8, and the ones that
|
||||
* don't may error with something like this:
|
||||
*
|
||||
* Error: Could not open '<mojibake>.unicode': No such file or directory.
|
||||
*
|
||||
* which is an internal error that happens when it tries to convert MinGW/Cygwin
|
||||
* paths to Windows paths.
|
||||
*
|
||||
* In that case, we bail to cmd.exe and the batch script, which supports UTF-8
|
||||
* on Windows 7 and later.
|
||||
*/
|
||||
fprintf(script, "case $(uname) in\n");
|
||||
/* MinGW/MSYS converts /c to C:\ unless you have a double slash,
|
||||
* Cygwin does not. */
|
||||
fprintf(script, " *CYGWIN*)\n");
|
||||
fprintf(script, " exec cmd.exe /c unicode_test.bat\n");
|
||||
fprintf(script, " ;;\n");
|
||||
fprintf(script, " *MINGW*|*MSYS*)\n");
|
||||
fprintf(script, " exec cmd.exe //c unicode_test.bat\n");
|
||||
fprintf(script, " ;;\n");
|
||||
fprintf(script, "esac\n");
|
||||
|
||||
/* First test a Unicode filename */
|
||||
fprintf(script, "echo Testing filename provided on command line...\n");
|
||||
fprintf(script, "echo './xxhsum \"%s\" || exit $?'\n", FILENAME);
|
||||
fprintf(script, "./xxhsum \"%s\" || exit $?\n", FILENAME);
|
||||
|
||||
/* Then test a checksum file. */
|
||||
fprintf(script, "echo Testing a checksum file...\n");
|
||||
fprintf(script, "echo './xxhsum -c unicode_test.xxh64 || exit $?'\n");
|
||||
fprintf(script, "./xxhsum -c unicode_test.xxh64 || exit $?\n");
|
||||
|
||||
fclose(script);
|
||||
|
||||
return 0;
|
||||
}
|
66
deps/xxHash/tests/multiInclude.c
vendored
Normal file
66
deps/xxHash/tests/multiInclude.c
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Multi-include test program
|
||||
* Validates that xxhash.h can be included multiple times and in any order
|
||||
*
|
||||
* Copyright (C) 2020 Yann Collet
|
||||
*
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
#include <stdio.h> /* printf */
|
||||
|
||||
/* Normal include, gives access to public symbols */
|
||||
#include "../xxhash.h"
|
||||
|
||||
/*
|
||||
* Advanced include, gives access to experimental symbols
|
||||
* This test ensure that xxhash.h can be included multiple times and in any
|
||||
* order. This order is more difficult: Without care, the declaration of
|
||||
* experimental symbols could be skipped.
|
||||
*/
|
||||
#define XXH_STATIC_LINKING_ONLY
|
||||
#include "../xxhash.h"
|
||||
|
||||
/*
|
||||
* Inlining: Re-define all identifiers, keep them private to the unit.
|
||||
* Note: Without specific efforts, the identifier names would collide.
|
||||
*
|
||||
* To be linked with and without xxhash.o to test the symbol's presence and
|
||||
* naming collisions.
|
||||
*/
|
||||
#define XXH_INLINE_ALL
|
||||
#include "../xxhash.h"
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
XXH3_state_t state; /* part of experimental API */
|
||||
|
||||
XXH3_64bits_reset(&state);
|
||||
const char input[] = "Hello World !";
|
||||
|
||||
XXH3_64bits_update(&state, input, sizeof(input));
|
||||
|
||||
XXH64_hash_t const h = XXH3_64bits_digest(&state);
|
||||
printf("hash '%s': %08x%08x \n", input, (unsigned)(h >> 32), (unsigned)h);
|
||||
|
||||
return 0;
|
||||
}
|
62
deps/xxHash/tests/ppc_define.c
vendored
Normal file
62
deps/xxHash/tests/ppc_define.c
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Multi-include test program
|
||||
* ensure that pixel, bool and vector are not redefined
|
||||
*
|
||||
* Copyright (C) 2020 Yann Collet
|
||||
*
|
||||
* GPL v2 License
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
/* gcc's altivec.h, included for the VSX code path,
|
||||
* may, in some circumstances, redefine
|
||||
* bool, vector and pixel keywords.
|
||||
*
|
||||
* This unit checks if it happens.
|
||||
* It's a compile test.
|
||||
* The test is mostly meaningful for PPC target using altivec.h
|
||||
* hence XXH_VECTOR == XXH_VSX
|
||||
*/
|
||||
|
||||
#define BOOL_VALUE 32123456
|
||||
#define bool BOOL_VALUE
|
||||
|
||||
#define VECTOR_VALUE 374464784
|
||||
#define vector VECTOR_VALUE
|
||||
|
||||
#define PIXEL_VALUE 5846841
|
||||
#define pixel PIXEL_VALUE
|
||||
|
||||
#define XXH_INLINE_ALL
|
||||
#include "../xxhash.h"
|
||||
|
||||
#if (bool != BOOL_VALUE)
|
||||
# error "bool macro was redefined !"
|
||||
#endif
|
||||
|
||||
#if (vector != VECTOR_VALUE)
|
||||
# error "vector macro was redefined !"
|
||||
#endif
|
||||
|
||||
#if (pixel != PIXEL_VALUE)
|
||||
# error "pixel macro was redefined !"
|
||||
#endif
|
||||
|
||||
int g_nonEmptyUnit = 0;
|
55
deps/xxHash/xxh3.h
vendored
Normal file
55
deps/xxHash/xxh3.h
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* xxHash - Extremely Fast Hash algorithm
|
||||
* Development source file for `xxh3`
|
||||
* Copyright (C) 2019-2020 Yann Collet
|
||||
*
|
||||
* BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
/*
|
||||
* Note: This file used to host the source code of XXH3_* variants.
|
||||
* during the development period.
|
||||
* The source code is now properly integrated within xxhash.h.
|
||||
*
|
||||
* xxh3.h is no longer useful,
|
||||
* but it is still provided for compatibility with source code
|
||||
* which used to include it directly.
|
||||
*
|
||||
* Programs are now highly discourage to include xxh3.h.
|
||||
* Include `xxhash.h` instead, which is the officially supported interface.
|
||||
*
|
||||
* In the future, xxh3.h will start to generate warnings, then errors,
|
||||
* then it will be removed from source package and from include directory.
|
||||
*/
|
||||
|
||||
/* Simulate the same impact as including the old xxh3.h source file */
|
||||
|
||||
#define XXH_INLINE_ALL
|
||||
#include "xxhash.h"
|
749
deps/xxHash/xxh_x86dispatch.c
vendored
Normal file
749
deps/xxHash/xxh_x86dispatch.c
vendored
Normal file
@ -0,0 +1,749 @@
|
||||
/*
|
||||
* xxHash - Extremely Fast Hash algorithm
|
||||
* Copyright (C) 2020 Yann Collet
|
||||
*
|
||||
* BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dispatcher code for XXH3 on x86-based targets.
|
||||
*/
|
||||
#if !(defined(__x86_64__) || defined(__i386__) || defined(_M_IX86) || defined(_M_X64))
|
||||
# error "Dispatching is currently only supported on x86 and x86_64."
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
# error "Dispatching requires __attribute__((__target__)) capability"
|
||||
#endif
|
||||
|
||||
#define XXH_DISPATCH_AVX2 /* enable dispatch towards AVX2 */
|
||||
#define XXH_DISPATCH_AVX512 /* enable dispatch towards AVX512 */
|
||||
|
||||
#ifdef XXH_DISPATCH_DEBUG
|
||||
/* debug logging */
|
||||
# include <stdio.h>
|
||||
# define XXH_debugPrint(str) { fprintf(stderr, "DEBUG: xxHash dispatch: %s \n", str); fflush(NULL); }
|
||||
#else
|
||||
# define XXH_debugPrint(str) ((void)0)
|
||||
# undef NDEBUG /* avoid redefinition */
|
||||
# define NDEBUG
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# include <immintrin.h> /* sse2 */
|
||||
# include <emmintrin.h> /* avx2 */
|
||||
#elif defined(_MSC_VER)
|
||||
# include <intrin.h>
|
||||
#endif
|
||||
|
||||
#define XXH_INLINE_ALL
|
||||
#define XXH_X86DISPATCH
|
||||
#define XXH_TARGET_AVX512 __attribute__((__target__("avx512f")))
|
||||
#define XXH_TARGET_AVX2 __attribute__((__target__("avx2")))
|
||||
#define XXH_TARGET_SSE2 __attribute__((__target__("sse2")))
|
||||
#include "xxhash.h"
|
||||
|
||||
/*
|
||||
* Modified version of Intel's guide
|
||||
* https://software.intel.com/en-us/articles/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
# include <intrin.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Support both AT&T and Intel dialects
|
||||
*
|
||||
* GCC doesn't convert AT&T syntax to Intel syntax, and will error out if
|
||||
* compiled with -masm=intel. Instead, it supports dialect switching with
|
||||
* curly braces: { AT&T syntax | Intel syntax }
|
||||
*
|
||||
* Clang's integrated assembler automatically converts AT&T syntax to Intel if
|
||||
* needed, making the dialect switching useless (it isn't even supported).
|
||||
*
|
||||
* Note: Comments are written in the inline assembly itself.
|
||||
*/
|
||||
#ifdef __clang__
|
||||
# define I_ATT(intel, att) att "\n\t"
|
||||
#else
|
||||
# define I_ATT(intel, att) "{" att "|" intel "}\n\t"
|
||||
#endif
|
||||
|
||||
|
||||
static void XXH_cpuid(xxh_u32 eax, xxh_u32 ecx, xxh_u32* abcd)
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
__cpuidex(abcd, eax, ecx);
|
||||
#else
|
||||
xxh_u32 ebx, edx;
|
||||
# if defined(__i386__) && defined(__PIC__)
|
||||
__asm__(
|
||||
"# Call CPUID\n\t"
|
||||
"#\n\t"
|
||||
"# On 32-bit x86 with PIC enabled, we are not allowed to overwrite\n\t"
|
||||
"# EBX, so we use EDI instead.\n\t"
|
||||
I_ATT("mov edi, ebx", "movl %%ebx, %%edi")
|
||||
I_ATT("cpuid", "cpuid" )
|
||||
I_ATT("xchg edi, ebx", "xchgl %%ebx, %%edi")
|
||||
: "=D" (ebx),
|
||||
# else
|
||||
__asm__(
|
||||
"# Call CPUID\n\t"
|
||||
I_ATT("cpuid", "cpuid")
|
||||
: "=b" (ebx),
|
||||
# endif
|
||||
"+a" (eax), "+c" (ecx), "=d" (edx));
|
||||
abcd[0] = eax;
|
||||
abcd[1] = ebx;
|
||||
abcd[2] = ecx;
|
||||
abcd[3] = edx;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(XXH_DISPATCH_AVX2) || defined(XXH_DISPATCH_AVX512)
|
||||
/*
|
||||
* While the CPU may support AVX2, the operating system might not properly save
|
||||
* the full YMM/ZMM registers.
|
||||
*
|
||||
* xgetbv is used for detecting this: Any compliant operating system will define
|
||||
* a set of flags in the xcr0 register indicating how it saves the AVX registers.
|
||||
*
|
||||
* You can manually disable this flag on Windows by running, as admin:
|
||||
*
|
||||
* bcdedit.exe /set xsavedisable 1
|
||||
*
|
||||
* and rebooting. Run the same command with 0 to re-enable it.
|
||||
*/
|
||||
static xxh_u64 XXH_xgetbv(void)
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
return _xgetbv(0); /* min VS2010 SP1 compiler is required */
|
||||
#else
|
||||
xxh_u32 xcr0_lo, xcr0_hi;
|
||||
__asm__(
|
||||
"# Call XGETBV\n\t"
|
||||
"#\n\t"
|
||||
"# Older assemblers (e.g. macOS's ancient GAS version) don't support\n\t"
|
||||
"# the XGETBV opcode, so we encode it by hand instead.\n\t"
|
||||
"# See <https://github.com/asmjit/asmjit/issues/78> for details.\n\t"
|
||||
".byte 0x0f, 0x01, 0xd0\n\t"
|
||||
: "=a" (xcr0_lo), "=d" (xcr0_hi) : "c" (0));
|
||||
return xcr0_lo | ((xxh_u64)xcr0_hi << 32);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SSE2_CPUID_MASK (1 << 26)
|
||||
#define OSXSAVE_CPUID_MASK ((1 << 26) | (1 << 27))
|
||||
#define AVX2_CPUID_MASK (1 << 5)
|
||||
#define AVX2_XGETBV_MASK ((1 << 2) | (1 << 1))
|
||||
#define AVX512F_CPUID_MASK (1 << 16)
|
||||
#define AVX512F_XGETBV_MASK ((7 << 5) | (1 << 2) | (1 << 1))
|
||||
|
||||
/* Returns the best XXH3 implementation */
|
||||
static int XXH_featureTest(void)
|
||||
{
|
||||
xxh_u32 abcd[4];
|
||||
xxh_u32 max_leaves;
|
||||
int best = XXH_SCALAR;
|
||||
#if defined(XXH_DISPATCH_AVX2) || defined(XXH_DISPATCH_AVX512)
|
||||
xxh_u64 xgetbv_val;
|
||||
#endif
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
xxh_u32 cpuid_supported;
|
||||
__asm__(
|
||||
"# For the sake of ruthless backwards compatibility, check if CPUID\n\t"
|
||||
"# is supported in the EFLAGS on i386.\n\t"
|
||||
"# This is not necessary on x86_64 - CPUID is mandatory.\n\t"
|
||||
"# The ID flag (bit 21) in the EFLAGS register indicates support\n\t"
|
||||
"# for the CPUID instruction. If a software procedure can set and\n\t"
|
||||
"# clear this flag, the processor executing the procedure supports\n\t"
|
||||
"# the CPUID instruction.\n\t"
|
||||
"# <https://c9x.me/x86/html/file_module_x86_id_45.html>\n\t"
|
||||
"#\n\t"
|
||||
"# Routine is from <https://wiki.osdev.org/CPUID>.\n\t"
|
||||
|
||||
"# Save EFLAGS\n\t"
|
||||
I_ATT("pushfd", "pushfl" )
|
||||
"# Store EFLAGS\n\t"
|
||||
I_ATT("pushfd", "pushfl" )
|
||||
"# Invert the ID bit in stored EFLAGS\n\t"
|
||||
I_ATT("xor dword ptr[esp], 0x200000", "xorl $0x200000, (%%esp)")
|
||||
"# Load stored EFLAGS (with ID bit inverted)\n\t"
|
||||
I_ATT("popfd", "popfl" )
|
||||
"# Store EFLAGS again (ID bit may or not be inverted)\n\t"
|
||||
I_ATT("pushfd", "pushfl" )
|
||||
"# eax = modified EFLAGS (ID bit may or may not be inverted)\n\t"
|
||||
I_ATT("pop eax", "popl %%eax" )
|
||||
"# eax = whichever bits were changed\n\t"
|
||||
I_ATT("xor eax, dword ptr[esp]", "xorl (%%esp), %%eax" )
|
||||
"# Restore original EFLAGS\n\t"
|
||||
I_ATT("popfd", "popfl" )
|
||||
"# eax = zero if ID bit can't be changed, else non-zero\n\t"
|
||||
I_ATT("and eax, 0x200000", "andl $0x200000, %%eax" )
|
||||
: "=a" (cpuid_supported) :: "cc");
|
||||
|
||||
if (XXH_unlikely(!cpuid_supported)) {
|
||||
XXH_debugPrint("CPUID support is not detected!");
|
||||
return best;
|
||||
}
|
||||
|
||||
#endif
|
||||
/* Check how many CPUID pages we have */
|
||||
XXH_cpuid(0, 0, abcd);
|
||||
max_leaves = abcd[0];
|
||||
|
||||
/* Shouldn't happen on hardware, but happens on some QEMU configs. */
|
||||
if (XXH_unlikely(max_leaves == 0)) {
|
||||
XXH_debugPrint("Max CPUID leaves == 0!");
|
||||
return best;
|
||||
}
|
||||
|
||||
/* Check for SSE2, OSXSAVE and xgetbv */
|
||||
XXH_cpuid(1, 0, abcd);
|
||||
|
||||
/*
|
||||
* Test for SSE2. The check is redundant on x86_64, but it doesn't hurt.
|
||||
*/
|
||||
if (XXH_unlikely((abcd[3] & SSE2_CPUID_MASK) != SSE2_CPUID_MASK))
|
||||
return best;
|
||||
|
||||
XXH_debugPrint("SSE2 support detected.");
|
||||
|
||||
best = XXH_SSE2;
|
||||
#if defined(XXH_DISPATCH_AVX2) || defined(XXH_DISPATCH_AVX512)
|
||||
/* Make sure we have enough leaves */
|
||||
if (XXH_unlikely(max_leaves < 7))
|
||||
return best;
|
||||
|
||||
/* Test for OSXSAVE and XGETBV */
|
||||
if ((abcd[2] & OSXSAVE_CPUID_MASK) != OSXSAVE_CPUID_MASK)
|
||||
return best;
|
||||
|
||||
/* CPUID check for AVX features */
|
||||
XXH_cpuid(7, 0, abcd);
|
||||
|
||||
xgetbv_val = XXH_xgetbv();
|
||||
#if defined(XXH_DISPATCH_AVX2)
|
||||
/* Validate that AVX2 is supported by the CPU */
|
||||
if ((abcd[1] & AVX2_CPUID_MASK) != AVX2_CPUID_MASK)
|
||||
return best;
|
||||
|
||||
/* Validate that the OS supports YMM registers */
|
||||
if ((xgetbv_val & AVX2_XGETBV_MASK) != AVX2_XGETBV_MASK) {
|
||||
XXH_debugPrint("AVX2 supported by the CPU, but not the OS.");
|
||||
return best;
|
||||
}
|
||||
|
||||
/* AVX2 supported */
|
||||
XXH_debugPrint("AVX2 support detected.");
|
||||
best = XXH_AVX2;
|
||||
#endif
|
||||
#if defined(XXH_DISPATCH_AVX512)
|
||||
/* Check if AVX512F is supported by the CPU */
|
||||
if ((abcd[1] & AVX512F_CPUID_MASK) != AVX512F_CPUID_MASK) {
|
||||
XXH_debugPrint("AVX512F not supported by CPU");
|
||||
return best;
|
||||
}
|
||||
|
||||
/* Validate that the OS supports ZMM registers */
|
||||
if ((xgetbv_val & AVX512F_XGETBV_MASK) != AVX512F_XGETBV_MASK) {
|
||||
XXH_debugPrint("AVX512F supported by the CPU, but not the OS.");
|
||||
return best;
|
||||
}
|
||||
|
||||
/* AVX512F supported */
|
||||
XXH_debugPrint("AVX512F support detected.");
|
||||
best = XXH_AVX512;
|
||||
#endif
|
||||
#endif
|
||||
return best;
|
||||
}
|
||||
|
||||
|
||||
/* === Vector implementations === */
|
||||
|
||||
/* === XXH3, default variants === */
|
||||
|
||||
XXH_NO_INLINE XXH64_hash_t
|
||||
XXHL64_default_scalar(const void* XXH_RESTRICT input, size_t len)
|
||||
{
|
||||
return XXH3_hashLong_64b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar);
|
||||
}
|
||||
|
||||
XXH_NO_INLINE XXH_TARGET_SSE2 XXH64_hash_t
|
||||
XXHL64_default_sse2(const void* XXH_RESTRICT input, size_t len)
|
||||
{
|
||||
return XXH3_hashLong_64b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2);
|
||||
}
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX2
|
||||
XXH_NO_INLINE XXH_TARGET_AVX2 XXH64_hash_t
|
||||
XXHL64_default_avx2(const void* XXH_RESTRICT input, size_t len)
|
||||
{
|
||||
return XXH3_hashLong_64b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX512
|
||||
XXH_NO_INLINE XXH_TARGET_AVX512 XXH64_hash_t
|
||||
XXHL64_default_avx512(const void* XXH_RESTRICT input, size_t len)
|
||||
{
|
||||
return XXH3_hashLong_64b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* === XXH3, Seeded variants === */
|
||||
|
||||
XXH_NO_INLINE XXH64_hash_t
|
||||
XXHL64_seed_scalar(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed)
|
||||
{
|
||||
return XXH3_hashLong_64b_withSeed_internal(input, len, seed,
|
||||
XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar, XXH3_initCustomSecret_scalar);
|
||||
}
|
||||
|
||||
XXH_NO_INLINE XXH_TARGET_SSE2 XXH64_hash_t
|
||||
XXHL64_seed_sse2(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed)
|
||||
{
|
||||
return XXH3_hashLong_64b_withSeed_internal(input, len, seed,
|
||||
XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2, XXH3_initCustomSecret_sse2);
|
||||
}
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX2
|
||||
XXH_NO_INLINE XXH_TARGET_AVX2 XXH64_hash_t
|
||||
XXHL64_seed_avx2(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed)
|
||||
{
|
||||
return XXH3_hashLong_64b_withSeed_internal(input, len, seed,
|
||||
XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2, XXH3_initCustomSecret_avx2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX512
|
||||
XXH_NO_INLINE XXH_TARGET_AVX512 XXH64_hash_t
|
||||
XXHL64_seed_avx512(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed)
|
||||
{
|
||||
return XXH3_hashLong_64b_withSeed_internal(input, len, seed,
|
||||
XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512, XXH3_initCustomSecret_avx512);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* === XXH3, Secret variants === */
|
||||
|
||||
XXH_NO_INLINE XXH64_hash_t
|
||||
XXHL64_secret_scalar(const void* XXH_RESTRICT input, size_t len, const void* secret, size_t secretLen)
|
||||
{
|
||||
return XXH3_hashLong_64b_internal(input, len, secret, secretLen,
|
||||
XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar);
|
||||
}
|
||||
|
||||
XXH_NO_INLINE XXH_TARGET_SSE2 XXH64_hash_t
|
||||
XXHL64_secret_sse2(const void* XXH_RESTRICT input, size_t len, const void* secret, size_t secretLen)
|
||||
{
|
||||
return XXH3_hashLong_64b_internal(input, len, secret, secretLen,
|
||||
XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2);
|
||||
}
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX2
|
||||
XXH_NO_INLINE XXH_TARGET_AVX2 XXH64_hash_t
|
||||
XXHL64_secret_avx2(const void* XXH_RESTRICT input, size_t len, const void* secret, size_t secretLen)
|
||||
{
|
||||
return XXH3_hashLong_64b_internal(input, len, secret, secretLen,
|
||||
XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX512
|
||||
XXH_NO_INLINE XXH_TARGET_AVX512 XXH64_hash_t
|
||||
XXHL64_secret_avx512(const void* XXH_RESTRICT input, size_t len, const void* secret, size_t secretLen)
|
||||
{
|
||||
return XXH3_hashLong_64b_internal(input, len, secret, secretLen,
|
||||
XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* === XXH3 update variants === */
|
||||
|
||||
XXH_NO_INLINE XXH_errorcode
|
||||
XXH3_64bits_update_scalar(XXH3_state_t* state, const void* input, size_t len)
|
||||
{
|
||||
return XXH3_update(state, (const xxh_u8*)input, len,
|
||||
XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar);
|
||||
}
|
||||
|
||||
XXH_NO_INLINE XXH_TARGET_SSE2 XXH_errorcode
|
||||
XXH3_64bits_update_sse2(XXH3_state_t* state, const void* input, size_t len)
|
||||
{
|
||||
return XXH3_update(state, (const xxh_u8*)input, len,
|
||||
XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2);
|
||||
}
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX2
|
||||
XXH_NO_INLINE XXH_TARGET_AVX2 XXH_errorcode
|
||||
XXH3_64bits_update_avx2(XXH3_state_t* state, const void* input, size_t len)
|
||||
{
|
||||
return XXH3_update(state, (const xxh_u8*)input, len,
|
||||
XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX512
|
||||
XXH_NO_INLINE XXH_TARGET_AVX512 XXH_errorcode
|
||||
XXH3_64bits_update_avx512(XXH3_state_t* state, const void* input, size_t len)
|
||||
{
|
||||
return XXH3_update(state, (const xxh_u8*)input, len,
|
||||
XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* === XXH128 default variants === */
|
||||
|
||||
XXH_NO_INLINE XXH128_hash_t
|
||||
XXHL128_default_scalar(const void* XXH_RESTRICT input, size_t len)
|
||||
{
|
||||
return XXH3_hashLong_128b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar);
|
||||
}
|
||||
|
||||
XXH_NO_INLINE XXH_TARGET_SSE2 XXH128_hash_t
|
||||
XXHL128_default_sse2(const void* XXH_RESTRICT input, size_t len)
|
||||
{
|
||||
return XXH3_hashLong_128b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2);
|
||||
}
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX2
|
||||
XXH_NO_INLINE XXH_TARGET_AVX2 XXH128_hash_t
|
||||
XXHL128_default_avx2(const void* XXH_RESTRICT input, size_t len)
|
||||
{
|
||||
return XXH3_hashLong_128b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX512
|
||||
XXH_NO_INLINE XXH_TARGET_AVX512 XXH128_hash_t
|
||||
XXHL128_default_avx512(const void* XXH_RESTRICT input, size_t len)
|
||||
{
|
||||
return XXH3_hashLong_128b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* === XXH128 Secret variants === */
|
||||
|
||||
XXH_NO_INLINE XXH128_hash_t
|
||||
XXHL128_secret_scalar(const void* XXH_RESTRICT input, size_t len, const void* XXH_RESTRICT secret, size_t secretLen)
|
||||
{
|
||||
return XXH3_hashLong_128b_internal(input, len, (const xxh_u8*)secret, secretLen,
|
||||
XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar);
|
||||
}
|
||||
|
||||
XXH_NO_INLINE XXH_TARGET_SSE2 XXH128_hash_t
|
||||
XXHL128_secret_sse2(const void* XXH_RESTRICT input, size_t len, const void* XXH_RESTRICT secret, size_t secretLen)
|
||||
{
|
||||
return XXH3_hashLong_128b_internal(input, len, (const xxh_u8*)secret, secretLen,
|
||||
XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2);
|
||||
}
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX2
|
||||
XXH_NO_INLINE XXH_TARGET_AVX2 XXH128_hash_t
|
||||
XXHL128_secret_avx2(const void* XXH_RESTRICT input, size_t len, const void* XXH_RESTRICT secret, size_t secretLen)
|
||||
{
|
||||
return XXH3_hashLong_128b_internal(input, len, (const xxh_u8*)secret, secretLen,
|
||||
XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX512
|
||||
XXH_NO_INLINE XXH_TARGET_AVX512 XXH128_hash_t
|
||||
XXHL128_secret_avx512(const void* XXH_RESTRICT input, size_t len, const void* XXH_RESTRICT secret, size_t secretLen)
|
||||
{
|
||||
return XXH3_hashLong_128b_internal(input, len, (const xxh_u8*)secret, secretLen,
|
||||
XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* === XXH128 Seeded variants === */
|
||||
|
||||
XXH_NO_INLINE XXH128_hash_t
|
||||
XXHL128_seed_scalar(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed)
|
||||
{
|
||||
return XXH3_hashLong_128b_withSeed_internal(input, len, seed,
|
||||
XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar, XXH3_initCustomSecret_scalar);
|
||||
}
|
||||
|
||||
XXH_NO_INLINE XXH_TARGET_SSE2 XXH128_hash_t
|
||||
XXHL128_seed_sse2(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed)
|
||||
{
|
||||
return XXH3_hashLong_128b_withSeed_internal(input, len, seed,
|
||||
XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2, XXH3_initCustomSecret_sse2);
|
||||
}
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX2
|
||||
XXH_NO_INLINE XXH_TARGET_AVX2 XXH128_hash_t
|
||||
XXHL128_seed_avx2(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed)
|
||||
{
|
||||
return XXH3_hashLong_128b_withSeed_internal(input, len, seed,
|
||||
XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2, XXH3_initCustomSecret_avx2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX512
|
||||
XXH_NO_INLINE XXH_TARGET_AVX512 XXH128_hash_t
|
||||
XXHL128_seed_avx512(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed)
|
||||
{
|
||||
return XXH3_hashLong_128b_withSeed_internal(input, len, seed,
|
||||
XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512, XXH3_initCustomSecret_avx512);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* === XXH128 update variants === */
|
||||
|
||||
XXH_NO_INLINE XXH_errorcode
|
||||
XXH3_128bits_update_scalar(XXH3_state_t* state, const void* input, size_t len)
|
||||
{
|
||||
return XXH3_update(state, (const xxh_u8*)input, len,
|
||||
XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar);
|
||||
}
|
||||
|
||||
XXH_NO_INLINE XXH_TARGET_SSE2 XXH_errorcode
|
||||
XXH3_128bits_update_sse2(XXH3_state_t* state, const void* input, size_t len)
|
||||
{
|
||||
return XXH3_update(state, (const xxh_u8*)input, len,
|
||||
XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2);
|
||||
}
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX2
|
||||
XXH_NO_INLINE XXH_TARGET_AVX2 XXH_errorcode
|
||||
XXH3_128bits_update_avx2(XXH3_state_t* state, const void* input, size_t len)
|
||||
{
|
||||
return XXH3_update(state, (const xxh_u8*)input, len,
|
||||
XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XXH_DISPATCH_AVX512
|
||||
XXH_NO_INLINE XXH_TARGET_AVX512 XXH_errorcode
|
||||
XXH3_128bits_update_avx512(XXH3_state_t* state, const void* input, size_t len)
|
||||
{
|
||||
return XXH3_update(state, (const xxh_u8*)input, len,
|
||||
XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ==== Dispatchers ==== */
|
||||
|
||||
typedef XXH64_hash_t (*XXH3_dispatchx86_hashLong64_default)(const void* XXH_RESTRICT, size_t);
|
||||
|
||||
typedef XXH64_hash_t (*XXH3_dispatchx86_hashLong64_withSeed)(const void* XXH_RESTRICT, size_t, XXH64_hash_t);
|
||||
|
||||
typedef XXH64_hash_t (*XXH3_dispatchx86_hashLong64_withSecret)(const void* XXH_RESTRICT, size_t, const void* XXH_RESTRICT, size_t);
|
||||
|
||||
typedef XXH_errorcode (*XXH3_dispatchx86_update)(XXH3_state_t*, const void*, size_t);
|
||||
|
||||
typedef struct {
|
||||
XXH3_dispatchx86_hashLong64_default hashLong64_default;
|
||||
XXH3_dispatchx86_hashLong64_withSeed hashLong64_seed;
|
||||
XXH3_dispatchx86_hashLong64_withSecret hashLong64_secret;
|
||||
XXH3_dispatchx86_update update;
|
||||
} dispatchFunctions_s;
|
||||
|
||||
static dispatchFunctions_s g_dispatch = { NULL, NULL, NULL, NULL};
|
||||
|
||||
#define NB_DISPATCHES 4
|
||||
static const dispatchFunctions_s k_dispatch[NB_DISPATCHES] = {
|
||||
/* scalar */ { XXHL64_default_scalar, XXHL64_seed_scalar, XXHL64_secret_scalar, XXH3_64bits_update_scalar },
|
||||
/* sse2 */ { XXHL64_default_sse2, XXHL64_seed_sse2, XXHL64_secret_sse2, XXH3_64bits_update_sse2 },
|
||||
#ifdef XXH_DISPATCH_AVX2
|
||||
/* avx2 */ { XXHL64_default_avx2, XXHL64_seed_avx2, XXHL64_secret_avx2, XXH3_64bits_update_avx2 },
|
||||
#else
|
||||
/* avx2 */ { NULL, NULL, NULL, NULL },
|
||||
#endif
|
||||
#ifdef XXH_DISPATCH_AVX512
|
||||
/* avx512 */ { XXHL64_default_avx512, XXHL64_seed_avx512, XXHL64_secret_avx512, XXH3_64bits_update_avx512 }
|
||||
#else
|
||||
/* avx512 */ { NULL, NULL, NULL, NULL }
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef XXH128_hash_t (*XXH3_dispatchx86_hashLong128_default)(const void* XXH_RESTRICT, size_t);
|
||||
|
||||
typedef XXH128_hash_t (*XXH3_dispatchx86_hashLong128_withSeed)(const void* XXH_RESTRICT, size_t, XXH64_hash_t);
|
||||
|
||||
typedef XXH128_hash_t (*XXH3_dispatchx86_hashLong128_withSecret)(const void* XXH_RESTRICT, size_t, const void* XXH_RESTRICT, size_t);
|
||||
|
||||
typedef struct {
|
||||
XXH3_dispatchx86_hashLong128_default hashLong128_default;
|
||||
XXH3_dispatchx86_hashLong128_withSeed hashLong128_seed;
|
||||
XXH3_dispatchx86_hashLong128_withSecret hashLong128_secret;
|
||||
XXH3_dispatchx86_update update;
|
||||
} dispatch128Functions_s;
|
||||
|
||||
static dispatch128Functions_s g_dispatch128 = { NULL, NULL, NULL, NULL };
|
||||
|
||||
static const dispatch128Functions_s k_dispatch128[NB_DISPATCHES] = {
|
||||
/* scalar */ { XXHL128_default_scalar, XXHL128_seed_scalar, XXHL128_secret_scalar, XXH3_128bits_update_scalar },
|
||||
/* sse2 */ { XXHL128_default_sse2, XXHL128_seed_sse2, XXHL128_secret_sse2, XXH3_128bits_update_sse2 },
|
||||
#ifdef XXH_DISPATCH_AVX2
|
||||
/* avx2 */ { XXHL128_default_avx2, XXHL128_seed_avx2, XXHL128_secret_avx2, XXH3_128bits_update_avx2 },
|
||||
#else
|
||||
/* avx2 */ { NULL, NULL, NULL, NULL },
|
||||
#endif
|
||||
#ifdef XXH_DISPATCH_AVX512
|
||||
/* avx512 */ { XXHL128_default_avx512, XXHL128_seed_avx512, XXHL128_secret_avx512, XXH3_128bits_update_avx512 }
|
||||
#else
|
||||
/* avx512 */ { NULL, NULL, NULL, NULL }
|
||||
#endif
|
||||
};
|
||||
|
||||
static void setDispatch(void)
|
||||
{
|
||||
int vecID = XXH_featureTest();
|
||||
XXH_STATIC_ASSERT(XXH_AVX512 == NB_DISPATCHES-1);
|
||||
assert(XXH_SCALAR <= vecID && vecID <= XXH_AVX512);
|
||||
#ifndef XXH_DISPATCH_AVX512
|
||||
assert(vecID != XXH_AVX512);
|
||||
#endif
|
||||
#ifndef XXH_DISPATCH_AVX2
|
||||
assert(vecID != XXH_AVX2);
|
||||
#endif
|
||||
g_dispatch = k_dispatch[vecID];
|
||||
g_dispatch128 = k_dispatch128[vecID];
|
||||
}
|
||||
|
||||
|
||||
/* ==== XXH3 public functions ==== */
|
||||
|
||||
static XXH64_hash_t
|
||||
XXH3_hashLong_64b_defaultSecret_selection(const void* input, size_t len,
|
||||
XXH64_hash_t seed64, const xxh_u8* secret, size_t secretLen)
|
||||
{
|
||||
(void)seed64; (void)secret; (void)secretLen;
|
||||
if (g_dispatch.hashLong64_default == NULL) setDispatch();
|
||||
return g_dispatch.hashLong64_default(input, len);
|
||||
}
|
||||
|
||||
XXH64_hash_t XXH3_64bits_dispatch(const void* input, size_t len)
|
||||
{
|
||||
return XXH3_64bits_internal(input, len, 0, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_64b_defaultSecret_selection);
|
||||
}
|
||||
|
||||
static XXH64_hash_t
|
||||
XXH3_hashLong_64b_withSeed_selection(const void* input, size_t len,
|
||||
XXH64_hash_t seed64, const xxh_u8* secret, size_t secretLen)
|
||||
{
|
||||
(void)secret; (void)secretLen;
|
||||
if (g_dispatch.hashLong64_seed == NULL) setDispatch();
|
||||
return g_dispatch.hashLong64_seed(input, len, seed64);
|
||||
}
|
||||
|
||||
XXH64_hash_t XXH3_64bits_withSeed_dispatch(const void* input, size_t len, XXH64_hash_t seed)
|
||||
{
|
||||
return XXH3_64bits_internal(input, len, seed, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_64b_withSeed_selection);
|
||||
}
|
||||
|
||||
static XXH64_hash_t
|
||||
XXH3_hashLong_64b_withSecret_selection(const void* input, size_t len,
|
||||
XXH64_hash_t seed64, const xxh_u8* secret, size_t secretLen)
|
||||
{
|
||||
(void)seed64;
|
||||
if (g_dispatch.hashLong64_secret == NULL) setDispatch();
|
||||
return g_dispatch.hashLong64_secret(input, len, secret, secretLen);
|
||||
}
|
||||
|
||||
XXH64_hash_t XXH3_64bits_withSecret_dispatch(const void* input, size_t len, const void* secret, size_t secretLen)
|
||||
{
|
||||
return XXH3_64bits_internal(input, len, 0, secret, secretLen, XXH3_hashLong_64b_withSecret_selection);
|
||||
}
|
||||
|
||||
XXH_errorcode
|
||||
XXH3_64bits_update_dispatch(XXH3_state_t* state, const void* input, size_t len)
|
||||
{
|
||||
if (g_dispatch.update == NULL) setDispatch();
|
||||
return g_dispatch.update(state, (const xxh_u8*)input, len);
|
||||
}
|
||||
|
||||
|
||||
/* ==== XXH128 public functions ==== */
|
||||
|
||||
static XXH128_hash_t
|
||||
XXH3_hashLong_128b_defaultSecret_selection(const void* input, size_t len,
|
||||
XXH64_hash_t seed64, const void* secret, size_t secretLen)
|
||||
{
|
||||
(void)seed64; (void)secret; (void)secretLen;
|
||||
if (g_dispatch128.hashLong128_default == NULL) setDispatch();
|
||||
return g_dispatch128.hashLong128_default(input, len);
|
||||
}
|
||||
|
||||
XXH128_hash_t XXH3_128bits_dispatch(const void* input, size_t len)
|
||||
{
|
||||
return XXH3_128bits_internal(input, len, 0, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_128b_defaultSecret_selection);
|
||||
}
|
||||
|
||||
static XXH128_hash_t
|
||||
XXH3_hashLong_128b_withSeed_selection(const void* input, size_t len,
|
||||
XXH64_hash_t seed64, const void* secret, size_t secretLen)
|
||||
{
|
||||
(void)secret; (void)secretLen;
|
||||
if (g_dispatch128.hashLong128_seed == NULL) setDispatch();
|
||||
return g_dispatch128.hashLong128_seed(input, len, seed64);
|
||||
}
|
||||
|
||||
XXH128_hash_t XXH3_128bits_withSeed_dispatch(const void* input, size_t len, XXH64_hash_t seed)
|
||||
{
|
||||
return XXH3_128bits_internal(input, len, seed, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_128b_withSeed_selection);
|
||||
}
|
||||
|
||||
static XXH128_hash_t
|
||||
XXH3_hashLong_128b_withSecret_selection(const void* input, size_t len,
|
||||
XXH64_hash_t seed64, const void* secret, size_t secretLen)
|
||||
{
|
||||
(void)seed64;
|
||||
if (g_dispatch128.hashLong128_secret == NULL) setDispatch();
|
||||
return g_dispatch128.hashLong128_secret(input, len, secret, secretLen);
|
||||
}
|
||||
|
||||
XXH128_hash_t XXH3_128bits_withSecret_dispatch(const void* input, size_t len, const void* secret, size_t secretLen)
|
||||
{
|
||||
return XXH3_128bits_internal(input, len, 0, secret, secretLen, XXH3_hashLong_128b_withSecret_selection);
|
||||
}
|
||||
|
||||
XXH_errorcode
|
||||
XXH3_128bits_update_dispatch(XXH3_state_t* state, const void* input, size_t len)
|
||||
{
|
||||
if (g_dispatch128.update == NULL) setDispatch();
|
||||
return g_dispatch128.update(state, (const xxh_u8*)input, len);
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
86
deps/xxHash/xxh_x86dispatch.h
vendored
Normal file
86
deps/xxHash/xxh_x86dispatch.h
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* xxHash - XXH3 Dispatcher for x86-based targets
|
||||
* Copyright (C) 2020 Yann Collet
|
||||
*
|
||||
* BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* You can contact the author at:
|
||||
* - xxHash homepage: https://www.xxhash.com
|
||||
* - xxHash source repository: https://github.com/Cyan4973/xxHash
|
||||
*/
|
||||
|
||||
#ifndef XXH_X86DISPATCH_H_13563687684
|
||||
#define XXH_X86DISPATCH_H_13563687684
|
||||
|
||||
#include "xxhash.h" /* XXH64_hash_t, XXH3_state_t */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_dispatch(const void* input, size_t len);
|
||||
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSeed_dispatch(const void* input, size_t len, XXH64_hash_t seed);
|
||||
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSecret_dispatch(const void* input, size_t len, const void* secret, size_t secretLen);
|
||||
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_update_dispatch(XXH3_state_t* state, const void* input, size_t len);
|
||||
|
||||
XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_dispatch(const void* input, size_t len);
|
||||
XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSeed_dispatch(const void* input, size_t len, XXH64_hash_t seed);
|
||||
XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSecret_dispatch(const void* input, size_t len, const void* secret, size_t secretLen);
|
||||
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_update_dispatch(XXH3_state_t* state, const void* input, size_t len);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* automatic replacement of XXH3 functions.
|
||||
* can be disabled by setting XXH_DISPATCH_DISABLE_REPLACE */
|
||||
#ifndef XXH_DISPATCH_DISABLE_REPLACE
|
||||
|
||||
# undef XXH3_64bits
|
||||
# define XXH3_64bits XXH3_64bits_dispatch
|
||||
# undef XXH3_64bits_withSeed
|
||||
# define XXH3_64bits_withSeed XXH3_64bits_withSeed_dispatch
|
||||
# undef XXH3_64bits_withSecret
|
||||
# define XXH3_64bits_withSecret XXH3_64bits_withSecret_dispatch
|
||||
# undef XXH3_64bits_update
|
||||
# define XXH3_64bits_update XXH3_64bits_update_dispatch
|
||||
|
||||
# undef XXH128
|
||||
# define XXH128 XXH3_128bits_withSeed_dispatch
|
||||
# define XXH3_128bits XXH3_128bits_dispatch
|
||||
# undef XXH3_128bits
|
||||
# define XXH3_128bits XXH3_128bits_dispatch
|
||||
# undef XXH3_128bits_withSeed
|
||||
# define XXH3_128bits_withSeed XXH3_128bits_withSeed_dispatch
|
||||
# undef XXH3_128bits_withSecret
|
||||
# define XXH3_128bits_withSecret XXH3_128bits_withSecret_dispatch
|
||||
# undef XXH3_128bits_update
|
||||
# define XXH3_128bits_update XXH3_128bits_update_dispatch
|
||||
|
||||
#endif /* XXH_DISPATCH_DISABLE_REPLACE */
|
||||
|
||||
#endif /* XXH_X86DISPATCH_H_13563687684 */
|
1058
deps/xxHash/xxhash.c
vendored
1058
deps/xxHash/xxhash.c
vendored
File diff suppressed because it is too large
Load Diff
4812
deps/xxHash/xxhash.h
vendored
4812
deps/xxHash/xxhash.h
vendored
File diff suppressed because it is too large
Load Diff
67
deps/xxHash/xxhsum.1
vendored
67
deps/xxHash/xxhsum.1
vendored
@ -1,26 +1,20 @@
|
||||
.
|
||||
.TH "XXHSUM" "1" "September 2017" "xxhsum 0.6.3" "User Commands"
|
||||
.TH "XXHSUM" "1" "July 2020" "xxhsum 0.7.4" "User Commands"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBxxhsum\fR \- print or check xxHash non\-cryptographic checksums
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBxxhsum [<OPTION>] \.\.\. [<FILE>] \.\.\.\fR
|
||||
.
|
||||
.br
|
||||
\fBxxhsum \-b [<OPTION>] \.\.\.\fR
|
||||
\fBxxhsum [<OPTION>] \.\.\. [<FILE>] \.\.\.\fR \fBxxhsum \-b [<OPTION>] \.\.\.\fR
|
||||
.
|
||||
.P
|
||||
\fBxxh32sum\fR is equivalent to \fBxxhsum \-H0\fR
|
||||
.
|
||||
.br
|
||||
\fBxxh64sum\fR is equivalent to \fBxxhsum \-H1\fR
|
||||
\fBxxh32sum\fR is equivalent to \fBxxhsum \-H0\fR \fBxxh64sum\fR is equivalent to \fBxxhsum \-H1\fR \fBxxh128sum\fR is equivalent to \fBxxhsum \-H2\fR
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
Print or check xxHash (32 or 64bit) checksums\. When \fIFILE\fR is \fB\-\fR, read standard input\.
|
||||
Print or check xxHash (32, 64 or 128 bits) checksums\. When no \fIFILE\fR, read standard input, except if it\'s the console\. When \fIFILE\fR is \fB\-\fR, read standard input even if it\'s the console\.
|
||||
.
|
||||
.P
|
||||
\fBxxhsum\fR supports a command line syntax similar but not identical to md5sum(1)\. Differences are: \fBxxhsum\fR doesn\'t have text/binary mode switch (\fB\-b\fR, \fB\-t\fR); \fBxxhsum\fR always treats file as binary file; \fBxxhsum\fR has hash bit width switch (\fB\-H\fR);
|
||||
\fBxxhsum\fR supports a command line syntax similar but not identical to md5sum(1)\. Differences are: \fBxxhsum\fR doesn\'t have text/binary mode switch (\fB\-b\fR, \fB\-t\fR); \fBxxhsum\fR always treats files as binary file; \fBxxhsum\fR has a hash bit width switch (\fB\-H\fR);
|
||||
.
|
||||
.P
|
||||
As xxHash is a fast non\-cryptographic checksum algorithm, \fBxxhsum\fR should not be used for security related purposes\.
|
||||
@ -32,11 +26,15 @@ As xxHash is a fast non\-cryptographic checksum algorithm, \fBxxhsum\fR should n
|
||||
.
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Display xxhsum version
|
||||
Displays xxhsum version and exits
|
||||
.
|
||||
.TP
|
||||
\fB\-H\fR\fIHASHTYPE\fR
|
||||
Hash selection\. \fIHASHTYPE\fR means \fB0\fR=32bits, \fB1\fR=64bits\. Default value is \fB1\fR (64bits)
|
||||
Hash selection\. \fIHASHTYPE\fR means \fB0\fR=32bits, \fB1\fR=64bits, \fB2\fR=128bits\. Alternatively, \fIHASHTYPE\fR \fB32\fR=32bits, \fB64\fR=64bits, \fB128\fR=128bits\. Default value is \fB1\fR (64bits)
|
||||
.
|
||||
.TP
|
||||
\fB\-\-tag\fR
|
||||
Output in the BSD style\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-little\-endian\fR
|
||||
@ -44,30 +42,30 @@ Set output hexadecimal checksum value as little endian convention\. By default,
|
||||
.
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Display help and exit
|
||||
Displays help and exits
|
||||
.
|
||||
.P
|
||||
\fBThe following four options are useful only when verifying checksums (\fB\-c\fR)\fR
|
||||
.
|
||||
.TP
|
||||
\fB\-c\fR, \fB\-\-check\fR
|
||||
Read xxHash sums from the \fIFILE\fRs and check them
|
||||
\fB\-c\fR, \fB\-\-check\fR \fIFILE\fR
|
||||
Read xxHash sums from \fIFILE\fR and check them
|
||||
.
|
||||
.TP
|
||||
\fB\-\-quiet\fR
|
||||
Exit non\-zero for improperly formatted checksum lines
|
||||
.
|
||||
.TP
|
||||
\fB\-\-strict\fR
|
||||
\fB\-q\fR, \fB\-\-quiet\fR
|
||||
Don\'t print OK for each successfully verified file
|
||||
.
|
||||
.TP
|
||||
\fB\-\-strict\fR
|
||||
Return an error code if any line in the file is invalid, not just if some checksums are wrong\. This policy is disabled by default, though UI will prompt an informational message if any line in the file is detected invalid\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-status\fR
|
||||
Don\'t output anything, status code shows success
|
||||
Don\'t output anything\. Status code shows success\.
|
||||
.
|
||||
.TP
|
||||
\fB\-w\fR, \fB\-\-warn\fR
|
||||
Warn about improperly formatted checksum lines
|
||||
Emit a warning message about each improperly formatted checksum line\.
|
||||
.
|
||||
.P
|
||||
\fBThe following options are useful only benchmark purpose\fR
|
||||
@ -77,12 +75,16 @@ Warn about improperly formatted checksum lines
|
||||
Benchmark mode\. See \fIEXAMPLES\fR for details\.
|
||||
.
|
||||
.TP
|
||||
\fB\-b#\fR
|
||||
Specify ID of variant to be tested\. Multiple variants can be selected, separated by a \',\' comma\.
|
||||
.
|
||||
.TP
|
||||
\fB\-B\fR\fIBLOCKSIZE\fR
|
||||
Only useful for benchmark mode (\fB\-b\fR)\. See \fIEXAMPLES\fR for details\. \fIBLOCKSIZE\fR specifies benchmark mode\'s test data block size in bytes\. Default value is 102400
|
||||
.
|
||||
.TP
|
||||
\fB\-i\fR\fIITERATIONS\fR
|
||||
Only useful for benchmark mode (\fB\-b\fR)\. See \fIEXAMPLES\fR for details\. \fIITERATIONS\fR specifies number of iterations in benchmark\. Single iteration takes at least 2500 milliseconds\. Default value is 3
|
||||
Only useful for benchmark mode (\fB\-b\fR)\. See \fIEXAMPLES\fR for details\. \fIITERATIONS\fR specifies number of iterations in benchmark\. Single iteration lasts approximately 1000 milliseconds\. Default value is 3
|
||||
.
|
||||
.SH "EXIT STATUS"
|
||||
\fBxxhsum\fR exit \fB0\fR on success, \fB1\fR if at least one file couldn\'t be read or doesn\'t have the same checksum as the \fB\-c\fR option\.
|
||||
@ -128,13 +130,26 @@ $ xxhsum \-c xyz\.xxh32 qux\.xxh64
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Benchmark xxHash algorithm for 16384 bytes data in 10 times\. \fBxxhsum\fR benchmarks xxHash algorithm for 32\-bit and 64\-bit and output results to standard output\. First column means algorithm, second column is source data size in bytes, last column means hash generation speed in mega\-bytes per seconds\.
|
||||
Benchmark xxHash algorithm\. By default, \fBxxhsum\fR benchmarks xxHash main variants on a synthetic sample of 100 KB, and print results into standard output\. The first column is the algorithm, the second column is the source data size in bytes, the third column is the number of hashes generated per second (throughput), and finally the last column translates speed in megabytes per second\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ xxhsum \-b \-i10 \-B16384
|
||||
$ xxhsum \-b
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
In the following example, the sample to hash is set to 16384 bytes, the variants to be benched are selected by their IDs, and each benchmark test is repeated 10 times, for increased accuracy\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ xxhsum \-b1,2,3 \-i10 \-B16384
|
||||
.
|
||||
.fi
|
||||
.
|
||||
|
72
deps/xxHash/xxhsum.1.md
vendored
72
deps/xxHash/xxhsum.1.md
vendored
@ -9,19 +9,21 @@ SYNOPSIS
|
||||
|
||||
`xxh32sum` is equivalent to `xxhsum -H0`
|
||||
`xxh64sum` is equivalent to `xxhsum -H1`
|
||||
`xxh128sum` is equivalent to `xxhsum -H2`
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
Print or check xxHash (32 or 64bit) checksums. When <FILE> is `-`, read
|
||||
standard input.
|
||||
Print or check xxHash (32, 64 or 128 bits) checksums.
|
||||
When no <FILE>, read standard input, except if it's the console.
|
||||
When <FILE> is `-`, read standard input even if it's the console.
|
||||
|
||||
`xxhsum` supports a command line syntax similar but not identical to
|
||||
md5sum(1). Differences are:
|
||||
`xxhsum` supports a command line syntax similar but not identical to md5sum(1).
|
||||
Differences are:
|
||||
`xxhsum` doesn't have text/binary mode switch (`-b`, `-t`);
|
||||
`xxhsum` always treats file as binary file;
|
||||
`xxhsum` has hash bit width switch (`-H`);
|
||||
`xxhsum` always treats files as binary file;
|
||||
`xxhsum` has a hash bit width switch (`-H`);
|
||||
|
||||
As xxHash is a fast non-cryptographic checksum algorithm,
|
||||
`xxhsum` should not be used for security related purposes.
|
||||
@ -32,41 +34,53 @@ OPTIONS
|
||||
-------
|
||||
|
||||
* `-V`, `--version`:
|
||||
Display xxhsum version
|
||||
Displays xxhsum version and exits
|
||||
|
||||
* `-H`<HASHTYPE>:
|
||||
Hash selection. <HASHTYPE> means `0`=32bits, `1`=64bits.
|
||||
Hash selection. <HASHTYPE> means `0`=32bits, `1`=64bits, `2`=128bits.
|
||||
Alternatively, <HASHTYPE> `32`=32bits, `64`=64bits, `128`=128bits.
|
||||
Default value is `1` (64bits)
|
||||
|
||||
* `--tag`:
|
||||
Output in the BSD style.
|
||||
|
||||
* `--little-endian`:
|
||||
Set output hexadecimal checksum value as little endian convention.
|
||||
By default, value is displayed as big endian.
|
||||
|
||||
* `-h`, `--help`:
|
||||
Display help and exit
|
||||
Displays help and exits
|
||||
|
||||
**The following four options are useful only when verifying checksums (`-c`)**
|
||||
|
||||
* `-c`, `--check`:
|
||||
Read xxHash sums from the <FILE>s and check them
|
||||
* `-c`, `--check` <FILE>:
|
||||
Read xxHash sums from <FILE> and check them
|
||||
|
||||
* `--quiet`:
|
||||
Exit non-zero for improperly formatted checksum lines
|
||||
|
||||
* `--strict`:
|
||||
* `-q`, `--quiet`:
|
||||
Don't print OK for each successfully verified file
|
||||
|
||||
* `--strict`:
|
||||
Return an error code if any line in the file is invalid,
|
||||
not just if some checksums are wrong.
|
||||
This policy is disabled by default,
|
||||
though UI will prompt an informational message
|
||||
if any line in the file is detected invalid.
|
||||
|
||||
* `--status`:
|
||||
Don't output anything, status code shows success
|
||||
Don't output anything. Status code shows success.
|
||||
|
||||
* `-w`, `--warn`:
|
||||
Warn about improperly formatted checksum lines
|
||||
Emit a warning message about each improperly formatted checksum line.
|
||||
|
||||
**The following options are useful only benchmark purpose**
|
||||
|
||||
* `-b`:
|
||||
Benchmark mode. See [EXAMPLES](#EXAMPLES) for details.
|
||||
|
||||
* `-b#`:
|
||||
Specify ID of variant to be tested.
|
||||
Multiple variants can be selected, separated by a ',' comma.
|
||||
|
||||
* `-B`<BLOCKSIZE>:
|
||||
Only useful for benchmark mode (`-b`). See [EXAMPLES](#EXAMPLES) for details.
|
||||
<BLOCKSIZE> specifies benchmark mode's test data block size in bytes.
|
||||
@ -75,7 +89,7 @@ OPTIONS
|
||||
* `-i`<ITERATIONS>:
|
||||
Only useful for benchmark mode (`-b`). See [EXAMPLES](#EXAMPLES) for details.
|
||||
<ITERATIONS> specifies number of iterations in benchmark. Single iteration
|
||||
takes at least 2500 milliseconds. Default value is 3
|
||||
lasts approximately 1000 milliseconds. Default value is 3
|
||||
|
||||
EXIT STATUS
|
||||
-----------
|
||||
@ -100,13 +114,23 @@ Read xxHash sums from specific files and check them
|
||||
|
||||
$ xxhsum -c xyz.xxh32 qux.xxh64
|
||||
|
||||
Benchmark xxHash algorithm for 16384 bytes data in 10 times. `xxhsum`
|
||||
benchmarks xxHash algorithm for 32-bit and 64-bit and output results to
|
||||
standard output. First column means algorithm, second column is source data
|
||||
size in bytes, last column means hash generation speed in mega-bytes per
|
||||
seconds.
|
||||
Benchmark xxHash algorithm.
|
||||
By default, `xxhsum` benchmarks xxHash main variants
|
||||
on a synthetic sample of 100 KB,
|
||||
and print results into standard output.
|
||||
The first column is the algorithm,
|
||||
the second column is the source data size in bytes,
|
||||
the third column is the number of hashes generated per second (throughput),
|
||||
and finally the last column translates speed in megabytes per second.
|
||||
|
||||
$ xxhsum -b -i10 -B16384
|
||||
$ xxhsum -b
|
||||
|
||||
In the following example,
|
||||
the sample to hash is set to 16384 bytes,
|
||||
the variants to be benched are selected by their IDs,
|
||||
and each benchmark test is repeated 10 times, for increased accuracy.
|
||||
|
||||
$ xxhsum -b1,2,3 -i10 -B16384
|
||||
|
||||
BUGS
|
||||
----
|
||||
|
2356
deps/xxHash/xxhsum.c
vendored
2356
deps/xxHash/xxhsum.c
vendored
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
* changes v6.2.1 -> v6.x.x
|
||||
|
||||
- Dependencies: Updated LZMA SDK from 19.00 to 21.02 alpha
|
||||
- Dependencies: Updated xxHash from 0.1.0 to v0.8.0 - Stable XXH3
|
||||
|
||||
* changes v6.2.0 -> v6.2.1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user