about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-03-21 23:06:42 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-03-21 23:06:42 -0700
commit7ac885ee8cb18fc2cb974cff06190532680cf29b (patch)
treef1a354cd2a763949a29856bac7e158d0f4f77b3b /src/rustllvm/RustWrapper.cpp
parent1e1ff638a3c920654c5f05c83b05e1e3b76e9782 (diff)
downloadrust-7ac885ee8cb18fc2cb974cff06190532680cf29b.tar.gz
rust-7ac885ee8cb18fc2cb974cff06190532680cf29b.zip
Repair some fallout from pcwalton's last few build changes.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
-rw-r--r--src/rustllvm/RustWrapper.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
new file mode 100644
index 00000000000..a604e4c29c5
--- /dev/null
+++ b/src/rustllvm/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;
+}
+