mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 526586 - XULRunner crashes on startup on Windows r=bustage fix and at least agreement on the approach from dbaron
This commit is contained in:
parent
4721d50556
commit
80f60eef3f
@ -1182,7 +1182,7 @@ Fault(const char *msg, PtrInfo *pi)
|
||||
static inline bool
|
||||
CheckMainThreadIfFast()
|
||||
{
|
||||
#ifdef NS_TLS
|
||||
#if defined(XP_WIN) || defined(NS_TLS)
|
||||
return NS_IsMainThread();
|
||||
#else
|
||||
return true;
|
||||
|
@ -466,9 +466,7 @@ typedef PRUint32 nsrefcnt;
|
||||
#define XPCOM_GLUE_AVOID_NSPR
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(WINCE)
|
||||
#define NS_TLS __declspec(thread)
|
||||
#elif defined(HAVE_THREAD_TLS_KEYWORD)
|
||||
#if defined(HAVE_THREAD_TLS_KEYWORD)
|
||||
#define NS_TLS __thread
|
||||
#endif
|
||||
|
||||
|
@ -46,6 +46,10 @@
|
||||
# include "nsServiceManagerUtils.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifndef XPCOM_GLUE_AVOID_NSPR
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsRunnable, nsIRunnable)
|
||||
@ -126,6 +130,13 @@ bool NS_IsMainThread()
|
||||
mgr->GetIsMainThread(&result);
|
||||
return bool(result);
|
||||
}
|
||||
#elif defined(XP_WIN)
|
||||
extern DWORD gTLSIsMainThreadIndex;
|
||||
bool
|
||||
NS_IsMainThread()
|
||||
{
|
||||
return !!TlsGetValue(gTLSIsMainThreadIndex);
|
||||
}
|
||||
#elif !defined(NS_TLS)
|
||||
bool NS_IsMainThread()
|
||||
{
|
||||
|
@ -98,7 +98,11 @@ NS_GetCurrentThread(nsIThread **result);
|
||||
extern NS_COM_GLUE NS_METHOD
|
||||
NS_GetMainThread(nsIThread **result);
|
||||
|
||||
#if defined(MOZILLA_INTERNAL_API) && defined(NS_TLS)
|
||||
#if defined(MOZILLA_INTERNAL_API) && defined(XP_WIN)
|
||||
|
||||
NS_COM bool NS_IsMainThread();
|
||||
|
||||
#elif defined(MOZILLA_INTERNAL_API) && defined(NS_TLS)
|
||||
// This is defined in nsThreadManager.cpp and initialized to `true` for the
|
||||
// main thread by nsThreadManager::Init.
|
||||
extern NS_TLS bool gTLSIsMainThread;
|
||||
|
@ -44,7 +44,10 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsAutoLock.h"
|
||||
|
||||
#ifdef NS_TLS
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
DWORD gTLSIsMainThreadIndex = TlsAlloc();
|
||||
#elif defined(NS_TLS)
|
||||
NS_TLS bool gTLSIsMainThread = false;
|
||||
#endif
|
||||
|
||||
@ -106,7 +109,9 @@ nsThreadManager::Init()
|
||||
// GetIsMainThread calls that occur post-Shutdown.
|
||||
mMainThread->GetPRThread(&mMainPRThread);
|
||||
|
||||
#ifdef NS_TLS
|
||||
#ifdef XP_WIN
|
||||
TlsSetValue(gTLSIsMainThreadIndex, (void*) 1);
|
||||
#elif defined(NS_TLS)
|
||||
gTLSIsMainThread = true;
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user