/usr/share/doc/libfarmhash-dev/examples/basics.cc is in libfarmhash-dev 0~20170626-g23eecfb-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | // Building blocks for hash functions
// std::swap() was in <algorithm> but is in <utility> from C++11 on.
#if !FARMHASH_CAN_USE_CXX11
#include <algorithm>
#endif
#undef PERMUTE3
#define PERMUTE3(a, b, c) do { std::swap(a, b); std::swap(a, c); } while (0)
namespace NAMESPACE_FOR_HASH_FUNCTIONS {
// Some primes between 2^63 and 2^64 for various uses.
static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
static const uint64_t k1 = 0xb492b66fbe98f273ULL;
static const uint64_t k2 = 0x9ae16a3b2f90404fULL;
// Magic numbers for 32-bit hashing. Copied from Murmur3.
static const uint32_t c1 = 0xcc9e2d51;
static const uint32_t c2 = 0x1b873593;
// A 32-bit to 32-bit integer hash copied from Murmur3.
STATIC_INLINE uint32_t fmix(uint32_t h)
{
h ^= h >> 16;
h *= 0x85ebca6b;
h ^= h >> 13;
h *= 0xc2b2ae35;
h ^= h >> 16;
return h;
}
STATIC_INLINE uint32_t Mur(uint32_t a, uint32_t h) {
// Helper from Murmur3 for combining two 32-bit values.
a *= c1;
a = Rotate32(a, 17);
a *= c2;
h ^= a;
h = Rotate32(h, 19);
return h * 5 + 0xe6546b64;
}
template <typename T> STATIC_INLINE T DebugTweak(T x) {
if (debug_mode) {
if (sizeof(x) == 4) {
x = ~Bswap32(x * c1);
} else {
x = ~Bswap64(x * k1);
}
}
return x;
}
template <> uint128_t DebugTweak(uint128_t x) {
if (debug_mode) {
uint64_t y = DebugTweak(Uint128Low64(x));
uint64_t z = DebugTweak(Uint128High64(x));
y += z;
z += y;
x = Uint128(y, z * k1);
}
return x;
}
} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
using namespace std;
using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
|