[llvm-commits] [llvm] r73925 - /llvm/trunk/lib/Support/PluginLoader.cpp
Owen Anderson
resistor at mac.com
Mon Jun 22 17:02:39 PDT 2009
Author: resistor
Date: Mon Jun 22 19:02:39 2009
New Revision: 73925
URL: http://llvm.org/viewvc/llvm-project?rev=73925&view=rev
Log:
Guard the plugin loader.
Modified:
llvm/trunk/lib/Support/PluginLoader.cpp
Modified: llvm/trunk/lib/Support/PluginLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PluginLoader.cpp?rev=73925&r1=73924&r2=73925&view=diff
==============================================================================
--- llvm/trunk/lib/Support/PluginLoader.cpp (original)
+++ llvm/trunk/lib/Support/PluginLoader.cpp Mon Jun 22 19:02:39 2009
@@ -16,13 +16,16 @@
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/DynamicLibrary.h"
+#include "llvm/System/Mutex.h"
#include <ostream>
#include <vector>
using namespace llvm;
static ManagedStatic<std::vector<std::string> > Plugins;
+static ManagedStatic<sys::SmartMutex<true> > PluginsLock;
void PluginLoader::operator=(const std::string &Filename) {
+ sys::SmartScopedLock<true> Lock(&*PluginsLock);
std::string Error;
if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
cerr << "Error opening '" << Filename << "': " << Error
@@ -33,10 +36,12 @@
}
unsigned PluginLoader::getNumPlugins() {
+ sys::SmartScopedLock<true> Lock(&*PluginsLock);
return Plugins.isConstructed() ? Plugins->size() : 0;
}
std::string &PluginLoader::getPlugin(unsigned num) {
+ sys::SmartScopedLock<true> Lock(&*PluginsLock);
assert(Plugins.isConstructed() && num < Plugins->size() &&
"Asking for an out of bounds plugin");
return (*Plugins)[num];
More information about the llvm-commits
mailing list