summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/src/md/windows/ntthread.c
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-02-23 11:03:38 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-02-23 11:03:38 +0100
commit8781f745556be5d7402d0f3adc67ecfe32fe04a0 (patch)
tree2aa8cfb446bab0283ac5ce9d8b1bb8c7bc2f3926 /nsprpub/pr/src/md/windows/ntthread.c
parentf3f9b7b06e37f870463a5f2196457cca6b10d700 (diff)
downloadUXP-8781f745556be5d7402d0f3adc67ecfe32fe04a0.tar
UXP-8781f745556be5d7402d0f3adc67ecfe32fe04a0.tar.gz
UXP-8781f745556be5d7402d0f3adc67ecfe32fe04a0.tar.lz
UXP-8781f745556be5d7402d0f3adc67ecfe32fe04a0.tar.xz
UXP-8781f745556be5d7402d0f3adc67ecfe32fe04a0.zip
Update NSPR to 4.18
Diffstat (limited to 'nsprpub/pr/src/md/windows/ntthread.c')
-rw-r--r--nsprpub/pr/src/md/windows/ntthread.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/nsprpub/pr/src/md/windows/ntthread.c b/nsprpub/pr/src/md/windows/ntthread.c
index fead1236d..1fdf0e93b 100644
--- a/nsprpub/pr/src/md/windows/ntthread.c
+++ b/nsprpub/pr/src/md/windows/ntthread.c
@@ -27,6 +27,9 @@ PRUint32 _nt_idleCount;
extern __declspec(thread) PRThread *_pr_io_restarted_io;
extern DWORD _pr_io_restartedIOIndex;
+typedef HRESULT (WINAPI *SETTHREADDESCRIPTION)(HANDLE, PCWSTR);
+static SETTHREADDESCRIPTION sSetThreadDescription = NULL;
+
/* Must check the restarted_io *before* decrementing no_sched to 0 */
#define POST_SWITCH_WORK() \
PR_BEGIN_MACRO \
@@ -79,6 +82,8 @@ _nt_handle_restarted_io(PRThread *restarted_io)
void
_PR_MD_EARLY_INIT()
{
+ HMODULE hModule;
+
_MD_NEW_LOCK( &_nt_idleLock );
_nt_idleCount = 0;
PR_INIT_CLIST(&_nt_idleList);
@@ -98,6 +103,15 @@ _PR_MD_EARLY_INIT()
_pr_intsOffIndex = TlsAlloc();
_pr_io_restartedIOIndex = TlsAlloc();
}
+
+ // SetThreadDescription is Windows 10 build 1607+
+ hModule = GetModuleHandleW(L"kernel32.dll");
+ if (hModule) {
+ sSetThreadDescription =
+ (SETTHREADDESCRIPTION) GetProcAddress(
+ hModule,
+ "SetThreadDescription");
+ }
}
void _PR_MD_CLEANUP_BEFORE_EXIT(void)
@@ -293,7 +307,16 @@ _PR_MD_SET_CURRENT_THREAD_NAME(const char *name)
{
#ifdef _MSC_VER
THREADNAME_INFO info;
+#endif
+
+ if (sSetThreadDescription) {
+ WCHAR wideName[MAX_PATH];
+ if (MultiByteToWideChar(CP_ACP, 0, name, -1, wideName, MAX_PATH)) {
+ sSetThreadDescription(GetCurrentThread(), wideName);
+ }
+ }
+#ifdef _MSC_VER
if (!IsDebuggerPresent())
return;