llvm.org GIT mirror llvm / 9a1c399
Merging r142039: ------------------------------------------------------------------------ r142039 | chapuni | 2011-10-14 18:58:16 -0700 (Fri, 14 Oct 2011) | 3 lines Windows/Memory.inc: Support the ability to allocate memory "near" another block of memory on Win32. It has fixed FIXME. Thanks to Aaron Ballman! ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_30@142095 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 8 years ago
1 changed file(s) with 7 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
3131 static const size_t pageSize = Process::GetPageSize();
3232 size_t NumPages = (NumBytes+pageSize-1)/pageSize;
3333
34 //FIXME: support NearBlock if ever needed on Win64.
34 PVOID start = NearBlock ? static_cast(NearBlock->base()) +
35 NearBlock->size() : NULL;
3536
36 void *pa = VirtualAlloc(NULL, NumPages*pageSize, MEM_COMMIT,
37 void *pa = VirtualAlloc(start, NumPages*pageSize, MEM_RESERVE | MEM_COMMIT,
3738 PAGE_EXECUTE_READWRITE);
3839 if (pa == NULL) {
40 if (NearBlock) {
41 // Try again without the NearBlock hint
42 return AllocateRWX(NumBytes, NULL, ErrMsg);
43 }
3944 MakeErrMsg(ErrMsg, "Can't allocate RWX Memory: ");
4045 return MemoryBlock();
4146 }