summaryrefslogtreecommitdiffhomepage
path: root/src/libSystem/src/Utilities.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libSystem/src/Utilities.cpp')
-rw-r--r--src/libSystem/src/Utilities.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libSystem/src/Utilities.cpp b/src/libSystem/src/Utilities.cpp
new file mode 100644
index 00000000..3ccfafa2
--- /dev/null
+++ b/src/libSystem/src/Utilities.cpp
@@ -0,0 +1,27 @@
+// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
+// Licensed under the Apache License, Version 2.0 (see LICENSE file)
+// Official repository: https://github.com/nekernel-org/nekernel
+
+#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;
+}