diff options
Diffstat (limited to 'dev/libSystem')
| -rw-r--r-- | dev/libSystem/SystemKit/Syscall.h | 22 | ||||
| -rw-r--r-- | dev/libSystem/src/SystemCalls.cc (renamed from dev/libSystem/src/SystemAPI.cc) | 10 |
2 files changed, 23 insertions, 9 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 diff --git a/dev/libSystem/src/SystemAPI.cc b/dev/libSystem/src/SystemCalls.cc index d0682830..6344cdac 100644 --- a/dev/libSystem/src/SystemAPI.cc +++ b/dev/libSystem/src/SystemCalls.cc @@ -47,7 +47,7 @@ IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt }
IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) {
- return (Ref) libsys_syscall_arg_3(SYSCALL_HASH('IoOpenFile'),
+ return (Ref) libsys_syscall_arg_3(SYSCALL_HASH("IoOpenFile"),
reinterpret_cast<VoidPtr>(const_cast<Char*>(path)),
reinterpret_cast<VoidPtr>(const_cast<Char*>(drv_letter)));
}
@@ -58,14 +58,14 @@ IMPORT_C Void IoCloseFile(_Input Ref desc) { IMPORT_C UInt64 IoSeekFile(_Input Ref desc, _Input UInt64 off) {
auto ret = (volatile UInt64*) libsys_syscall_arg_3(
- SYSCALL_HASH('IoSeekFile'), reinterpret_cast<VoidPtr>(desc), reinterpret_cast<VoidPtr>(&off));
+ SYSCALL_HASH("IoSeekFile"), reinterpret_cast<VoidPtr>(desc), reinterpret_cast<VoidPtr>(&off));
MUST_PASS((*ret) != ~0UL);
return *ret;
}
IMPORT_C UInt64 IoTellFile(_Input Ref desc) {
- auto ret = (volatile UInt64*) libsys_syscall_arg_2(SYSCALL_HASH('IoTellFile'),
+ auto ret = (volatile UInt64*) libsys_syscall_arg_2(SYSCALL_HASH("IoTellFile"),
reinterpret_cast<VoidPtr>(desc));
return *ret;
}
@@ -76,7 +76,7 @@ IMPORT_C SInt32 PrintOut(_Input IORef desc, const char* fmt, ...) { va_start(args, fmt);
auto ret = (volatile UInt64*) libsys_syscall_arg_4(
- SYSCALL_HASH('PrintOut'), reinterpret_cast<VoidPtr>(desc),
+ SYSCALL_HASH("PrintOut"), reinterpret_cast<VoidPtr>(desc),
reinterpret_cast<VoidPtr>(const_cast<Char*>(fmt)), args);
va_end(args);
@@ -89,6 +89,6 @@ IMPORT_C Void _rtl_assert(Bool expr, const Char* origin) { PrintOut(nullptr, "Assertion failed: %s\r", origin);
PrintOut(nullptr, "Origin: %s\r", origin);
- libsys_syscall_arg_1(SYSCALL_HASH('_rtl_debug_break'));
+ libsys_syscall_arg_1(SYSCALL_HASH("_rtl_debug_break"));
}
}
|
