diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-08-17 22:32:34 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-08-17 22:32:34 +0000 |
commit | ff329942cd7af409e923c55f34c646736b0c275f (patch) | |
tree | fbc97bd4af5ca62bda4117bd25120337c80343ff /llvm/lib/Support/CrashRecoveryContext.cpp | |
parent | 16f96445c3803eecf714c2ca571eddb84eb84f2a (diff) | |
download | bcm5719-llvm-ff329942cd7af409e923c55f34c646736b0c275f.tar.gz bcm5719-llvm-ff329942cd7af409e923c55f34c646736b0c275f.zip |
CrashRecovery: Make CrashRecoveryContext static methods thread safe.
llvm-svn: 111307
Diffstat (limited to 'llvm/lib/Support/CrashRecoveryContext.cpp')
-rw-r--r-- | llvm/lib/Support/CrashRecoveryContext.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp index de981325394..d1ecbb74dac 100644 --- a/llvm/lib/Support/CrashRecoveryContext.cpp +++ b/llvm/lib/Support/CrashRecoveryContext.cpp @@ -10,6 +10,7 @@ #include "llvm/Support/CrashRecoveryContext.h" #include "llvm/ADT/SmallString.h" #include "llvm/Config/config.h" +#include "llvm/System/Mutex.h" #include "llvm/System/ThreadLocal.h" #include <setjmp.h> #include <cstdio> @@ -47,6 +48,7 @@ public: } +static sys::Mutex gCrashRecoveryContexMutex; static bool gCrashRecoveryEnabled = false; CrashRecoveryContext::~CrashRecoveryContext() { @@ -59,6 +61,8 @@ CrashRecoveryContext::~CrashRecoveryContext() { // FIXME: No real Win32 implementation currently. void CrashRecoveryContext::Enable() { + sys::ScopedLock L(gCrashRecoveryContexMutex); + if (gCrashRecoveryEnabled) return; @@ -66,6 +70,8 @@ void CrashRecoveryContext::Enable() { } void CrashRecoveryContext::Disable() { + sys::ScopedLock L(gCrashRecoveryContexMutex); + if (!gCrashRecoveryEnabled) return; @@ -121,6 +127,8 @@ static void CrashRecoverySignalHandler(int Signal) { } void CrashRecoveryContext::Enable() { + sys::ScopedLock L(gCrashRecoveryContexMutex); + if (gCrashRecoveryEnabled) return; @@ -138,6 +146,8 @@ void CrashRecoveryContext::Enable() { } void CrashRecoveryContext::Disable() { + sys::ScopedLock L(gCrashRecoveryContexMutex); + if (!gCrashRecoveryEnabled) return; |