abseil-cpp/absl/hash/internal/hash.cc
Go to the documentation of this file.
1 // Copyright 2018 The Abseil Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "absl/hash/internal/hash.h"
16 
17 namespace absl {
19 namespace hash_internal {
20 
22  uint64_t state, const unsigned char* first, size_t len) {
23  while (len >= PiecewiseChunkSize()) {
24  state = Mix(state,
25  hash_internal::CityHash32(reinterpret_cast<const char*>(first),
29  }
30  // Handle the remainder.
32  std::integral_constant<int, 4>{});
33 }
34 
36  uint64_t state, const unsigned char* first, size_t len) {
37  while (len >= PiecewiseChunkSize()) {
41  }
42  // Handle the remainder.
44  std::integral_constant<int, 8>{});
45 }
46 
47 ABSL_CONST_INIT const void* const MixingHashState::kSeed = &kSeed;
48 
49 // The salt array used by LowLevelHash. This array is NOT the mechanism used to
50 // make absl::Hash non-deterministic between program invocations. See `Seed()`
51 // for that mechanism.
52 //
53 // Any random values are fine. These values are just digits from the decimal
54 // part of pi.
55 // https://en.wikipedia.org/wiki/Nothing-up-my-sleeve_number
56 constexpr uint64_t kHashSalt[5] = {
57  uint64_t{0x243F6A8885A308D3}, uint64_t{0x13198A2E03707344},
58  uint64_t{0xA4093822299F31D0}, uint64_t{0x082EFA98EC4E6C89},
59  uint64_t{0x452821E638D01377},
60 };
61 
63  size_t len) {
64  return LowLevelHash(data, len, Seed(), kHashSalt);
65 }
66 
67 } // namespace hash_internal
69 } // namespace absl
absl::hash_internal::MixingHashState::CombineContiguousImpl
static uint64_t CombineContiguousImpl(uint64_t state, const unsigned char *first, size_t len, std::integral_constant< int, 4 >)
Definition: abseil-cpp/absl/hash/internal/hash.h:1151
absl::hash_internal::MixingHashState::CombineLargeContiguousImpl64
static uint64_t CombineLargeContiguousImpl64(uint64_t state, const unsigned char *first, size_t len)
Definition: abseil-cpp/absl/hash/internal/hash.cc:35
ABSL_CONST_INIT
#define ABSL_CONST_INIT
Definition: abseil-cpp/absl/base/attributes.h:716
absl::hash_internal::MixingHashState::CombineLargeContiguousImpl32
static uint64_t CombineLargeContiguousImpl32(uint64_t state, const unsigned char *first, size_t len)
Definition: abseil-cpp/absl/hash/internal/hash.cc:21
absl::hash_internal::MixingHashState::Seed
static ABSL_ATTRIBUTE_ALWAYS_INLINE uint64_t Seed()
Definition: abseil-cpp/absl/hash/internal/hash.h:1135
ABSL_NAMESPACE_END
#define ABSL_NAMESPACE_END
Definition: third_party/abseil-cpp/absl/base/config.h:171
ABSL_NAMESPACE_BEGIN
#define ABSL_NAMESPACE_BEGIN
Definition: third_party/abseil-cpp/absl/base/config.h:170
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
absl::hash_internal::data
static char data[kDataSize]
Definition: bloaty/third_party/abseil-cpp/absl/hash/internal/city_test.cc:32
absl::hash_internal::LowLevelHash
uint64_t LowLevelHash(const void *data, size_t len, uint64_t seed, const uint64_t salt[])
Definition: low_level_hash.cc:42
absl::hash_internal::MixingHashState::Hash64
static ABSL_ATTRIBUTE_ALWAYS_INLINE uint64_t Hash64(const unsigned char *data, size_t len)
Definition: abseil-cpp/absl/hash/internal/hash.h:1110
absl::hash_internal::PiecewiseChunkSize
constexpr size_t PiecewiseChunkSize()
Definition: abseil-cpp/absl/hash/internal/hash.h:67
absl::hash_internal::kHashSalt
constexpr uint64_t kHashSalt[5]
Definition: abseil-cpp/absl/hash/internal/hash.cc:56
absl::hash_internal::MixingHashState::kSeed
static const void *const kSeed
Definition: abseil-cpp/absl/hash/internal/hash.h:1145
first
StrT first
Definition: cxa_demangle.cpp:4884
state
Definition: bloaty/third_party/zlib/contrib/blast/blast.c:41
absl::hash_internal::MixingHashState::Mix
static ABSL_ATTRIBUTE_ALWAYS_INLINE uint64_t Mix(uint64_t state, uint64_t v)
Definition: abseil-cpp/absl/hash/internal/hash.h:1092
absl
Definition: abseil-cpp/absl/algorithm/algorithm.h:31
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
absl::hash_internal::MixingHashState::LowLevelHashImpl
static uint64_t LowLevelHashImpl(const unsigned char *data, size_t len)
Definition: abseil-cpp/absl/hash/internal/hash.cc:62
absl::hash_internal::CityHash32
uint32_t CityHash32(const char *s, size_t len)
Definition: abseil-cpp/absl/hash/internal/city.cc:124


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:00