diff options
| author | Owen Anderson <resistor@mac.com> | 2009-06-23 00:02:39 +0000 | 
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2009-06-23 00:02:39 +0000 | 
| commit | bee30f58fb3f65d980fa15c14aa9546145521619 (patch) | |
| tree | 9f2bad2edf1e0a98cbf513d52114360e6f1216d1 /llvm/lib/Support | |
| parent | 412190b067a688a50b047c441418b8dea8f407ab (diff) | |
| download | bcm5719-llvm-bee30f58fb3f65d980fa15c14aa9546145521619.tar.gz bcm5719-llvm-bee30f58fb3f65d980fa15c14aa9546145521619.zip  | |
Guard the plugin loader.
llvm-svn: 73925
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/PluginLoader.cpp | 5 | 
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Support/PluginLoader.cpp b/llvm/lib/Support/PluginLoader.cpp index 5acf1d13ee9..ef32af4b3f3 100644 --- a/llvm/lib/Support/PluginLoader.cpp +++ b/llvm/lib/Support/PluginLoader.cpp @@ -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 @@ void PluginLoader::operator=(const std::string &Filename) {  }  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];  | 

