diff options
author | somov <somov@yandex-team.ru> | 2022-02-10 16:45:47 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:47 +0300 |
commit | a5950576e397b1909261050b8c7da16db58f10b1 (patch) | |
tree | 7ba7677f6a4c3e19e2cefab34d16df2c8963b4d4 /contrib/libs/farmhash/farmhash_iface.cc | |
parent | 81eddc8c0b55990194e112b02d127b87d54164a9 (diff) | |
download | ydb-a5950576e397b1909261050b8c7da16db58f10b1.tar.gz |
Restoring authorship annotation for <somov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/farmhash/farmhash_iface.cc')
-rw-r--r-- | contrib/libs/farmhash/farmhash_iface.cc | 212 |
1 files changed, 106 insertions, 106 deletions
diff --git a/contrib/libs/farmhash/farmhash_iface.cc b/contrib/libs/farmhash/farmhash_iface.cc index a9c3ca77f2..0064662412 100644 --- a/contrib/libs/farmhash/farmhash_iface.cc +++ b/contrib/libs/farmhash/farmhash_iface.cc @@ -1,106 +1,106 @@ -#include "common.h" - -#include "farmhash_iface.h" - -#include <util/system/cpu_id.h> - -namespace NAMESPACE_FOR_HASH_FUNCTIONS { - -// BASIC STRING HASHING - -// Hash function for a byte array. See also Hash(), below. -// May change from time to time, may differ on different platforms, may differ -// depending on NDEBUG. -uint32_t Hash32(const char* s, size_t len) { - return DebugTweak( - (NX86::CachedHaveSSE41() & x86_64) ? farmhashnt::Hash32(s, len) : - (NX86::CachedHaveSSE42() & NX86::CachedHaveAES()) ? farmhashsu::Hash32(s, len) : - NX86::CachedHaveSSE42() ? farmhashsa::Hash32(s, len) : - farmhashmk::Hash32(s, len)); -} - -// Hash function for a byte array. For convenience, a 32-bit seed is also -// hashed into the result. -// May change from time to time, may differ on different platforms, may differ -// depending on NDEBUG. -uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) { - return DebugTweak( - (NX86::CachedHaveSSE41() & x86_64) ? farmhashnt::Hash32WithSeed(s, len, seed) : - (NX86::CachedHaveSSE42() & NX86::CachedHaveAES()) ? farmhashsu::Hash32WithSeed(s, len, seed) : - NX86::CachedHaveSSE42() ? farmhashsa::Hash32WithSeed(s, len, seed) : - farmhashmk::Hash32WithSeed(s, len, seed)); -} - -// Hash function for a byte array. For convenience, a 64-bit seed is also -// hashed into the result. See also Hash(), below. -// May change from time to time, may differ on different platforms, may differ -// depending on NDEBUG. -uint64_t Hash64(const char* s, size_t len) { - return DebugTweak( - (NX86::CachedHaveSSE42() & x86_64) ? - farmhashte::Hash64(s, len) : - farmhashxo::Hash64(s, len)); -} - -// Hash function for a byte array. -// May change from time to time, may differ on different platforms, may differ -// depending on NDEBUG. -size_t Hash(const char* s, size_t len) { - return sizeof(size_t) == 8 ? Hash64(s, len) : Hash32(s, len); -} - -// Hash function for a byte array. For convenience, a 64-bit seed is also -// hashed into the result. -// May change from time to time, may differ on different platforms, may differ -// depending on NDEBUG. -uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) { - return DebugTweak(farmhashna::Hash64WithSeed(s, len, seed)); -} - -// Hash function for a byte array. For convenience, two seeds are also -// hashed into the result. -// May change from time to time, may differ on different platforms, may differ -// depending on NDEBUG. -uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1) { - return DebugTweak(farmhashna::Hash64WithSeeds(s, len, seed0, seed1)); -} - -// Hash function for a byte array. -// May change from time to time, may differ on different platforms, may differ -// depending on NDEBUG. -uint128_t Hash128(const char* s, size_t len) { - return DebugTweak(farmhashcc::Fingerprint128(s, len)); -} - -// Hash function for a byte array. For convenience, a 128-bit seed is also -// hashed into the result. -// May change from time to time, may differ on different platforms, may differ -// depending on NDEBUG. -uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed) { - return DebugTweak(farmhashcc::CityHash128WithSeed(s, len, seed)); -} - -// BASIC NON-STRING HASHING - -// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions) - -// Fingerprint function for a byte array. Most useful in 32-bit binaries. -uint32_t Fingerprint32(const char* s, size_t len) { - return farmhashmk::Hash32(s, len); -} - -// Fingerprint function for a byte array. -uint64_t Fingerprint64(const char* s, size_t len) { - return farmhashna::Hash64(s, len); -} - -// Fingerprint function for a byte array. -uint128_t Fingerprint128(const char* s, size_t len) { - return farmhashcc::Fingerprint128(s, len); -} - -// Older and still available but perhaps not as fast as the above: -// farmhashns::Hash32{,WithSeed}() - -} // namespace NAMESPACE_FOR_HASH_FUNCTIONS - +#include "common.h" + +#include "farmhash_iface.h" + +#include <util/system/cpu_id.h> + +namespace NAMESPACE_FOR_HASH_FUNCTIONS { + +// BASIC STRING HASHING + +// Hash function for a byte array. See also Hash(), below. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint32_t Hash32(const char* s, size_t len) { + return DebugTweak( + (NX86::CachedHaveSSE41() & x86_64) ? farmhashnt::Hash32(s, len) : + (NX86::CachedHaveSSE42() & NX86::CachedHaveAES()) ? farmhashsu::Hash32(s, len) : + NX86::CachedHaveSSE42() ? farmhashsa::Hash32(s, len) : + farmhashmk::Hash32(s, len)); +} + +// Hash function for a byte array. For convenience, a 32-bit seed is also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) { + return DebugTweak( + (NX86::CachedHaveSSE41() & x86_64) ? farmhashnt::Hash32WithSeed(s, len, seed) : + (NX86::CachedHaveSSE42() & NX86::CachedHaveAES()) ? farmhashsu::Hash32WithSeed(s, len, seed) : + NX86::CachedHaveSSE42() ? farmhashsa::Hash32WithSeed(s, len, seed) : + farmhashmk::Hash32WithSeed(s, len, seed)); +} + +// Hash function for a byte array. For convenience, a 64-bit seed is also +// hashed into the result. See also Hash(), below. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint64_t Hash64(const char* s, size_t len) { + return DebugTweak( + (NX86::CachedHaveSSE42() & x86_64) ? + farmhashte::Hash64(s, len) : + farmhashxo::Hash64(s, len)); +} + +// Hash function for a byte array. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +size_t Hash(const char* s, size_t len) { + return sizeof(size_t) == 8 ? Hash64(s, len) : Hash32(s, len); +} + +// Hash function for a byte array. For convenience, a 64-bit seed is also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) { + return DebugTweak(farmhashna::Hash64WithSeed(s, len, seed)); +} + +// Hash function for a byte array. For convenience, two seeds are also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1) { + return DebugTweak(farmhashna::Hash64WithSeeds(s, len, seed0, seed1)); +} + +// Hash function for a byte array. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint128_t Hash128(const char* s, size_t len) { + return DebugTweak(farmhashcc::Fingerprint128(s, len)); +} + +// Hash function for a byte array. For convenience, a 128-bit seed is also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed) { + return DebugTweak(farmhashcc::CityHash128WithSeed(s, len, seed)); +} + +// BASIC NON-STRING HASHING + +// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions) + +// Fingerprint function for a byte array. Most useful in 32-bit binaries. +uint32_t Fingerprint32(const char* s, size_t len) { + return farmhashmk::Hash32(s, len); +} + +// Fingerprint function for a byte array. +uint64_t Fingerprint64(const char* s, size_t len) { + return farmhashna::Hash64(s, len); +} + +// Fingerprint function for a byte array. +uint128_t Fingerprint128(const char* s, size_t len) { + return farmhashcc::Fingerprint128(s, len); +} + +// Older and still available but perhaps not as fast as the above: +// farmhashns::Hash32{,WithSeed}() + +} // namespace NAMESPACE_FOR_HASH_FUNCTIONS + |