418 Commits

Author SHA1 Message Date
Pavel P
2b83bca869 Fix XXH_INLINE_ALL build
+ fix XXH_IPREF to use XXH_NAME2 for proper name concatenation
 + simplify XXH_NAMESPACE block (use XXH_IPREF instead of XXH_NAME2)
2025-11-23 23:26:29 +02:00
Olaf Bernstein
a60a8a7e2d add comments 2025-09-10 00:04:13 +02:00
Olaf Bernstein
d2d0624e6f cleanup RVV implementation 2025-09-09 23:51:14 +02:00
Yann Collet
d8820c9fd3 Merge pull request #1070 from BoBoDai/enhance_rvv_performance
enhance riscv-v implementation performance.
2025-09-09 13:19:34 -07:00
junbo.dai
fb0784698e refactor riscv-v implementation.
Co-authored-by: gong-flying <gongxiaofei24@iscas.ac.cn>
2025-09-09 23:46:20 +08:00
junbo.dai
87b712ade8 enhance riscv-v implementation performance.
Co-authored-by: gong-flying <gongxiaofei24@iscas.ac.cn>
2025-09-09 23:03:43 +08:00
Yann Collet
55d9c43608 Merge pull request #1049 from zijianli1234/dev
add riscv rvv ci
2025-07-19 13:27:00 -08:00
YexuanXiao
76ce994c72 use the actual C23 __STDC_VERSION__ value 2025-07-20 04:07:10 +08:00
ZijianLi
bc5ae3b634 fix error: cast increases required alignment of target type 2025-06-20 22:16:34 +08:00
Yann Collet
4f43b71778 small optimization when streaming small quantities
described in #1011 by @aleksazr as point 2:
this optimization avoids copying accumulators
when there is not enough data to compute them anyway.
Seems effective on MSVC.

Such a scenario implies streaming, and receiving very little data per invocation.
2025-06-19 15:29:10 -07:00
Yann Collet
ee34939dee Merge pull request #1013 from lassipulkkinen/unaligned_read_may_alias
Use may_alias with unaligned reads to fix miscompilation on GCC
2025-06-18 16:52:07 -07:00
Yann Collet
a83692aaf1 Merge pull request #1043 from zijianli1234/dev
Add RVV Optimizations for RISC-V Architecture Platforms
2025-06-15 17:35:30 -07:00
Yann Collet
2c28ba829e use a different work around when no _mm_set_epi64x() is available
should fix visual /W4 warnings
2025-06-15 22:23:12 +00:00
Zijian
0d7465ea4f Add XXH3_initCustomSecret_rvv func 2025-06-13 18:33:13 +08:00
Zijian
2973489afa Add RISC-V RVV implementation 2025-06-11 20:27:33 +08:00
Yann Collet
41fea3d9ac Merge pull request #1023 from Nicoshev/dev
Prefer NEON over SVE
2025-04-29 12:59:12 -07:00
Nicolas De Carli
5d3ed49c06 Prefer NEON over SVE
We've observed the NEON implementation perform 25% to 40% better than the SVE one.

aarch64 builds will now prefer the NEON variation instead of the SVE one.

The SVE version can still be used by explicitly defining XXH_SVE
2025-04-28 11:47:01 -04:00
musvaage
2be8ba6cd1 typos 2025-04-25 09:07:49 -05:00
Lassi Pulkkinen
febebd1505 Use may_alias with unaligned reads to fix miscompilation on GCC
When XXH_FORCE_MEMORY_ACCESS==1, which is the default on supported
compilers unlike stated in the README, a strict aliasing violation
occurs in XXH_read64, resulting in miscompilation on GCC (but not Clang)
in some oddly specific circumstances.

The following code reproduces the problem on x86_64 GCC 14.2.1 when
compiled with -O3:

	#define XXH_INLINE_ALL

	#include <inttypes.h>
	#include <stdio.h>
	#include <xxhash.h>

	int main() {
		// it seems this has to be exactly 24 bytes.
		union {
			char x[24];
			// force 8-byte alignment without making
			// aliasable with uint64_t.
			void *y[3];
		} data = {.x = "garblegarblegarblegarble"};
		uint64_t hash = XXH64(&data, sizeof(data), 0);
		printf("%016"PRIx64"\n", hash);
		return 0;
	}

A bogus -Wuninitialized warning is produced if enabled, and the
resulting program outputs an incorrect hash.

While this definitely looks like a compiler bug in some ways, I see no
reason to assume aligned(1) alone should excempt the type from aliasing
restrictions regardless, and adding may_alias does fix the problem.

The separate strict aliasing bug when XXH_FORCE_ALIGN_CHECK==1,
discussed in #383, still remains.
2025-02-14 00:26:22 +02:00
Yann Collet
9998b5dddb allow removal of extern "C" guards in C++ mode
using new build macro XXH_NO_EXTERNC_GUARD
2025-01-28 18:33:38 -08:00
Yann Collet
eaffecc777 use macro instead of static function 2025-01-28 14:55:11 -08:00
Yann Collet
9376b76413 fix function signature 2025-01-28 14:47:58 -08:00
Yann Collet
99ed11175e makes it possible to redirect memcpy / memset / memcmp
to user-selectable symbols or functions
at compiler time, using build macros.
2025-01-28 14:39:37 -08:00
Yann Collet
e4e33f1f54 Merge pull request #1000 from pps83/dev-x64test
Use _M_X64 only without mixing with _M_AMD64
2025-01-23 16:58:31 -08:00
Yann Collet
4a7c46d613 fix doxygen documentation 2025-01-22 10:34:03 -08:00
Yann Collet
71e797bd8c add XXH_NOESCAPE 2025-01-21 20:55:25 -08:00
Yann Collet
c3e587a1ca attempt to silence a recent ubsan warning with code reorganization
apparently, UBSAN uses the prototype of the inner inlined function
instead of the outer shell of the function.
Let's see if one indirection level is enough to fix this.
2025-01-21 17:28:25 -08:00
Pavel P
a42b007b06 Use _M_X64 only without mixing with _M_AMD64 2025-01-21 02:26:34 +02:00
24bit-xjkp
7d6bd4ea09 feat(xsum): Display which mode is complied in the welcome message for LoongArch
1. Display the mode which is used as below:
"loongarch64 + lasx" -> LoongArch64 platform with LoongArch Advanced SIMD Extension
"loongarch64 + lsx"  -> LoongArch64 platform with LoongArch SIMD Extension
"loongarch64"        -> LoongArch64 platform, use scalar implement
2. Align the define in xxhash.h
2025-01-13 11:30:39 +08:00
24bit-xjkp
63e083c539 feat(xxhash3): Support LASX instruction set and refactor LSX implement
1. Use __lsx_vmul_d dircetly instead of using 2 32-bit multiply to emulate a 64-bit multiply.
2. Add LASX support.
2025-01-12 19:33:18 +08:00
easyaspi314
a8d6ff0e13 Extract finalization from XXH3 hashLong 2024-12-27 17:37:17 -08:00
Yann Collet
4dd799c922 fix static analyzer warnings
they are suspicious that some tests on unsigned values might wrap around.
They should not, but let's write these branches differently to also cover these cases.
2024-12-27 17:15:50 -08:00
easyaspi314
bca2d275b2 Modernize XXH32/XXH64
- Fix the state structs to use unsigned char, update names
 - Extract the algorithm steps into inline subroutines
 - Fix a theoretical integer overflow bug
 - Reroll XXH64 on 32-bit (it is going to run like crap anyway)
2024-12-27 16:28:26 -08:00
Yann Collet
5a8de81527 make XXH_VECTOR values more accessible
via #include "xxhash.h"
to fix double-include issues in xsum_arch.c
2024-12-26 16:10:04 -08:00
Yann Collet
cfd77237e6 updated doc 2024-12-26 16:02:40 -08:00
Yann Collet
c5a6a14676 only enforce inlining of XXH64_finalize() when XXH_INLINE_ALL is enabled 2024-12-05 00:44:07 -05:00
Yann Collet
e876423360 fixed XXH64_finalize() not being inlined
even though `XXH_INLINE_ALL` is set
on `gcc-11`.
2024-12-04 11:13:54 -05:00
Lin Runze
e7c94efe45 Add LoongArch SX SIMD extenstion implementation 2024-12-03 03:49:06 +08:00
Cristian Rodríguez
a8700688cf add GCC >=15 __builtin_stdc_rotate_left suppor to rotl
GCC does not support the clang builtins but does have
type generic, type-checking __builtin_stdc_rotate_left.

The only advantage of this is that the builtin evaluates the arguments
only once.
2024-10-30 16:10:30 -03:00
Yann Collet
8ffd354cdf circumvent Visual Studio 2019 "partial" support of C11
use _Alignas() instead, to not rely on including <stdalign.h>
since some versions of VS2019 do not provide it
despite claiming C11 compliance.
2024-10-03 16:14:43 -07:00
Yann Collet
984fb574d3 reorganize README build modifier section
introduce a clearly labelled "Binary size control" paragraph
following #947.
2024-05-26 20:54:13 -07:00
Yann Collet
9f465f1ea9 Merge pull request #939 from Cyan4973/detect894
updated internal check in xxhsum
2024-05-07 20:20:09 -07:00
Yann Collet
d622b4fbb1 updated documentation of XXH3_64bits_reset_withSecretandSeed() 2024-05-07 18:24:44 -07:00
Yann Collet
92d283916d update documentation of XXH3_128bits_withSecretandSeed()
to reflect #894
2024-05-07 18:21:56 -07:00
Yann Collet
02fe5d152a update version number to v0.8.3
reflecting the change for results produced by XXH3_128bits_withSecretandSeed() for the specific case of `seed == 0` and `len < 240`.
2024-05-07 18:21:56 -07:00
Yann Collet
bd51be8d1e updated internal check in xxhsum
to catch bugs such as #894
2024-05-07 18:16:57 -07:00
Yann Collet
a9b2f18115 Merge pull request #894 from hltj/dev
Fix a typo that cause inconsistent hash between streaming and stateless way for XXH3 128-bit variant with custom secret and seed 0
2024-05-07 16:18:32 -07:00
Yann Collet
5930eb43f3 Merge pull request #931 from pps83/dev-win32-sheck
Correct check for Windows compilation
2024-05-07 15:31:17 -07:00
Carl Rosdahl
cb34fc944f underscore attributes 2024-04-15 12:01:21 +02:00
Pavel P
b54324acee Correct check for Windows compilation
`_WIN32` is the proper check for compilation for Windows. `WIN32` is defined when `Windows.h` is included or could be defined by some projects
2024-04-01 22:06:02 +02:00