summaryrefslogtreecommitdiffstats
path: root/third_party/rust
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust')
-rw-r--r--third_party/rust/ahash/.cargo-checksum.json2
-rw-r--r--third_party/rust/ahash/Cargo.toml61
-rw-r--r--third_party/rust/ahash/build.rs4
-rw-r--r--third_party/rust/ahash/src/aes_hash.rs13
-rw-r--r--third_party/rust/ahash/src/hash_quality_test.rs36
-rw-r--r--third_party/rust/ahash/src/random_state.rs7
6 files changed, 99 insertions, 24 deletions
diff --git a/third_party/rust/ahash/.cargo-checksum.json b/third_party/rust/ahash/.cargo-checksum.json
index 8c7a101059..d2fa45cb86 100644
--- a/third_party/rust/ahash/.cargo-checksum.json
+++ b/third_party/rust/ahash/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"31399b9babab52fabfe71f52ffe38fef0d3d894fdd5829f84a4e69b031f463c9","FAQ.md":"9eb41898523ee209a0a937f9bcb78afe45ad55ca0556f8a4d4063558098f6d1e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"ff8f68cb076caf8cefe7a6430d4ac086ce6af2ca8ce2c4e5a2004d4552ef52a2","README.md":"72185284f100e149998fe5301f70489e617cc4415b51cc77e967c63c6e970a67","build.rs":"123b322034273b5aa1b4934d84c277fef279afd533ecfb44831a3715e9887fcd","rustfmt.toml":"e090969e99df9360705680cc0097cfaddae10c22dc2e01470592cf3b9787fd36","src/aes_hash.rs":"04483498a0d86e3ab099e22f734ea6fcac384b92f349bd310456856bf6a9a5e2","src/convert.rs":"f0e78840046493d0679a9ec077c8164cf57cf30d5e852b11bfadfdd996d29bd1","src/fallback_hash.rs":"ec00691bd555c69f7446afe893b6631cb84207cb7b512260dec8ef488e1905f3","src/hash_map.rs":"ed0c79c41c2218ad9591a585670a2b9b983807c9725880b780138a44c126cbfd","src/hash_quality_test.rs":"6c1fea90a38dc7b2ac5b2fa6e44a565e0c3385c72df6e87231401f920912d053","src/hash_set.rs":"dc3d33e290aad62457ab1f5e64d3e33eb79e28c9468bfc8686339f0bbd8b19aa","src/lib.rs":"9fec7d1d412e414231c9b929081b1daa7c3b788a9f91eedd79a55efdf5d0d291","src/operations.rs":"10772e65b8b7106f195428c5eb8dbf6cbd49dd5a2165ac750e54af5995210f88","src/random_state.rs":"b7981967ec5ecbff04d166b5e05c59c386062b4de3b36816f3c98ef284372f63","src/specialize.rs":"38d3b56ef4f264d564f48dbcb8ac137928babf90635090c9771c1a62140d1f30","tests/bench.rs":"0851dffebaffd7a437f6f9946ed5e03a957e9a6eb0da7911451af58778c411ec","tests/map_tests.rs":"e0f155f964dd965740b072ee1da110a8c6ef34491c95219f7c89064112c7840f","tests/nopanic.rs":"3363675c4c1a197b86604a0aebbe958fb5ec7c01a414fbfd70e9eb8a29707400"},"package":"fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"} \ No newline at end of file
+{"files":{"Cargo.toml":"a519809f46c9aad28d6c48748f330fe31e05029d234b6d1743522ec403441744","FAQ.md":"9eb41898523ee209a0a937f9bcb78afe45ad55ca0556f8a4d4063558098f6d1e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"ff8f68cb076caf8cefe7a6430d4ac086ce6af2ca8ce2c4e5a2004d4552ef52a2","README.md":"72185284f100e149998fe5301f70489e617cc4415b51cc77e967c63c6e970a67","build.rs":"f80cb1cdb731a63d16513f1f0b0871d9c077d2c6bf2312af40a202f9c0fefe49","rustfmt.toml":"e090969e99df9360705680cc0097cfaddae10c22dc2e01470592cf3b9787fd36","src/aes_hash.rs":"0b11ce066931396222d2bed7eff678fdd7c8351819485efb721f62a30551866b","src/convert.rs":"f0e78840046493d0679a9ec077c8164cf57cf30d5e852b11bfadfdd996d29bd1","src/fallback_hash.rs":"ec00691bd555c69f7446afe893b6631cb84207cb7b512260dec8ef488e1905f3","src/hash_map.rs":"ed0c79c41c2218ad9591a585670a2b9b983807c9725880b780138a44c126cbfd","src/hash_quality_test.rs":"61695e5cac46ea25021a9d04199fb00c513e0c0c9c0f67aca0c647b9d2f7dd5a","src/hash_set.rs":"dc3d33e290aad62457ab1f5e64d3e33eb79e28c9468bfc8686339f0bbd8b19aa","src/lib.rs":"9fec7d1d412e414231c9b929081b1daa7c3b788a9f91eedd79a55efdf5d0d291","src/operations.rs":"10772e65b8b7106f195428c5eb8dbf6cbd49dd5a2165ac750e54af5995210f88","src/random_state.rs":"ce9689147659efa975887debe1481daddca09386ea8e1d5b4ee90ebeda6c8745","src/specialize.rs":"38d3b56ef4f264d564f48dbcb8ac137928babf90635090c9771c1a62140d1f30","tests/bench.rs":"0851dffebaffd7a437f6f9946ed5e03a957e9a6eb0da7911451af58778c411ec","tests/map_tests.rs":"e0f155f964dd965740b072ee1da110a8c6ef34491c95219f7c89064112c7840f","tests/nopanic.rs":"3363675c4c1a197b86604a0aebbe958fb5ec7c01a414fbfd70e9eb8a29707400"},"package":"891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9"} \ No newline at end of file
diff --git a/third_party/rust/ahash/Cargo.toml b/third_party/rust/ahash/Cargo.toml
index b412f79166..5830a500d9 100644
--- a/third_party/rust/ahash/Cargo.toml
+++ b/third_party/rust/ahash/Cargo.toml
@@ -3,43 +3,63 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies
+# to registry (e.g., crates.io) dependencies.
#
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "ahash"
-version = "0.7.6"
+version = "0.7.8"
authors = ["Tom Kaitchuck <Tom.Kaitchuck@gmail.com>"]
build = "./build.rs"
-exclude = ["/smhasher", "/benchmark_tools"]
+exclude = [
+ "/smhasher",
+ "/benchmark_tools",
+]
description = "A non-cryptographic hash function using AES-NI for high performance"
documentation = "https://docs.rs/ahash"
readme = "README.md"
-keywords = ["hash", "hasher", "hashmap", "aes", "no-std"]
-categories = ["algorithms", "data-structures", "no-std"]
+keywords = [
+ "hash",
+ "hasher",
+ "hashmap",
+ "aes",
+ "no-std",
+]
+categories = [
+ "algorithms",
+ "data-structures",
+ "no-std",
+]
license = "MIT OR Apache-2.0"
repository = "https://github.com/tkaitchuck/ahash"
+
[package.metadata.docs.rs]
features = ["std"]
-rustc-args = ["-C", "target-feature=+aes"]
-rustdoc-args = ["-C", "target-feature=+aes"]
+rustc-args = [
+ "-C",
+ "target-feature=+aes",
+]
+rustdoc-args = [
+ "-C",
+ "target-feature=+aes",
+]
+
[profile.bench]
opt-level = 3
lto = "fat"
codegen-units = 1
-debug = false
+debug = 0
debug-assertions = false
[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
-debug = false
+debug = 0
debug-assertions = false
[profile.test]
@@ -63,6 +83,7 @@ harness = false
name = "map"
path = "tests/map_tests.rs"
harness = false
+
[dev-dependencies.criterion]
version = "0.3.2"
@@ -86,13 +107,19 @@ version = "4.0"
[dev-dependencies.serde_json]
version = "1.0.59"
+
[build-dependencies.version_check]
version = "0.9"
[features]
+atomic-polyfill = [
+ "dep:atomic-polyfill",
+ "once_cell/atomic-polyfill",
+]
compile-time-rng = ["const-random"]
default = ["std"]
std = []
+
[target."cfg(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\"))".dependencies.const-random]
version = "0.1.12"
optional = true
@@ -103,10 +130,16 @@ version = "0.2.3"
[target."cfg(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\"))".dependencies.serde]
version = "1.0.117"
optional = true
+
[target."cfg(not(all(target_arch = \"arm\", target_os = \"none\")))".dependencies.once_cell]
-version = "1.8"
+version = "1.13.1"
features = ["alloc"]
default-features = false
+
+[target."cfg(not(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\")))".dependencies.atomic-polyfill]
+version = "1.0.1"
+optional = true
+
[target."cfg(not(any(target_os = \"linux\", target_os = \"android\", target_os = \"windows\", target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"dragonfly\", target_os = \"solaris\", target_os = \"illumos\", target_os = \"fuchsia\", target_os = \"redox\", target_os = \"cloudabi\", target_os = \"haiku\", target_os = \"vxworks\", target_os = \"emscripten\", target_os = \"wasi\")))".dependencies.const-random]
version = "0.1.12"
optional = true
diff --git a/third_party/rust/ahash/build.rs b/third_party/rust/ahash/build.rs
index 8be4964e52..6aba02526b 100644
--- a/third_party/rust/ahash/build.rs
+++ b/third_party/rust/ahash/build.rs
@@ -7,7 +7,9 @@ fn main() {
if let Some(channel) = version_check::Channel::read() {
if channel.supports_features() {
println!("cargo:rustc-cfg=feature=\"specialize\"");
- println!("cargo:rustc-cfg=feature=\"stdsimd\"");
+ if version_check::Version::read().map_or(false, |v| v.at_most("1.77.9")) {
+ println!("cargo:rustc-cfg=feature=\"stdsimd\"");
+ }
}
}
let os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS was not set");
diff --git a/third_party/rust/ahash/src/aes_hash.rs b/third_party/rust/ahash/src/aes_hash.rs
index 1c98582cee..7e619b520b 100644
--- a/third_party/rust/ahash/src/aes_hash.rs
+++ b/third_party/rust/ahash/src/aes_hash.rs
@@ -170,10 +170,10 @@ impl Hasher for AHasher {
let tail = data.read_last_u128x4();
let mut current: [u128; 4] = [self.key; 4];
current[0] = aesenc(current[0], tail[0]);
- current[1] = aesenc(current[1], tail[1]);
+ current[1] = aesdec(current[1], tail[1]);
current[2] = aesenc(current[2], tail[2]);
- current[3] = aesenc(current[3], tail[3]);
- let mut sum: [u128; 2] = [self.key, self.key];
+ current[3] = aesdec(current[3], tail[3]);
+ let mut sum: [u128; 2] = [self.key, !self.key];
sum[0] = add_by_64s(sum[0].convert(), tail[0].convert()).convert();
sum[1] = add_by_64s(sum[1].convert(), tail[1].convert()).convert();
sum[0] = shuffle_and_add(sum[0], tail[2]);
@@ -190,8 +190,9 @@ impl Hasher for AHasher {
sum[1] = shuffle_and_add(sum[1], blocks[3]);
data = rest;
}
- self.hash_in_2(aesenc(current[0], current[1]), aesenc(current[2], current[3]));
- self.hash_in(add_by_64s(sum[0].convert(), sum[1].convert()).convert());
+ self.hash_in_2(current[0], current[1]);
+ self.hash_in_2(current[2], current[3]);
+ self.hash_in_2(sum[0], sum[1]);
} else {
//len 33-64
let (head, _) = data.read_u128x2();
@@ -215,7 +216,7 @@ impl Hasher for AHasher {
fn finish(&self) -> u64 {
let combined = aesdec(self.sum, self.enc);
let result: [u64; 2] = aesenc(aesenc(combined, self.key), combined).convert();
- result[0]
+ result[1]
}
}
diff --git a/third_party/rust/ahash/src/hash_quality_test.rs b/third_party/rust/ahash/src/hash_quality_test.rs
index 4cd3156afe..17228d4716 100644
--- a/third_party/rust/ahash/src/hash_quality_test.rs
+++ b/third_party/rust/ahash/src/hash_quality_test.rs
@@ -1,5 +1,5 @@
use core::hash::{Hash, Hasher};
-use std::collections::HashMap;
+use std::collections::{HashMap};
fn assert_sufficiently_different(a: u64, b: u64, tolerance: i32) {
let (same_byte_count, same_nibble_count) = count_same_bytes_and_nibbles(a, b);
@@ -326,6 +326,28 @@ fn test_length_extension<T: Hasher>(hasher: impl Fn(u128, u128) -> T) {
}
}
+fn test_sparse<T: Hasher>(hasher: impl Fn() -> T) {
+ let mut buf = [0u8; 256];
+ let mut hashes = HashMap::new();
+ for idx_1 in 0..256 {
+ for idx_2 in idx_1+1..256 {
+ for value_1 in [1, 2, 4, 8, 16, 32, 64, 128] {
+ for value_2 in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 16, 17, 18, 20, 24, 31, 32, 33, 48, 64, 96, 127, 128, 129, 192, 254, 255] {
+ buf[idx_1] = value_1;
+ buf[idx_2] = value_2;
+ let hash_value = hash_with(&buf, &mut hasher());
+ let keys = hashes.entry(hash_value).or_insert(Vec::new());
+ keys.push((idx_1, value_1, idx_2, value_2));
+ buf[idx_1] = 0;
+ buf[idx_2] = 0;
+ }
+ }
+ }
+ }
+ hashes.retain(|_key, value| value.len() != 1);
+ assert_eq!(0, hashes.len(), "Collision with: {:?}", hashes);
+}
+
#[cfg(test)]
mod fallback_tests {
use crate::fallback_hash::*;
@@ -392,6 +414,12 @@ mod fallback_tests {
fn fallback_length_extension() {
test_length_extension(|a, b| AHasher::new_with_keys(a, b));
}
+
+ #[test]
+ fn test_no_sparse_collisions() {
+ test_sparse(|| AHasher::new_with_keys(0, 0));
+ test_sparse(|| AHasher::new_with_keys(1, 2));
+ }
}
///Basic sanity tests of the cypto properties of aHash.
@@ -480,4 +508,10 @@ mod aes_tests {
fn aes_length_extension() {
test_length_extension(|a, b| AHasher::test_with_keys(a, b));
}
+
+ #[test]
+ fn aes_no_sparse_collisions() {
+ test_sparse(|| AHasher::test_with_keys(0, 0));
+ test_sparse(|| AHasher::test_with_keys(1, 2));
+ }
}
diff --git a/third_party/rust/ahash/src/random_state.rs b/third_party/rust/ahash/src/random_state.rs
index c3628bf145..9ac2f3ec43 100644
--- a/third_party/rust/ahash/src/random_state.rs
+++ b/third_party/rust/ahash/src/random_state.rs
@@ -29,8 +29,13 @@ extern crate alloc;
#[cfg(feature = "std")]
extern crate std as alloc;
+#[cfg(feature = "atomic-polyfill")]
+use atomic_polyfill as atomic;
+#[cfg(not(feature = "atomic-polyfill"))]
+use core::sync::atomic;
+
use alloc::boxed::Box;
-use core::sync::atomic::{AtomicUsize, Ordering};
+use atomic::{AtomicUsize, Ordering};
#[cfg(not(all(target_arch = "arm", target_os = "none")))]
use once_cell::race::OnceBox;