27#if defined(DEBUG_FNV1A)
40 constexpr uint32_t initialHash = 0x811c9dc5;
41 constexpr size_t size =
sizeof(initialHash);
44 constexpr uint32_t
feed(uint32_t hash, uint8_t
byte)
53 constexpr uint32_t
checksum(std::span<uint8_t, Size> span, uint32_t hash = initialHash)
65 constexpr void putAtEnd(std::span<uint8_t, Size> span, uint32_t hash = initialHash)
67 size_t end = span.size();
72 const uint32_t got =
checksum(span.first(end - 4), hash);
73 span[end - 4] =
static_cast<uint8_t
>(got >> 0);
74 span[end - 3] =
static_cast<uint8_t
>(got >> 8);
75 span[end - 2] =
static_cast<uint8_t
>(got >> 16);
76 span[end - 1] =
static_cast<uint8_t
>(got >> 24);
82 constexpr bool checkAtEnd(std::span<uint8_t, Size> span, uint32_t hash = initialHash)
84 size_t end = span.size();
89 const uint32_t got =
checksum(span.first(end - 4), hash);
90 const uint32_t expected =
91 (
static_cast<uint32_t
>(span[end - 4]) << 0) |
92 (
static_cast<uint32_t
>(span[end - 3]) << 8) |
93 (
static_cast<uint32_t
>(span[end - 2]) << 16) |
94 (
static_cast<uint32_t
>(span[end - 1]) << 24);
103 return got == expected;
constexpr void putAtEnd(std::span< uint8_t, Size > span, uint32_t hash=initialHash)
Definition fnv1a.hpp:65
constexpr bool checkAtEnd(std::span< uint8_t, Size > span, uint32_t hash=initialHash)
Definition fnv1a.hpp:82
constexpr uint32_t feed(uint32_t hash, uint8_t byte)
Update the hash with the given byte.
Definition fnv1a.hpp:44
constexpr uint32_t checksum(std::span< uint8_t, Size > span, uint32_t hash=initialHash)
Compute the hash over the given span.
Definition fnv1a.hpp:53
#define debugf(...)
Definition ndebug.hpp:23
#define END
Terminator of log message at the end.
Definition ndebug.hpp:50
#define LOGLEVEL_ARGS
Definition ndebug.hpp:28