summaryrefslogtreecommitdiffhomepage
path: root/Source/ThreadLocalStorage.cxx
blob: 36f59df5ed6e6a06797fa494ae80ccbb7ddbdfc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * ========================================================
 *
 * hCore
 * Copyright Mahrouss Logic, all rights reserved.
 *
 *  ========================================================
 */

#include <KernelKit/ProcessManager.hpp>
#include <KernelKit/ThreadLocalStorage.hxx>

#include <KernelKit/SharedObjectCore.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: Thread check failure, crashing...\n";
        ProcessManager::Shared().Leak().GetCurrent().Leak().Crash();
    }
}