summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/src/md/windows/w95thred.c
diff options
context:
space:
mode:
Diffstat (limited to 'nsprpub/pr/src/md/windows/w95thred.c')
-rw-r--r--nsprpub/pr/src/md/windows/w95thred.c143
1 files changed, 74 insertions, 69 deletions
diff --git a/nsprpub/pr/src/md/windows/w95thred.c b/nsprpub/pr/src/md/windows/w95thred.c
index a365411f5..fb9c457d7 100644
--- a/nsprpub/pr/src/md/windows/w95thred.c
+++ b/nsprpub/pr/src/md/windows/w95thred.c
@@ -25,7 +25,7 @@ DWORD _pr_currentThreadIndex;
DWORD _pr_lastThreadIndex;
DWORD _pr_currentCPUIndex;
#endif
-int _pr_intsOff = 0;
+int _pr_intsOff = 0;
_PRInterruptTable _pr_interruptTable[] = { { 0 } };
typedef HRESULT (WINAPI *SETTHREADDESCRIPTION)(HANDLE, PCWSTR);
@@ -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
@@ -138,23 +140,23 @@ pr_root(void *arg)
return 0;
}
-PRStatus
-_PR_MD_CREATE_THREAD(PRThread *thread,
- void (*start)(void *),
- PRThreadPriority priority,
- PRThreadScope scope,
- PRThreadState state,
- PRUint32 stackSize)
+PRStatus
+_PR_MD_CREATE_THREAD(PRThread *thread,
+ 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,20 +171,21 @@ _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;
}
-void
+void
_PR_MD_YIELD(void)
{
/* Can NT really yield at all? */
Sleep(0);
}
-void
+void
_PR_MD_SET_PRIORITY(_MDThread *thread, PRThreadPriority newPri)
{
int nativePri;
@@ -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,16 +321,17 @@ 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
}
-void
-_PR_MD_SUSPEND_CPU(_PRCPU *cpu)
+void
+_PR_MD_SUSPEND_CPU(_PRCPU *cpu)
{
_PR_MD_SUSPEND_THREAD(cpu->thread);
}
@@ -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;
}