mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-05 09:24:28 +00:00
Simplify the sys::Memory interface per Chris' request.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16318 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -26,8 +26,8 @@ using namespace sys;
|
||||
//=== and must not be generic UNIX code (see ../Unix/Memory.cpp)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void* Memory::AllocateRWX(Memory& M, unsigned NumBytes) {
|
||||
if (NumBytes == 0) return 0;
|
||||
MemoryBlock Memory::AllocateRWX(unsigned NumBytes) {
|
||||
if (NumBytes == 0) return MemoryBlock();
|
||||
|
||||
static const long pageSize = Process::GetPageSize();
|
||||
unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
|
||||
@ -37,14 +37,15 @@ void* Memory::AllocateRWX(Memory& M, unsigned NumBytes) {
|
||||
if (pa == (void*)-1) {
|
||||
throw std::string("Can't allocate RWX Memory: ") + strerror(errno);
|
||||
}
|
||||
M.Address = pa;
|
||||
M.AllocSize = NumPages*pageSize;
|
||||
return pa;
|
||||
MemoryBlock result;
|
||||
result.Address = pa;
|
||||
result.AllocSize = NumPages*pageSize;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Memory::ReleaseRWX(Memory& M) {
|
||||
if (M.Address == 0 || M.AllocSize == 0) return;
|
||||
if (0 != munmap(M.Address, M.AllocSize)) {
|
||||
void Memory::ReleaseRWX(MemoryBlock& M) {
|
||||
if (M.Address == 0 || M.Size == 0) return;
|
||||
if (0 != munmap(M.Address, M.Size)) {
|
||||
throw std::string("Can't release RWX Memory: ") + strerror(errno);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user