diff options
author | Vassil Vassilev <v.g.vassilev@gmail.com> | 2017-03-02 17:56:45 +0000 |
---|---|---|
committer | Vassil Vassilev <v.g.vassilev@gmail.com> | 2017-03-02 17:56:45 +0000 |
commit | 7f1c255dfe8e6559c6181901a1420b3e06ef2a5c (patch) | |
tree | 3c0ea16a147d7abe2f1127a78bee45881d7606c3 /llvm/include/llvm/Support/DynamicLibrary.h | |
parent | 8139eab3c3b50155e5333f201745765e9492e3d3 (diff) | |
download | bcm5719-llvm-7f1c255dfe8e6559c6181901a1420b3e06ef2a5c.tar.gz bcm5719-llvm-7f1c255dfe8e6559c6181901a1420b3e06ef2a5c.zip |
Reland r296442 with modifications reverted in r296463.
Original commit message:
"Allow externally dlopen-ed libraries to be registered as permanent libraries.
This is also useful in cases when llvm is in a shared library. First we dlopen
the llvm shared library and then we register it as a permanent library in order
to keep the JIT and other services working.
Patch reviewed by Vedant Kumar (D29955)!"
llvm-svn: 296774
Diffstat (limited to 'llvm/include/llvm/Support/DynamicLibrary.h')
-rw-r--r-- | llvm/include/llvm/Support/DynamicLibrary.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/DynamicLibrary.h b/llvm/include/llvm/Support/DynamicLibrary.h index a7d22212dbd..eda98b928a6 100644 --- a/llvm/include/llvm/Support/DynamicLibrary.h +++ b/llvm/include/llvm/Support/DynamicLibrary.h @@ -14,6 +14,8 @@ #ifndef LLVM_SUPPORT_DYNAMICLIBRARY_H #define LLVM_SUPPORT_DYNAMICLIBRARY_H +#include "llvm/Support/Mutex.h" + #include <string> namespace llvm { @@ -68,6 +70,15 @@ namespace sys { static DynamicLibrary getPermanentLibrary(const char *filename, std::string *errMsg = nullptr); + /// Registers an externally loaded library. The library will be unloaded + /// when the program terminates. + /// + /// It is safe to call this function multiple times for the same library. + /// + /// \returns An empty \p DynamicLibrary if the library was already loaded. + static DynamicLibrary addPermanentLibrary(void *handle, + std::string *errMsg = nullptr); + /// This function permanently loads the dynamic library at the given path. /// Use this instead of getPermanentLibrary() when you won't need to get /// symbols from the library itself. |