diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-17 10:05:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-17 10:05:07 +0100 |
| commit | 062c4bb508bf6ec7334d374fef2e0e10623b2df9 (patch) | |
| tree | 137a91eb22d1a9207fd4322ced08c3b6388c5eb5 /dev/libSystem/src/Utils.cc | |
| parent | 36269e57831e560df6a0da9c9d02c00671b0163d (diff) | |
| parent | 791fcd646503f05617f22e6006c115095746da26 (diff) | |
Merge pull request #69 from nekernel-org/dev
release: NeKernel v0.0.7
Diffstat (limited to 'dev/libSystem/src/Utils.cc')
| -rw-r--r-- | dev/libSystem/src/Utils.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/dev/libSystem/src/Utils.cc b/dev/libSystem/src/Utils.cc new file mode 100644 index 00000000..cf4f41e7 --- /dev/null +++ b/dev/libSystem/src/Utils.cc @@ -0,0 +1,29 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +------------------------------------------- */ + +#include <libSystem/SystemKit/Err.h> +#include <libSystem/SystemKit/Syscall.h> +#include <libSystem/SystemKit/System.h> +#include <libSystem/SystemKit/Verify.h> + +using namespace LibSystem; + +/// @note This uses the FNV 64-bit variant. +IMPORT_C UInt64 libsys_hash_64(const Char* path) { + if (!path || *path == 0) return 0; + + const UInt64 kFNVSeed = 0xcbf29ce484222325ULL; + const UInt64 kFNVPrime = 0x100000001b3ULL; + + UInt64 hash = kFNVSeed; + + while (*path) { + hash ^= (Char) (*path++); + hash *= kFNVPrime; + } + + return hash; +} |
