summaryrefslogtreecommitdiff
path: root/pr/src/md/windows/w95thred.c
diff options
context:
space:
mode:
Diffstat (limited to 'pr/src/md/windows/w95thred.c')
-rw-r--r--pr/src/md/windows/w95thred.c129
1 files changed, 67 insertions, 62 deletions
diff --git a/pr/src/md/windows/w95thred.c b/pr/src/md/windows/w95thred.c
index 5b5a5a89..fb9c457d 100644
--- a/pr/src/md/windows/w95thred.c
+++ b/pr/src/md/windows/w95thred.c
@@ -51,8 +51,8 @@ _PR_MD_EARLY_INIT()
if (hModule) {
sSetThreadDescription =
(SETTHREADDESCRIPTION) GetProcAddress(
- hModule,
- "SetThreadDescription");
+ hModule,
+ "SetThreadDescription");
}
}
@@ -108,13 +108,13 @@ _PR_MD_INIT_THREAD(PRThread *thread)
** the pseudo handle via DuplicateHandle(...)
*/
BOOL ok = DuplicateHandle(
- GetCurrentProcess(), /* Process of source handle */
- GetCurrentThread(), /* Pseudo Handle to dup */
- GetCurrentProcess(), /* Process of handle */
- &(thread->md.handle), /* resulting handle */
- 0L, /* access flags */
- FALSE, /* Inheritable */
- DUPLICATE_SAME_ACCESS); /* Options */
+ GetCurrentProcess(), /* Process of source handle */
+ GetCurrentThread(), /* Pseudo Handle to dup */
+ GetCurrentProcess(), /* Process of handle */
+ &(thread->md.handle), /* resulting handle */
+ 0L, /* access flags */
+ FALSE, /* Inheritable */
+ DUPLICATE_SAME_ACCESS); /* Options */
if (!ok) {
return PR_FAILURE;
}
@@ -124,10 +124,12 @@ _PR_MD_INIT_THREAD(PRThread *thread)
/* Create the blocking IO semaphore */
thread->md.blocked_sema = CreateSemaphore(NULL, 0, 1, NULL);
- if (thread->md.blocked_sema == NULL)
+ if (thread->md.blocked_sema == NULL) {
return PR_FAILURE;
- else
- return PR_SUCCESS;
+ }
+ else {
+ return PR_SUCCESS;
+ }
}
static unsigned __stdcall
@@ -140,21 +142,21 @@ pr_root(void *arg)
PRStatus
_PR_MD_CREATE_THREAD(PRThread *thread,
- void (*start)(void *),
- PRThreadPriority priority,
- PRThreadScope scope,
- PRThreadState state,
- PRUint32 stackSize)
+ void (*start)(void *),
+ PRThreadPriority priority,
+ PRThreadScope scope,
+ PRThreadState state,
+ PRUint32 stackSize)
{
thread->md.start = start;
thread->md.handle = (HANDLE) _beginthreadex(
- NULL,
- thread->stack->stackSize,
- pr_root,
- (void *)thread,
- CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION,
- &(thread->id));
+ NULL,
+ thread->stack->stackSize,
+ pr_root,
+ (void *)thread,
+ CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION,
+ &(thread->id));
if(!thread->md.handle) {
return PR_FAILURE;
}
@@ -169,8 +171,9 @@ _PR_MD_CREATE_THREAD(PRThread *thread,
}
/* Activate the thread */
- if ( ResumeThread( thread->md.handle ) != -1)
+ if ( ResumeThread( thread->md.handle ) != -1) {
return PR_SUCCESS;
+ }
return PR_FAILURE;
}
@@ -209,8 +212,8 @@ _PR_MD_SET_PRIORITY(_MDThread *thread, PRThreadPriority newPri)
rv = SetThreadPriority(thread->handle, nativePri);
PR_ASSERT(rv);
if (!rv) {
- PR_LOG(_pr_thread_lm, PR_LOG_MIN,
- ("PR_SetThreadPriority: can't set thread priority\n"));
+ PR_LOG(_pr_thread_lm, PR_LOG_MIN,
+ ("PR_SetThreadPriority: can't set thread priority\n"));
}
return;
}
@@ -220,10 +223,10 @@ const DWORD MS_VC_EXCEPTION = 0x406D1388;
#pragma pack(push,8)
typedef struct tagTHREADNAME_INFO
{
- DWORD dwType; // Must be 0x1000.
- LPCSTR szName; // Pointer to name (in user addr space).
- DWORD dwThreadID; // Thread ID (-1=caller thread).
- DWORD dwFlags; // Reserved for future use, must be zero.
+ DWORD dwType; // Must be 0x1000.
+ LPCSTR szName; // Pointer to name (in user addr space).
+ DWORD dwThreadID; // Thread ID (-1=caller thread).
+ DWORD dwFlags; // Reserved for future use, must be zero.
} THREADNAME_INFO;
#pragma pack(pop)
@@ -231,32 +234,33 @@ void
_PR_MD_SET_CURRENT_THREAD_NAME(const char *name)
{
#ifdef _MSC_VER
- THREADNAME_INFO info;
+ THREADNAME_INFO info;
#endif
- if (sSetThreadDescription) {
- WCHAR wideName[MAX_PATH];
- if (MultiByteToWideChar(CP_ACP, 0, name, -1, wideName, MAX_PATH)) {
- sSetThreadDescription(GetCurrentThread(), wideName);
- }
- }
+ 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;
-
- info.dwType = 0x1000;
- info.szName = (char*) name;
- info.dwThreadID = -1;
- info.dwFlags = 0;
-
- __try {
- RaiseException(MS_VC_EXCEPTION,
- 0,
- sizeof(info) / sizeof(ULONG_PTR),
- (ULONG_PTR*)&info);
- } __except(EXCEPTION_CONTINUE_EXECUTION) {
- }
+ if (!IsDebuggerPresent()) {
+ return;
+ }
+
+ info.dwType = 0x1000;
+ info.szName = (char*) name;
+ info.dwThreadID = -1;
+ info.dwFlags = 0;
+
+ __try {
+ RaiseException(MS_VC_EXCEPTION,
+ 0,
+ sizeof(info) / sizeof(ULONG_PTR),
+ (ULONG_PTR*)&info);
+ } __except(EXCEPTION_CONTINUE_EXECUTION) {
+ }
#endif
}
@@ -317,9 +321,10 @@ PRInt32 _PR_MD_GETTHREADAFFINITYMASK(PRThread *thread, PRUint32 *mask)
DWORD_PTR system_mask;
rv = GetProcessAffinityMask(GetCurrentProcess(),
- &process_mask, &system_mask);
- if (rv)
+ &process_mask, &system_mask);
+ if (rv) {
*mask = (PRUint32)process_mask;
+ }
return rv?0:-1;
#endif
@@ -363,14 +368,14 @@ _PR_MD_RESUME_THREAD(PRThread *thread)
PRThread*
_MD_CURRENT_THREAD(void)
{
-PRThread *thread;
+ PRThread *thread;
- thread = _MD_GET_ATTACHED_THREAD();
+ thread = _MD_GET_ATTACHED_THREAD();
- if (NULL == thread) {
- thread = _PRI_AttachThread(
- PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0);
- }
- PR_ASSERT(thread != NULL);
- return thread;
+ if (NULL == thread) {
+ thread = _PRI_AttachThread(
+ PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0);
+ }
+ PR_ASSERT(thread != NULL);
+ return thread;
}