[llvm-c] Expose LLVMLoadLibraryPermanently
authorPeter Zotov <whitequark@whitequark.org>
Wed, 6 Nov 2013 09:21:31 +0000 (09:21 +0000)
committerPeter Zotov <whitequark@whitequark.org>
Wed, 6 Nov 2013 09:21:31 +0000 (09:21 +0000)
Original patch by Chris Wailes

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194139 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm-c/Support.h [new file with mode: 0644]
lib/Support/DynamicLibrary.cpp

diff --git a/include/llvm-c/Support.h b/include/llvm-c/Support.h
new file mode 100644 (file)
index 0000000..72af4e4
--- /dev/null
@@ -0,0 +1,36 @@
+/*===-- llvm-c/Support.h - Support C Interface --------------------*- C -*-===*\
+|*                                                                            *|
+|*                     The LLVM Compiler Infrastructure                       *|
+|*                                                                            *|
+|* This file is distributed under the University of Illinois Open Source      *|
+|* License. See LICENSE.TXT for details.                                      *|
+|*                                                                            *|
+|*===----------------------------------------------------------------------===*|
+|*                                                                            *|
+|* This file defines the C interface to the LLVM support library.             *|
+|*                                                                            *|
+\*===----------------------------------------------------------------------===*/
+
+#ifndef LLVM_C_SUPPORT_H
+#define LLVM_C_SUPPORT_H
+
+#include "llvm-c/Core.h"
+#include "llvm/Support/DynamicLibrary.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * This function permanently loads the dynamic library at the given path.
+ * It is safe to call this function multiple times for the same library.
+ *
+ * @see sys::DynamicLibrary::LoadLibraryPermanently()
+  */
+LLVMBool LLVMLoadLibraryPermanently(const char* Filename);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
index c063f5382d19e9e5311aa7c838232fb1fc163c06..f58a1f1c8f8f768731c0680500137bfa0a49c95e 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/Mutex.h"
+#include "llvm-c/Core.h"
 #include <cstdio>
 #include <cstring>
 
@@ -169,3 +170,11 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
 }
 
 #endif // LLVM_ON_WIN32
+
+//===----------------------------------------------------------------------===//
+// C API.
+//===----------------------------------------------------------------------===//
+
+LLVMBool LLVMLoadLibraryPermanently(const char* Filename) {
+  return sys::DynamicLibrary::LoadLibraryPermanently(Filename);
+}
\ No newline at end of file