2023-03-15 00:35:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: ThreadCookie.hpp
|
|
|
|
Date: 2023-3-14
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED) && defined(AURORA_IS_64BIT)
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
AuUInt32 GetCurrentThreadIDFast();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace Aurora::Threading::Primitives
|
|
|
|
{
|
|
|
|
using ThreadCookie_t = AuUInt;
|
|
|
|
|
|
|
|
static auline ThreadCookie_t GetThreadCookie()
|
|
|
|
{
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
|
|
#if defined(AURORA_IS_32BIT)
|
|
|
|
__asm {
|
|
|
|
mov eax, fs:[0x18]
|
2023-03-15 03:12:10 +00:00
|
|
|
mov eax, [eax + 0x24]
|
|
|
|
ret
|
2023-03-15 00:35:29 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
return ::GetCurrentThreadIDFast();
|
|
|
|
#endif
|
|
|
|
#elif defined(AURORA_IS_POSIX_DERIVED)
|
|
|
|
return (ThreadCookie_t)pthread_self();
|
|
|
|
#else
|
|
|
|
return (ThreadCookie_t)Threads::GetThread();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|