Recommit r310809 with a fix for the spill problem
[llvm-core.git] / bindings / go / llvm / SupportBindings.cpp
blob5e251b7da09232480b6fcf4fe61827ce6267f6f3
1 //===- SupportBindings.cpp - Additional bindings for support --------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines additional C bindings for the support component.
12 //===----------------------------------------------------------------------===//
14 #include "SupportBindings.h"
15 #include "llvm/Support/DynamicLibrary.h"
16 #include <stdlib.h>
17 #include <string.h>
19 void LLVMLoadLibraryPermanently2(const char *Filename, char **ErrMsg) {
20 std::string ErrMsgStr;
21 if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Filename, &ErrMsgStr)) {
22 *ErrMsg = static_cast<char *>(malloc(ErrMsgStr.size() + 1));
23 memcpy(static_cast<void *>(*ErrMsg),
24 static_cast<const void *>(ErrMsgStr.c_str()), ErrMsgStr.size() + 1);