| 29 | typedef HRESULT (*PfnSetThreadDescription)(HANDLE,PCWSTR); |
| 30 | |
| 31 | void SetThreadName(Thread thread, const char* name) |
| 32 | { |
| 33 | (void)thread; |
| 34 | (void)name; |
| 35 | // Currently, this crashed mysteriously on Win32, so we'll keep it only for Win64 until we've figured it out |
| 36 | #if defined(_WIN64) |
| 37 | static PfnSetThreadDescription pfn = (PfnSetThreadDescription)GetFunctionPtr("kernel32.dll", "SetThreadDescription"); |
| 38 | if (pfn) { |
| 39 | size_t wn = mbsrtowcs(NULL, &name, 0, NULL); |
| 40 | wchar_t* buf = (wchar_t*)malloc((wn + 1) * sizeof(wchar_t)); |
| 41 | wn = mbsrtowcs(buf, &name, wn + 1, NULL); |
| 42 | |
| 43 | pfn(thread, buf); |
| 44 | |
| 45 | free(buf); |
| 46 | } |
| 47 | #endif |
| 48 | } |
| 49 | |
| 50 | Thread New(ThreadStart thread_start, uint32_t stack_size, void* arg, const char* name) |
| 51 | { |
no test coverage detected