Initial import (#2064142)

epel9
Aleksei Bavshin 3 years ago
parent a80d85ece8
commit bf4854ec5d
No known key found for this signature in database
GPG Key ID: 4F071603387A382A

3
.gitignore vendored

@ -0,0 +1,3 @@
*.crate
*.src.rpm
results_*/

@ -0,0 +1,4 @@
[fedora]
# The compat package for `digest` = 0.8 is not available in Fedora
unwanted-features =
digest

@ -0,0 +1,155 @@
# Generated by rust2rpm 21
%bcond_without check
%global crate twox-hash
Name: rust-%{crate}
Version: 1.6.2
Release: %autorelease
Summary: Rust implementation of the XXHash and XXH3 algorithms
# Upstream license specification: MIT
License: MIT
URL: https://crates.io/crates/twox-hash
Source: %{crates_source}
# Address test failures on non-x86 platforms
Patch0: https://github.com/shepmaster/twox-hash/pull/86.patch#/twox-hash-1.6.2-Support-big-endian-platforms.patch
Patch1: https://github.com/shepmaster/twox-hash/pull/87.patch#/twox-hash-1.6.2-Fix-XXH3-generic-fallback.patch
ExclusiveArch: %{rust_arches}
BuildRequires: rust-packaging >= 21
%global _description %{expand:
Rust implementation of the XXHash and XXH3 algorithms.}
%description %{_description}
%package -n %{crate}
Summary: %{summary}
%description -n %{crate} %{_description}
%files -n %{crate}
%license LICENSE.txt
%doc README.md
%{_bindir}/hash_file
%package devel
Summary: %{summary}
BuildArch: noarch
%description devel %{_description}
This package contains library source intended for building other packages which
use the "%{crate}" crate.
%files devel
%license %{crate_instdir}/LICENSE.txt
%doc %{crate_instdir}/README.md
%{crate_instdir}/
%package -n %{name}+default-devel
Summary: %{summary}
BuildArch: noarch
%description -n %{name}+default-devel %{_description}
This package contains library source intended for building other packages which
use the "default" feature of the "%{crate}" crate.
%files -n %{name}+default-devel
%ghost %{crate_instdir}/Cargo.toml
%package -n %{name}+digest_0_10-devel
Summary: %{summary}
BuildArch: noarch
%description -n %{name}+digest_0_10-devel %{_description}
This package contains library source intended for building other packages which
use the "digest_0_10" feature of the "%{crate}" crate.
%files -n %{name}+digest_0_10-devel
%ghost %{crate_instdir}/Cargo.toml
%package -n %{name}+digest_0_9-devel
Summary: %{summary}
BuildArch: noarch
%description -n %{name}+digest_0_9-devel %{_description}
This package contains library source intended for building other packages which
use the "digest_0_9" feature of the "%{crate}" crate.
%files -n %{name}+digest_0_9-devel
%ghost %{crate_instdir}/Cargo.toml
%package -n %{name}+rand-devel
Summary: %{summary}
BuildArch: noarch
%description -n %{name}+rand-devel %{_description}
This package contains library source intended for building other packages which
use the "rand" feature of the "%{crate}" crate.
%files -n %{name}+rand-devel
%ghost %{crate_instdir}/Cargo.toml
%package -n %{name}+serde-devel
Summary: %{summary}
BuildArch: noarch
%description -n %{name}+serde-devel %{_description}
This package contains library source intended for building other packages which
use the "serde" feature of the "%{crate}" crate.
%files -n %{name}+serde-devel
%ghost %{crate_instdir}/Cargo.toml
%package -n %{name}+serialize-devel
Summary: %{summary}
BuildArch: noarch
%description -n %{name}+serialize-devel %{_description}
This package contains library source intended for building other packages which
use the "serialize" feature of the "%{crate}" crate.
%files -n %{name}+serialize-devel
%ghost %{crate_instdir}/Cargo.toml
%package -n %{name}+std-devel
Summary: %{summary}
BuildArch: noarch
%description -n %{name}+std-devel %{_description}
This package contains library source intended for building other packages which
use the "std" feature of the "%{crate}" crate.
%files -n %{name}+std-devel
%ghost %{crate_instdir}/Cargo.toml
%prep
%autosetup -n %{crate}-%{version_no_tilde} -p1
%cargo_prep
%generate_buildrequires
%cargo_generate_buildrequires
%build
%cargo_build
%install
%cargo_install
%if %{with check}
%check
%cargo_test
%endif
%changelog
%autochangelog

@ -0,0 +1 @@
SHA512 (twox-hash-1.6.2.crate) = 8171cf6970f18143cf2bd186014fe5a72d3ec5b2cd1e718b45dbc94e5cb6bea1b2485a6f6332d52411ffb85d746266c408b3b3dbd6c7c18a98cc0dc953cc21b1

@ -0,0 +1,26 @@
From f085fe2e12321dcb5ecbb145ffde5c9c6fccd4aa Mon Sep 17 00:00:00 2001
From: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Date: Fri, 4 Mar 2022 15:06:31 +0100
Subject: [PATCH] Fix XXH3 generic fallback
The generic fallback code used on non-Intel platforms seems to
have a bug that makes the computed hashes different from the
SSE and AVX code pathes (and the test cases). This patch makes
the generic path also pass the tests.
---
src/xxh3.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/xxh3.rs b/src/xxh3.rs
index b793a521a..0ffc54189 100644
--- a/src/xxh3.rs
+++ b/src/xxh3.rs
@@ -754,7 +754,7 @@ mod generic {
let data_key1 = key1 ^ in1;
let data_key2 = key2 ^ in2;
acc[i] = acc[i].wrapping_add(mul32_to64(data_key1, data_key1 >> 32));
- acc[i + 1] = acc[i].wrapping_add(mul32_to64(data_key2, data_key2 >> 32));
+ acc[i + 1] = acc[i + 1].wrapping_add(mul32_to64(data_key2, data_key2 >> 32));
if acc_width == AccWidth::Acc128Bits {
acc[i] = acc[i].wrapping_add(in2);

@ -0,0 +1,78 @@
From 2fac078713ad979b8a56fcb5ccf5725d474c4325 Mon Sep 17 00:00:00 2001
From: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Date: Fri, 4 Mar 2022 15:01:20 +0100
Subject: [PATCH] Support big-endian platforms
When using the UnalignedBuffer mechanism to operate on
multiple input bytes at once, the resulting u32 or u64
needs to be byte-swapped on big-endian platforms.
---
src/sixty_four.rs | 12 ++++++------
src/thirty_two.rs | 10 +++++-----
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/sixty_four.rs b/src/sixty_four.rs
index 9bd351c15..c15158693 100644
--- a/src/sixty_four.rs
+++ b/src/sixty_four.rs
@@ -65,10 +65,10 @@ impl XxCore {
let mut v4 = self.v4;
for [n1, n2, n3, n4] in values {
- v1 = ingest_one_number(v1, n1);
- v2 = ingest_one_number(v2, n2);
- v3 = ingest_one_number(v3, n3);
- v4 = ingest_one_number(v4, n4);
+ v1 = ingest_one_number(v1, n1.to_le());
+ v2 = ingest_one_number(v2, n2.to_le());
+ v3 = ingest_one_number(v3, n3.to_le());
+ v4 = ingest_one_number(v4, n4.to_le());
}
self.v1 = v1;
@@ -221,7 +221,7 @@ impl XxHash64 {
let mut buffered_u64s = UnalignedBuffer::<u64>::new(self.buffer.data());
for buffered_u64 in &mut buffered_u64s {
- let mut k1 = buffered_u64.wrapping_mul(PRIME_2);
+ let mut k1 = buffered_u64.to_le().wrapping_mul(PRIME_2);
k1 = k1.rotate_left(31);
k1 = k1.wrapping_mul(PRIME_1);
hash ^= k1;
@@ -232,7 +232,7 @@ impl XxHash64 {
let mut buffered_u32s = UnalignedBuffer::<u32>::new(buffered_u64s.remaining());
for buffered_u32 in &mut buffered_u32s {
- let k1 = u64::from(buffered_u32).wrapping_mul(PRIME_1);
+ let k1 = u64::from(buffered_u32.to_le()).wrapping_mul(PRIME_1);
hash ^= k1;
hash = hash.rotate_left(23);
hash = hash.wrapping_mul(PRIME_2);
diff --git a/src/thirty_two.rs b/src/thirty_two.rs
index 86b2b1957..cfa44cdbc 100644
--- a/src/thirty_two.rs
+++ b/src/thirty_two.rs
@@ -70,10 +70,10 @@ impl XxCore {
let mut v4 = self.v4;
for [n1, n2, n3, n4] in values {
- v1 = ingest_one_number(v1, n1);
- v2 = ingest_one_number(v2, n2);
- v3 = ingest_one_number(v3, n3);
- v4 = ingest_one_number(v4, n4);
+ v1 = ingest_one_number(v1, n1.to_le());
+ v2 = ingest_one_number(v2, n2.to_le());
+ v3 = ingest_one_number(v3, n3.to_le());
+ v4 = ingest_one_number(v4, n4.to_le());
}
self.v1 = v1;
@@ -211,7 +211,7 @@ impl XxHash32 {
let mut buffered_u32s = UnalignedBuffer::<u32>::new(self.buffer.data());
for buffered_u32 in &mut buffered_u32s {
- let k1 = buffered_u32.wrapping_mul(PRIME_3);
+ let k1 = buffered_u32.to_le().wrapping_mul(PRIME_3);
hash = hash.wrapping_add(k1);
hash = hash.rotate_left(17);
hash = hash.wrapping_mul(PRIME_4);
Loading…
Cancel
Save