[PATCH][llvm-c] Create Memory Buffer with memory ranges
Moritz Maxeiner
moritzmaxeiner at googlemail.com
Sun Feb 10 09:13:14 PST 2013
Add two new functions to the C API:
LLVMCreateMemoryBufferWithMemoryRange - exposes MemoryBuffer::getMemBuffer
LLVMCreateMemoryBufferWithMemoryRangeCopy - exposes
MemoryBuffer::getMemBufferCopy
Index: include/llvm-c/Core.h
===================================================================
--- include/llvm-c/Core.h (revision 170197)
+++ include/llvm-c/Core.h (working copy)
@@ -2547,6 +2547,11 @@
char **OutMessage);
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
char **OutMessage);
+LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char
*InputData,
+ const char
*BufferName,
+ bool
RequiresNullTerminator);
+LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const
char *InputData,
+ const char *BufferName);
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
/**
Index: lib/VMCore/Core.cpp
===================================================================
--- lib/VMCore/Core.cpp (revision 170197)
+++ lib/VMCore/Core.cpp (working copy)
@@ -2364,6 +2364,26 @@
return 1;
}
+LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(
+ const char *InputData,
+ const char *BufferName,
+ bool RequiresNullTerminator) {
+
+ return wrap(MemoryBuffer::getMemBuffer(
+ StringRef(InputData),
+ StringRef(BufferName),
+ RequiresNullTerminator));
+}
+
+LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(
+ const char *InputData,
+ const char *BufferName) {
+
+ return wrap(MemoryBuffer::getMemBufferCopy(
+ StringRef(InputData),
+ StringRef(BufferName)));
+}
+
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf) {
delete unwrap(MemBuf);
}
-------------- next part --------------
Index: include/llvm-c/Core.h
===================================================================
--- include/llvm-c/Core.h (revision 170197)
+++ include/llvm-c/Core.h (working copy)
@@ -2547,6 +2547,11 @@
char **OutMessage);
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
char **OutMessage);
+LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
+ const char *BufferName,
+ bool RequiresNullTerminator);
+LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
+ const char *BufferName);
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
/**
Index: lib/VMCore/Core.cpp
===================================================================
--- lib/VMCore/Core.cpp (revision 170197)
+++ lib/VMCore/Core.cpp (working copy)
@@ -2364,6 +2364,26 @@
return 1;
}
+LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(
+ const char *InputData,
+ const char *BufferName,
+ bool RequiresNullTerminator) {
+
+ return wrap(MemoryBuffer::getMemBuffer(
+ StringRef(InputData),
+ StringRef(BufferName),
+ RequiresNullTerminator));
+}
+
+LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(
+ const char *InputData,
+ const char *BufferName) {
+
+ return wrap(MemoryBuffer::getMemBufferCopy(
+ StringRef(InputData),
+ StringRef(BufferName)));
+}
+
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf) {
delete unwrap(MemBuf);
}
More information about the llvm-commits
mailing list