From 05bc2ed7cbe07cb4cd535932f10778b35f72e944 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sun, 17 Mar 2019 01:59:46 +0100 Subject: Codechange: Replace custom thread code with C++11 thread objects. We assume a conforming C++11 compiler environment that has a valid -header. Failure to run a real thread is handled gracefully. --- src/os/windows/win32.cpp | 7 +++++-- src/os/windows/win32.h | 6 ------ 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'src/os/windows') diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index 4a4955549..2a72ca1c5 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -30,6 +30,7 @@ #include #include #include "../../language.h" +#include "../../thread.h" #include "../../safeguards.h" @@ -816,12 +817,12 @@ PACK_N(struct THREADNAME_INFO { /** * Signal thread name to any attached debuggers. */ -void SetWin32ThreadName(DWORD dwThreadID, const char* threadName) +void SetCurrentThreadName(const char *threadName) { THREADNAME_INFO info; info.dwType = 0x1000; info.szName = threadName; - info.dwThreadID = dwThreadID; + info.dwThreadID = -1; info.dwFlags = 0; #pragma warning(push) @@ -832,4 +833,6 @@ void SetWin32ThreadName(DWORD dwThreadID, const char* threadName) } #pragma warning(pop) } +#else +void SetCurrentThreadName(const char *) {} #endif diff --git a/src/os/windows/win32.h b/src/os/windows/win32.h index 4f813c4a6..23e216762 100644 --- a/src/os/windows/win32.h +++ b/src/os/windows/win32.h @@ -39,12 +39,6 @@ HRESULT OTTDSHGetFolderPath(HWND, int, HANDLE, DWORD, LPTSTR); #define SHGFP_TYPE_CURRENT 0 #endif /* __MINGW32__ */ -#ifdef _MSC_VER -void SetWin32ThreadName(DWORD dwThreadID, const char* threadName); -#else -static inline void SetWin32ThreadName(DWORD dwThreadID, const char* threadName) {} -#endif - void Win32SetCurrentLocaleName(const char *iso_code); int OTTDStringCompare(const char *s1, const char *s2); -- cgit v1.2.3-54-g00ecf