6 #ifndef IROHA_MURMUR_2_HPP 7 #define IROHA_MURMUR_2_HPP 12 static constexpr uint32_t __init__(uint32_t len) {
16 template <
typename __T>
17 static constexpr uint32_t __load__(__T &data, uint32_t offset) {
18 return data[offset + 0] | (data[offset + 1] << 8)
19 | (data[offset + 2] << 16) | (data[offset + 3] << 24);
22 static constexpr uint32_t __mul__(uint32_t val1, uint32_t val2) {
26 static constexpr uint32_t __sl__(uint32_t value, uint32_t count) {
27 return (value << count);
30 static constexpr uint32_t __sr__(uint32_t value, uint32_t count) {
31 return (value >> count);
34 static constexpr uint32_t __xor__(uint32_t h, uint32_t k) {
38 static constexpr uint32_t __xor_with_sr__(uint32_t k, uint32_t r) {
39 return __xor__(k, __sr__(k, r));
42 template <
typename __Type>
43 static constexpr uint32_t __proc__(__Type &data,
53 __xor__(__mul__(h, m),
54 __mul__(__xor_with_sr__(
55 __mul__(__load__(data, offset), m), r),
63 __xor__(h, __sl__(data[offset + 2], 16)),
66 : len == 2 ? __proc__(data,
69 __xor__(h, __sl__(data[offset + 1], 8)),
76 __xor__(h, data[offset]) * m,
79 : __xor__(__mul__(__xor_with_sr__(h, 13), m),
80 __sr__(__mul__(__xor_with_sr__(h, 13), m), 15));
84 template <
typename __Type>
85 static constexpr uint32_t
murmur2(__Type &data, uint32_t len) {
86 return __proc__(data, len, 0, __init__(len), 0x5bd1e995, 24);
93 #define CT_MURMUR2(x) \ 94 ::iroha::ct_hash::Hasher::murmur2(x, (sizeof(x) / sizeof(x[0])) - 1) 97 static_assert(
CT_MURMUR2(
"Called the One Ring, or the Ruling Ring.")
100 CT_MURMUR2(
"Fashioned by Sauron a decade after the making of the Elven " 101 "rings in the fires of Mount Doom in Mordor and which")
103 static_assert(
CT_MURMUR2(
"could only be destroyed in that same fire.")
106 #endif // IROHA_MURMUR_2_HPP #define CT_MURMUR2(x)
Definition: compile-time_murmur2.hpp:93
static constexpr uint32_t murmur2(__Type &data, uint32_t len)
Definition: compile-time_murmur2.hpp:85
Definition: compile-time_murmur2.hpp:9
Definition: compile-time_murmur2.hpp:11