Bug 958796: Pass STACK_SIZE_PARAM_IS_A_RESERVATION to _beginthreadex NSPR_4_10_4_BETA2
authorEmanuel Hoogeveen <emanuel.hoogeveen@gmail.com>
Tue, 28 Jan 2014 10:40:26 -0800
changeset 4509 539942e2dd07d2e349777460b86fd8d8a3d96b93
parent 4508 5b444c27c96d16dbcf0b10d064748f9d30ff929e
child 4510 b15b05fafb4f08560d35e92bcba33296153444a9
push id57
push userwtc@google.com
push dateTue, 28 Jan 2014 18:40:32 +0000
bugs958796
Bug 958796: Pass STACK_SIZE_PARAM_IS_A_RESERVATION to _beginthreadex when setting a custom thread stack size. r=wtc.
pr/src/md/windows/ntthread.c
pr/src/md/windows/w95thred.c
pr/tests/attach.c
pr/tests/foreign.c
pr/tests/provider.c
pr/tests/socket.c
pr/tests/testfile.c
--- a/pr/src/md/windows/ntthread.c
+++ b/pr/src/md/windows/ntthread.c
@@ -177,17 +177,17 @@ PRStatus
 {
 
     thread->md.start = start;
     thread->md.handle = (HANDLE) _beginthreadex(
                     NULL,
                     thread->stack->stackSize,
                     pr_root,
                     (void *)thread,
-                    CREATE_SUSPENDED,
+                    CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION,
                     &(thread->id));
     if(!thread->md.handle) {
         PRErrorCode prerror;
         thread->md.fiber_last_error = GetLastError();
         switch (errno) {
             case ENOMEM:
                 prerror = PR_OUT_OF_MEMORY_ERROR;
                 break;
--- a/pr/src/md/windows/w95thred.c
+++ b/pr/src/md/windows/w95thred.c
@@ -101,17 +101,17 @@ PRStatus
 {
 
     thread->md.start = start;
     thread->md.handle = (HANDLE) _beginthreadex(
                     NULL,
                     thread->stack->stackSize,
                     pr_root,
                     (void *)thread,
-                    CREATE_SUSPENDED,
+                    CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION,
                     &(thread->id));
     if(!thread->md.handle) {
         return PR_FAILURE;
     }
 
     thread->md.id = thread->id;
     /*
      * On windows, a thread is created with a thread priority of
--- a/pr/tests/attach.c
+++ b/pr/tests/attach.c
@@ -255,17 +255,17 @@ int main(int argc, char **argv)
 		failed_already=1;
 		goto exit_now;
 	}
 
 
 #elif defined(WIN32)
 
     hThread = (HANDLE) _beginthreadex(NULL, 0, threadStartFunc, NULL,
-            0, &threadID); 
+            STACK_SIZE_PARAM_IS_A_RESERVATION, &threadID);
     if (hThread == 0) {
         fprintf(stderr, "thread creation failed: error code %d\n",
                 GetLastError());
 		failed_already=1;
 		goto exit_now;
     }
     rv = WaitForSingleObject(hThread, INFINITE);
     if (debug_mode)PR_ASSERT(rv != WAIT_FAILED);
--- a/pr/tests/foreign.c
+++ b/pr/tests/foreign.c
@@ -74,19 +74,17 @@ static void sproc_start(void *arg, PRSiz
     StartFn start = so->start;
     void *data = so->arg;
     PR_Free(so);
     start(data);
 }  /* sproc_start */
 #endif  /* defined(IRIX) && !defined(_PR_PTHREADS) */
 
 #if defined(WIN32)
-#if defined(WINCE)
 #include <windows.h>
-#endif
 #include <process.h>  /* for _beginthreadex() */
 
 static PRUintn __stdcall windows_start(void *arg)
 {
     StartObject *so = (StartObject*)arg;
     StartFn start = so->start;
     void *data = so->arg;
     PR_Free(so);
@@ -169,17 +167,17 @@ static PRStatus NSPRPUB_TESTS_CreateThre
             PR_ASSERT(NULL != start_object);
             start_object->start = start;
             start_object->arg = arg;
             th = (void*)_beginthreadex(
                 NULL, /* LPSECURITY_ATTRIBUTES - pointer to thread security attributes */  
                 0U, /* DWORD - initial thread stack size, in bytes */
                 windows_start, /* LPTHREAD_START_ROUTINE - pointer to thread function */
                 start_object, /* LPVOID - argument for new thread */
-                0U, /*DWORD dwCreationFlags - creation flags */
+                STACK_SIZE_PARAM_IS_A_RESERVATION, /*DWORD dwCreationFlags - creation flags */
                 &id /* LPDWORD - pointer to returned thread identifier */ );
 
             rv = (NULL == th) ? PR_FAILURE : PR_SUCCESS;
         }
 #else
         PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
         rv = PR_FAILURE;
 #endif
--- a/pr/tests/provider.c
+++ b/pr/tests/provider.c
@@ -748,17 +748,17 @@ static PRStatus NewThread(
             PR_ASSERT(NULL != start_object);
             start_object->start = start;
             start_object->arg = arg;
             th = (void*)_beginthreadex(
                 NULL, /* LPSECURITY_ATTRIBUTES - pointer to thread security attributes */  
                 0U, /* DWORD - initial thread stack size, in bytes */
                 windows_start, /* LPTHREAD_START_ROUTINE - pointer to thread function */
                 start_object, /* LPVOID - argument for new thread */
-                0U, /*DWORD dwCreationFlags - creation flags */
+                STACK_SIZE_PARAM_IS_A_RESERVATION, /*DWORD dwCreationFlags - creation flags */
                 &id /* LPDWORD - pointer to returned thread identifier */ );
 
             rv = (NULL == th) ? PR_FAILURE : PR_SUCCESS;
         }
 #else
         PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
         rv = PR_FAILURE;
 #endif
--- a/pr/tests/socket.c
+++ b/pr/tests/socket.c
@@ -342,17 +342,17 @@ PRInt32 native_thread = 0;
 		HANDLE thandle;
 		unsigned tid;
 		
 		thandle = (HANDLE) _beginthreadex(
 						NULL,
 						stackSize,
 						(unsigned (__stdcall *)(void *))start,
 						arg,
-						0,
+						STACK_SIZE_PARAM_IS_A_RESERVATION,
 						&tid);		
 		return((PRThread *) thandle);
 #endif
 	} else {
 		return(PR_CreateThread(type,start,arg,priority,scope,state,stackSize));
 	}
 #else
 	return(PR_CreateThread(type,start,arg,priority,scope,state,stackSize));
--- a/pr/tests/testfile.c
+++ b/pr/tests/testfile.c
@@ -145,17 +145,17 @@ PRInt32 native_thread = 0;
 		HANDLE thandle;
 		unsigned tid;
 		
 		thandle = (HANDLE) _beginthreadex(
 						NULL,
 						stackSize,
 						(unsigned (__stdcall *)(void *))start,
 						arg,
-						0,
+						STACK_SIZE_PARAM_IS_A_RESERVATION,
 						&tid);		
 		return((PRThread *) thandle);
 #endif
 	} else {
 		return(PR_CreateThread(type,start,arg,priority,scope,state,stackSize));
 	}
 #else
 	return(PR_CreateThread(type,start,arg,priority,scope,state,stackSize));