summaryrefslogtreecommitdiffhomepage
path: root/dev/libSystem/SystemKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-06-22 21:41:15 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-06-22 21:41:15 +0200
commit41703b62f9e7e83fa856fbf53101edc889502c45 (patch)
tree96079f607134642cae1b6c79b1da70135c1bf5d6 /dev/libSystem/SystemKit
parent7c63269be0c40d8b6169d3cacf487ab370206f60 (diff)
feat: use FNV in libSystem's syscall routing.
fix: Add legacy string.h functions back, for GCC. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/libSystem/SystemKit')
-rw-r--r--dev/libSystem/SystemKit/Syscall.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/dev/libSystem/SystemKit/Syscall.h b/dev/libSystem/SystemKit/Syscall.h
index 436665ae..5a840df1 100644
--- a/dev/libSystem/SystemKit/Syscall.h
+++ b/dev/libSystem/SystemKit/Syscall.h
@@ -9,11 +9,25 @@
#include <libSystem/SystemKit/System.h>
#include <cstdarg>
-#ifndef SYSCALL_HASH
-#define SYSCALL_HASH(str) (UInt64) str
-#endif // !SYSCALL_HASH
-
IMPORT_C VoidPtr libsys_syscall_arg_1(SizeT id);
IMPORT_C VoidPtr libsys_syscall_arg_2(SizeT id, VoidPtr arg1);
IMPORT_C VoidPtr libsys_syscall_arg_3(SizeT id, VoidPtr arg1, VoidPtr arg3);
IMPORT_C VoidPtr libsys_syscall_arg_4(SizeT id, VoidPtr arg1, VoidPtr arg3, VoidPtr arg4);
+
+inline UInt64 libsys_hash_64(const Char* path) {
+ const UInt64 FNV_OFFSET_BASIS = 0xcbf29ce484222325ULL;
+ const UInt64 FNV_PRIME = 0x100000001b3ULL;
+
+ UInt64 hash = FNV_OFFSET_BASIS;
+
+ while (*path) {
+ hash ^= (Char) (*path++);
+ hash *= FNV_PRIME;
+ }
+
+ return hash;
+}
+
+#ifndef SYSCALL_HASH
+#define SYSCALL_HASH(str) libsys_hash_64(str)
+#endif // !SYSCALL_HASH \ No newline at end of file