diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-18 19:42:43 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-18 19:42:43 +0100 |
| commit | 21631860dcfc9c6fef3f7108ff427f67549bcc51 (patch) | |
| tree | 81d3b35e11103d37e43920d0bb5ffc273e95b8f4 /src/libDDK/DriverKit/ObjectKit/Checksum.hpp | |
| parent | 93a712bf209423048fd78f3512a7e521df5c54b8 (diff) | |
[FEAT] Updated DDK headers for C++ units. (BREAKING CHANGES)
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/libDDK/DriverKit/ObjectKit/Checksum.hpp')
| -rw-r--r-- | src/libDDK/DriverKit/ObjectKit/Checksum.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/libDDK/DriverKit/ObjectKit/Checksum.hpp b/src/libDDK/DriverKit/ObjectKit/Checksum.hpp new file mode 100644 index 00000000..d1973161 --- /dev/null +++ b/src/libDDK/DriverKit/ObjectKit/Checksum.hpp @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/ne-foss-org/nekernel + +#ifndef DRIVERKIT_CHECKSUM_H +#define DRIVERKIT_CHECKSUM_H + +#include <DriverKit/ObjectKit/Base.hpp> + +namespace Kernel::DDK { + +using Blob = char*; +using IndexableBlob = Blob; +using Indexable = char; + +/// @note This uses the FNV 64-bit variant. +/// @brief Performs a checksum computation for a memory region. +inline uintptr_t rtl_checksum(const IndexableBlob path) { + if (!path || *path == 0) return 0; + + const uintptr_t kFNVSeed = 0xcbf29ce484222325ULL; + const uintptr_t kFNVPrime = 0x100000001b3ULL; + + uintptr_t hash = kFNVSeed; + IndexableBlob path_ = path; + + while (*path_) { + hash ^= (Indexable) (*path_); + ++path_; + + hash *= kFNVPrime; + } + + return hash; +} + +} // namespace Kernel::DDK + +#endif |
