From 33189e787b98c79bd03be466ec19dfb2f65eb65f Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 13 Sep 2004 22:38:11 +0000 Subject: 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 --- lib/System/Linux/Memory.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lib/System/Linux/Memory.cpp') diff --git a/lib/System/Linux/Memory.cpp b/lib/System/Linux/Memory.cpp index 1bc6fd98bb..1a55ad8a19 100644 --- a/lib/System/Linux/Memory.cpp +++ b/lib/System/Linux/Memory.cpp @@ -30,8 +30,8 @@ using namespace sys; /// to emit code to the memory then jump to it. Getting this type of memory /// is very OS specific. /// -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; @@ -43,14 +43,15 @@ void* Memory::AllocateRWX(Memory& M, unsigned NumBytes) { strerror_r(errno, msg, MAXPATHLEN-1); throw std::string("Can't allocate RWX Memory: ") + msg; } - M.Address = pa; - M.AllocSize = NumPages*pageSize; - return pa; + MemoryBlock result; + result.Address = pa; + result.Size = 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)) { char msg[MAXPATHLEN]; strerror_r(errno, msg, MAXPATHLEN-1); throw std::string("Can't release RWX Memory: ") + msg; -- cgit v1.2.3-18-g5258