aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/DynamicLibrary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/DynamicLibrary.cpp')
-rw-r--r--llvm/lib/Support/DynamicLibrary.cpp26
1 files changed, 1 insertions, 25 deletions
diff --git a/llvm/lib/Support/DynamicLibrary.cpp b/llvm/lib/Support/DynamicLibrary.cpp
index d3983fb..74d94d3 100644
--- a/llvm/lib/Support/DynamicLibrary.cpp
+++ b/llvm/lib/Support/DynamicLibrary.cpp
@@ -68,34 +68,10 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
handle = RTLD_DEFAULT;
#endif
- DynamicLibrary dyLib = addPermanentLibraryWithLock(handle, lock, !filename);
-
// If we've already loaded this library, dlclose() the handle in order to
// keep the internal refcount at +1.
- if (!dyLib.isValid()) {
- if (errMsg)
- *errMsg = (filename) ? std::string(filename) : std::string() +
- ": Library already loaded";
+ if (!OpenedHandles->insert(handle).second)
dlclose(handle);
- }
-
- return dyLib;
-}
-
-DynamicLibrary DynamicLibrary::addPermanentLibrary(void *handle) {
- SmartScopedLock<true> lock(*SymbolsMutex);
- return addPermanentLibraryWithLock(handle, lock, false);
-}
-
-DynamicLibrary DynamicLibrary::addPermanentLibraryWithLock(void *handle,
- sys::SmartScopedLock<true> &,
- bool isMainExec) {
- // If we've already loaded this library, tell the caller.
- // FIXME: Note that multiple requests for adding the main executable is not
- // considered as an error. If we don't want to treat the main executable as a
- // special case we need to do a cleanup in the MCJIT tests and API.
- if (!OpenedHandles->insert(handle).second && !isMainExec)
- return DynamicLibrary();
return DynamicLibrary(handle);
}