diff options
Diffstat (limited to 'Private/Source/ThreadLocalStorage.cxx')
| -rw-r--r-- | Private/Source/ThreadLocalStorage.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Private/Source/ThreadLocalStorage.cxx b/Private/Source/ThreadLocalStorage.cxx new file mode 100644 index 00000000..5cde1e77 --- /dev/null +++ b/Private/Source/ThreadLocalStorage.cxx @@ -0,0 +1,31 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <KernelKit/ProcessManager.hpp> +#include <KernelKit/ThreadLocalStorage.hxx> + +using namespace hCore; + +Boolean hcore_tls_check(VoidPtr ptr) +{ + if (!ptr) + return false; + + const char *_ptr = (const char *)ptr; + return _ptr[0] == kRTLMag0 && _ptr[1] == kRTLMag1 && _ptr[2] == kRTLMag2; +} + +Void hcore_tls_check_syscall_impl(VoidPtr ptr) noexcept +{ + if (!hcore_tls_check(ptr)) + { + kcout << "TLS: TLS check failure, crashing...\n"; + ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); + } +} |
