diff --git a/mozilla/nsprpub/config/prdepend.h b/mozilla/nsprpub/config/prdepend.h index 28c1b139d11..8bebd56b5d7 100644 --- a/mozilla/nsprpub/config/prdepend.h +++ b/mozilla/nsprpub/config/prdepend.h @@ -39,4 +39,3 @@ */ #error "Do not include this header file." - diff --git a/mozilla/nsprpub/pr/include/md/_win95.h b/mozilla/nsprpub/pr/include/md/_win95.h index 3a71acf6798..44f3e531e44 100644 --- a/mozilla/nsprpub/pr/include/md/_win95.h +++ b/mozilla/nsprpub/pr/include/md/_win95.h @@ -112,6 +112,9 @@ struct _MDThread { struct PRThread *prev, *next; /* used by the cvar wait queue to * chain the PRThread structures * together */ + void (*start)(void *); /* used by _PR_MD_CREATE_THREAD to + * pass its 'start' argument to + * pr_root. */ }; struct _MDThreadStack { diff --git a/mozilla/nsprpub/pr/include/md/_winnt.h b/mozilla/nsprpub/pr/include/md/_winnt.h index 6dcc991bf04..1e7fe6d31a9 100644 --- a/mozilla/nsprpub/pr/include/md/_winnt.h +++ b/mozilla/nsprpub/pr/include/md/_winnt.h @@ -172,6 +172,9 @@ struct _MDThread { void *fiber_arg; /* arg to main fiber routine */ PRUint32 fiber_stacksize; /* stacksize for fiber */ PRInt32 fiber_last_error; /* last error for the fiber */ + void (*start)(void *); /* used by _PR_MD_CREATE_THREAD to + * pass its 'start' argument to + * pr_root. */ }; struct _MDThreadStack { diff --git a/mozilla/nsprpub/pr/src/md/windows/ntthread.c b/mozilla/nsprpub/pr/src/md/windows/ntthread.c index a414e5c7871..0e7ef6e00a7 100644 --- a/mozilla/nsprpub/pr/src/md/windows/ntthread.c +++ b/mozilla/nsprpub/pr/src/md/windows/ntthread.c @@ -191,6 +191,14 @@ _PR_MD_INIT_THREAD(PRThread *thread) return PR_SUCCESS; } +static unsigned __stdcall +pr_root(void *arg) +{ + PRThread *thread = (PRThread *)arg; + thread->md.start(thread); + return 0; +} + PRStatus _PR_MD_CREATE_THREAD(PRThread *thread, void (*start)(void *), @@ -200,23 +208,14 @@ _PR_MD_CREATE_THREAD(PRThread *thread, PRUint32 stackSize) { -#if 0 - thread->md.handle = CreateThread( - NULL, /* security attrib */ - thread->stack->stackSize, /* stack size */ - (LPTHREAD_START_ROUTINE)start, /* startup routine */ - (void *)thread, /* thread param */ - CREATE_SUSPENDED, /* create flags */ - &(thread->id) ); /* thread id */ -#else + thread->md.start = start; thread->md.handle = (HANDLE) _beginthreadex( NULL, thread->stack->stackSize, - (unsigned (__stdcall *)(void *))start, + pr_root, (void *)thread, CREATE_SUSPENDED, &(thread->id)); -#endif if(!thread->md.handle) { PRErrorCode prerror; thread->md.fiber_last_error = GetLastError(); diff --git a/mozilla/nsprpub/pr/src/md/windows/w95thred.c b/mozilla/nsprpub/pr/src/md/windows/w95thred.c index f8a70043c50..f2519f421c3 100644 --- a/mozilla/nsprpub/pr/src/md/windows/w95thred.c +++ b/mozilla/nsprpub/pr/src/md/windows/w95thred.c @@ -106,6 +106,14 @@ _PR_MD_INIT_THREAD(PRThread *thread) return PR_SUCCESS; } +static unsigned __stdcall +pr_root(void *arg) +{ + PRThread *thread = (PRThread *)arg; + thread->md.start(thread); + return 0; +} + PRStatus _PR_MD_CREATE_THREAD(PRThread *thread, void (*start)(void *), @@ -115,14 +123,11 @@ _PR_MD_CREATE_THREAD(PRThread *thread, PRUint32 stackSize) { + thread->md.start = start; thread->md.handle = (HANDLE) _beginthreadex( NULL, thread->stack->stackSize, -#if defined(__MINGW32__) - (void *)start, -#else - (unsigned (__stdcall *)(void *))start, -#endif + pr_root, (void *)thread, CREATE_SUSPENDED, &(thread->id));