提交 6abae591 编写于 作者: I Ian Craggs

Convert thread name to wide chars #1280 and correct conditional compilation #1275

上级 000175a6
......@@ -83,14 +83,20 @@ void Thread_start(thread_fn fn, void* parameter)
int Thread_set_name(const char* thread_name)
{
int rc = 0;
#if defined(_WIN32) || defined(_WIN64)
#define MAX_THREAD_NAME_LENGTH 30
wchar_t wchars[MAX_THREAD_NAME_LENGTH];
#endif
FUNC_ENTRY;
#if defined(_WIN32) || defined(_WIN64)
#if defined(_MSC_VER) && _MSC_VER >= 1920
rc = (int)SetThreadDescription(GetCurrentThread(), (PCWSTR)thread_name);
/* Using NTDDI_VERSION rather than WINVER for more detailed version targeting */
#if NTDDI_VERSION >= NTDDI_WIN10_RS1
mbstowcs(wchars, thread_name, MAX_THREAD_NAME_LENGTH);
rc = (int)SetThreadDescription(GetCurrentThread(), wchars);
#endif
#elif defined(OSX)
// pthread_setname_np __API_AVAILABLE(macos(10.6), ios(3.2))
/* pthread_setname_np __API_AVAILABLE(macos(10.6), ios(3.2)) */
#if defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
rc = pthread_setname_np(thread_name);
#endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册