OLD | NEW |
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* This Source Code Form is subject to the terms of the Mozilla Public | 2 /* This Source Code Form is subject to the terms of the Mozilla Public |
3 * License, v. 2.0. If a copy of the MPL was not distributed with this | 3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | 5 |
6 #include "primpl.h" | 6 #include "primpl.h" |
7 #include <process.h> /* for _beginthreadex() */ | 7 #include <process.h> /* for _beginthreadex() */ |
8 | 8 |
9 #if defined(_MSC_VER) && _MSC_VER <= 1200 | 9 #if defined(_MSC_VER) && _MSC_VER <= 1200 |
10 /* | 10 /* |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 rv = SetThreadPriority(thread->handle, nativePri); | 162 rv = SetThreadPriority(thread->handle, nativePri); |
163 PR_ASSERT(rv); | 163 PR_ASSERT(rv); |
164 if (!rv) { | 164 if (!rv) { |
165 PR_LOG(_pr_thread_lm, PR_LOG_MIN, | 165 PR_LOG(_pr_thread_lm, PR_LOG_MIN, |
166 ("PR_SetThreadPriority: can't set thread priority\n")); | 166 ("PR_SetThreadPriority: can't set thread priority\n")); |
167 } | 167 } |
168 return; | 168 return; |
169 } | 169 } |
170 | 170 |
| 171 const DWORD MS_VC_EXCEPTION = 0x406D1388; |
| 172 |
| 173 #pragma pack(push,8) |
| 174 typedef struct tagTHREADNAME_INFO |
| 175 { |
| 176 DWORD dwType; // Must be 0x1000. |
| 177 LPCSTR szName; // Pointer to name (in user addr space). |
| 178 DWORD dwThreadID; // Thread ID (-1=caller thread). |
| 179 DWORD dwFlags; // Reserved for future use, must be zero. |
| 180 } THREADNAME_INFO; |
| 181 #pragma pack(pop) |
| 182 |
| 183 void |
| 184 _PR_MD_SET_CURRENT_THREAD_NAME(const char *name) |
| 185 { |
| 186 #ifdef _MSC_VER |
| 187 THREADNAME_INFO info; |
| 188 |
| 189 if (!IsDebuggerPresent()) |
| 190 return; |
| 191 |
| 192 info.dwType = 0x1000; |
| 193 info.szName = (char*) name; |
| 194 info.dwThreadID = -1; |
| 195 info.dwFlags = 0; |
| 196 |
| 197 __try { |
| 198 RaiseException(MS_VC_EXCEPTION, |
| 199 0, |
| 200 sizeof(info) / sizeof(ULONG_PTR), |
| 201 (ULONG_PTR*)&info); |
| 202 } __except(EXCEPTION_CONTINUE_EXECUTION) { |
| 203 } |
| 204 #endif |
| 205 } |
| 206 |
171 void | 207 void |
172 _PR_MD_CLEAN_THREAD(PRThread *thread) | 208 _PR_MD_CLEAN_THREAD(PRThread *thread) |
173 { | 209 { |
174 BOOL rv; | 210 BOOL rv; |
175 | 211 |
176 if (thread->md.blocked_sema) { | 212 if (thread->md.blocked_sema) { |
177 rv = CloseHandle(thread->md.blocked_sema); | 213 rv = CloseHandle(thread->md.blocked_sema); |
178 PR_ASSERT(rv); | 214 PR_ASSERT(rv); |
179 thread->md.blocked_sema = 0; | 215 thread->md.blocked_sema = 0; |
180 } | 216 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 428 |
393 #pragma data_seg(".CRT$XLB") | 429 #pragma data_seg(".CRT$XLB") |
394 PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit; | 430 PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit; |
395 | 431 |
396 // Reset the default section. | 432 // Reset the default section. |
397 #pragma data_seg() | 433 #pragma data_seg() |
398 | 434 |
399 #endif // _WIN64 | 435 #endif // _WIN64 |
400 | 436 |
401 #endif // NSPR_STATIC | 437 #endif // NSPR_STATIC |
OLD | NEW |