diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-09-05 13:28:23 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-09-05 13:28:23 +0200 |
| commit | 0adf3b9b215ab90533b0a4b07d6bf4c12dad74bf (patch) | |
| tree | eebd229313ef7f034e669052adaf4ad8bfbcf947 /dev | |
| parent | 77dc0a650819b460480e1c0be5409fc322a6d2a4 (diff) | |
feat: libSystem: `libsys_hash_64` is now defined in `src/System.cc`
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/libSystem/SystemKit/Syscall.h | 18 | ||||
| -rw-r--r-- | dev/libSystem/src/System.cc | 17 | ||||
| -rw-r--r-- | dev/misc/BenchKit/HWChronometer.h | 2 |
3 files changed, 20 insertions, 17 deletions
diff --git a/dev/libSystem/SystemKit/Syscall.h b/dev/libSystem/SystemKit/Syscall.h index a1505b46..35bfc6f8 100644 --- a/dev/libSystem/SystemKit/Syscall.h +++ b/dev/libSystem/SystemKit/Syscall.h @@ -14,22 +14,8 @@ 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) { - if (!path || *path == 0) return 0; - - 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; -} +IMPORT_C UInt64 libsys_hash_64(const Char* path); #ifndef SYSCALL_HASH #define SYSCALL_HASH(str) libsys_hash_64(str) -#endif // !SYSCALL_HASH
\ No newline at end of file +#endif // !SYSCALL_HASH diff --git a/dev/libSystem/src/System.cc b/dev/libSystem/src/System.cc index 3870ff18..ba848a18 100644 --- a/dev/libSystem/src/System.cc +++ b/dev/libSystem/src/System.cc @@ -23,6 +23,23 @@ IMPORT_C Void _rtl_assert(Bool expr, const Char* origin) { }
}
+/// @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;
+}
+
// memmove-style copy
IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len) {
// handles overlap, prefers 64-bit word copies when aligned
diff --git a/dev/misc/BenchKit/HWChronometer.h b/dev/misc/BenchKit/HWChronometer.h index e232db7e..56e4f2af 100644 --- a/dev/misc/BenchKit/HWChronometer.h +++ b/dev/misc/BenchKit/HWChronometer.h @@ -14,7 +14,7 @@ struct HWChronoTraits; template <typename ChronoTraits = HWChronoTraits> class HWChrono; -/// @brief BenchKit chrono logic for x64. +/// @brief BenchKit chrono logic for x64/ARM64. struct HWChronoTraits final { private: STATIC UInt64 TickImpl_(void) { |
