[PATCH][llvm-c] Create Memory Buffer with memory ranges
Chris Lattner
clattner at apple.com
Tue Feb 12 20:46:50 PST 2013
On Feb 10, 2013, at 9:13 AM, Moritz Maxeiner <moritzmaxeiner at googlemail.com> wrote:
> Add two new functions to the C API:
>
> LLVMCreateMemoryBufferWithMemoryRange - exposes MemoryBuffer::getMemBuffer
> LLVMCreateMemoryBufferWithMemoryRangeCopy - exposes MemoryBuffer::getMemBufferCopy
These new APIs should take a "const char*" + length. The memory buffer may have embedded nul's in it.
-Chris
>
> 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);
> }
>
>
> <llvm-c_mbrange.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list