aboutsummaryrefslogtreecommitdiff
path: root/src/llvmext/RustWrapper.cpp
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-03-15 14:57:26 -0700
committerPatrick Walton <[email protected]>2011-03-15 14:58:11 -0700
commit736969f9fe49b17174c6e06fbb7b1a8331ca94b2 (patch)
tree762d10760333efd5c9db1bf81007c7c78081fa30 /src/llvmext/RustWrapper.cpp
parentChange the numbering of upcall functions. upcall_0 now calls a function (diff)
downloadrust-736969f9fe49b17174c6e06fbb7b1a8331ca94b2.tar.xz
rust-736969f9fe49b17174c6e06fbb7b1a8331ca94b2.zip
rustc: Add support for LLVM memory buffer creation via a wrapper function
Diffstat (limited to 'src/llvmext/RustWrapper.cpp')
-rw-r--r--src/llvmext/RustWrapper.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/llvmext/RustWrapper.cpp b/src/llvmext/RustWrapper.cpp
new file mode 100644
index 00000000..a604e4c2
--- /dev/null
+++ b/src/llvmext/RustWrapper.cpp
@@ -0,0 +1,31 @@
+//===- RustWrapper.cpp - Rust wrapper for core functions --------*- 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 alternate interfaces to core functions that are more
+// readily callable by Rust's FFI.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm-c/Core.h"
+#include "llvm-c/Object.h"
+#include <cstdlib>
+
+static char *LLVMRustError;
+
+extern "C" LLVMMemoryBufferRef
+LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
+ LLVMMemoryBufferRef MemBuf = NULL;
+ LLVMCreateMemoryBufferWithContentsOfFile(Path, &MemBuf, &LLVMRustError);
+ return MemBuf;
+}
+
+extern "C" const char *LLVMRustGetLastError(void) {
+ return LLVMRustError;
+}
+