diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2011-10-15 01:58:16 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2011-10-15 01:58:16 +0000 |
commit | 7bc976a8ef24745d7c884bf5b0b720eb79348eab (patch) | |
tree | 62c7a95625a128229aa383f2811ad1392837c292 /llvm/lib/Support/Windows | |
parent | d50861c83130480ce279f210523e6978b9631cb7 (diff) | |
download | bcm5719-llvm-7bc976a8ef24745d7c884bf5b0b720eb79348eab.tar.gz bcm5719-llvm-7bc976a8ef24745d7c884bf5b0b720eb79348eab.zip |
Windows/Memory.inc: Support the ability to allocate memory "near" another block of memory on Win32. It has fixed FIXME.
Thanks to Aaron Ballman!
llvm-svn: 142039
Diffstat (limited to 'llvm/lib/Support/Windows')
-rw-r--r-- | llvm/lib/Support/Windows/Memory.inc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Support/Windows/Memory.inc b/llvm/lib/Support/Windows/Memory.inc index 8609d39dd6d..fcc72837c45 100644 --- a/llvm/lib/Support/Windows/Memory.inc +++ b/llvm/lib/Support/Windows/Memory.inc @@ -32,11 +32,16 @@ MemoryBlock Memory::AllocateRWX(size_t NumBytes, static const size_t pageSize = Process::GetPageSize(); size_t NumPages = (NumBytes+pageSize-1)/pageSize; - //FIXME: support NearBlock if ever needed on Win64. + PVOID start = NearBlock ? static_cast<unsigned char *>(NearBlock->base()) + + NearBlock->size() : NULL; - void *pa = VirtualAlloc(NULL, NumPages*pageSize, MEM_COMMIT, + void *pa = VirtualAlloc(start, NumPages*pageSize, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (pa == NULL) { + if (NearBlock) { + // Try again without the NearBlock hint + return AllocateRWX(NumBytes, NULL, ErrMsg); + } MakeErrMsg(ErrMsg, "Can't allocate RWX Memory: "); return MemoryBlock(); } |