[llvm-commits] [llvm] r111307 - in /llvm/trunk: include/llvm/Support/CrashRecoveryContext.h lib/Support/CrashRecoveryContext.cpp
Daniel Dunbar
daniel at zuster.org
Tue Aug 17 15:32:34 PDT 2010
Author: ddunbar
Date: Tue Aug 17 17:32:34 2010
New Revision: 111307
URL: http://llvm.org/viewvc/llvm-project?rev=111307&view=rev
Log:
CrashRecovery: Make CrashRecoveryContext static methods thread safe.
Modified:
llvm/trunk/include/llvm/Support/CrashRecoveryContext.h
llvm/trunk/lib/Support/CrashRecoveryContext.cpp
Modified: llvm/trunk/include/llvm/Support/CrashRecoveryContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CrashRecoveryContext.h?rev=111307&r1=111306&r2=111307&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CrashRecoveryContext.h (original)
+++ llvm/trunk/include/llvm/Support/CrashRecoveryContext.h Tue Aug 17 17:32:34 2010
@@ -47,12 +47,10 @@
CrashRecoveryContext() : Impl(0) {}
~CrashRecoveryContext();
- /// \brief Enable crash recovery. This function is not thread safe, clients
- /// should call it during startup or with a lock held.
+ /// \brief Enable crash recovery.
static void Enable();
- /// \brief Disable crash recovery. This function is not thread safe, clients
- /// should call it during startup or with a lock held.
+ /// \brief Disable crash recovery.
static void Disable();
/// \brief Execute the provide callback function (with the given arguments) in
Modified: llvm/trunk/lib/Support/CrashRecoveryContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CrashRecoveryContext.cpp?rev=111307&r1=111306&r2=111307&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CrashRecoveryContext.cpp (original)
+++ llvm/trunk/lib/Support/CrashRecoveryContext.cpp Tue Aug 17 17:32:34 2010
@@ -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 @@
}
+static sys::Mutex gCrashRecoveryContexMutex;
static bool gCrashRecoveryEnabled = false;
CrashRecoveryContext::~CrashRecoveryContext() {
@@ -59,6 +61,8 @@
// FIXME: No real Win32 implementation currently.
void CrashRecoveryContext::Enable() {
+ sys::ScopedLock L(gCrashRecoveryContexMutex);
+
if (gCrashRecoveryEnabled)
return;
@@ -66,6 +70,8 @@
}
void CrashRecoveryContext::Disable() {
+ sys::ScopedLock L(gCrashRecoveryContexMutex);
+
if (!gCrashRecoveryEnabled)
return;
@@ -121,6 +127,8 @@
}
void CrashRecoveryContext::Enable() {
+ sys::ScopedLock L(gCrashRecoveryContexMutex);
+
if (gCrashRecoveryEnabled)
return;
@@ -138,6 +146,8 @@
}
void CrashRecoveryContext::Disable() {
+ sys::ScopedLock L(gCrashRecoveryContexMutex);
+
if (!gCrashRecoveryEnabled)
return;
More information about the llvm-commits
mailing list