// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp #include #if defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_POSIX) #include #else #error OS not handled #endif #include namespace Nz { namespace NAZARA_ANONYMOUS_NAMESPACE { PlatformImpl::ThreadHandle GetHandle(std::thread& thread) { #ifdef NAZARA_COMPILER_MINGW_THREADS_MCF // MCF flavor (returns HANDLE by a void*) return static_cast(_MCF_thread_get_handle(thread.native_handle())); #else // Cast because of MSVC standard library that returns a void* instead of a HANDLE return static_cast(thread.native_handle()); #endif } } std::string GetCurrentThreadName() { return PlatformImpl::GetCurrentThreadName(); } std::string GetThreadName(std::thread& thread) { NAZARA_USE_ANONYMOUS_NAMESPACE // std::thread::native_handle returns a void* with MSVC instead of a HANDLE return PlatformImpl::GetThreadName(GetHandle(thread)); } void SetCurrentThreadName(const char* name) { PlatformImpl::SetCurrentThreadName(name); } void SetThreadName(std::thread& thread, const char* name) { NAZARA_USE_ANONYMOUS_NAMESPACE // std::thread::native_handle returns a void* with MSVC instead of a HANDLE PlatformImpl::SetThreadName(GetHandle(thread), name); } }