#include "thread.h" #include "util_likely.h" #include #ifdef _WIN32 namespace dxvk::this_thread { bool isInModuleDetachment() { using PFN_RtlDllShutdownInProgress = BOOLEAN (WINAPI *)(); static auto RtlDllShutdownInProgress = reinterpret_cast( ::GetProcAddress(::GetModuleHandleW(L"ntdll.dll"), "RtlDllShutdownInProgress")); return RtlDllShutdownInProgress(); } } #else namespace dxvk::this_thread { static std::atomic g_threadCtr = { 0u }; static thread_local uint32_t g_threadId = 0u; // This implementation returns thread ids unique to the current instance. // ie. if you use this across multiple .so's then you might get conflicting ids. // // This isn't an issue for us, as it is only used by the spinlock implementation, // but may be for you if you use this elsewhere. uint32_t get_id() { if (unlikely(!g_threadId)) g_threadId = ++g_threadCtr; return g_threadId; } } #endif