Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
checksum.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
20#include <cstddef>
21
22namespace shambase {
23
31 inline u64 fnv1a_hash(const char *data, size_t size) {
32 constexpr u64 fnv_offset_basis = 14695981039346656037ULL;
33 constexpr u64 fnv_prime = 1099511628211ULL;
34
36 for (size_t i = 0; i < size; ++i) {
37 hash ^= static_cast<u64>(static_cast<unsigned char>(data[i]));
38 hash *= fnv_prime;
39 }
40 return hash;
41 }
42
43} // namespace shambase
std::uint64_t u64
64 bit unsigned integer
namespace for basic c++ utilities
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
u64 fnv1a_hash(const char *data, size_t size)
Compute the FNV-1a hash of a given data.
Definition checksum.hpp:31