aboutsummaryrefslogtreecommitdiff
path: root/lib/System/FreeBSD/Memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/System/FreeBSD/Memory.cpp')
-rw-r--r--lib/System/FreeBSD/Memory.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/System/FreeBSD/Memory.cpp b/lib/System/FreeBSD/Memory.cpp
index eeb22e910b..4ab1a5dcc1 100644
--- a/lib/System/FreeBSD/Memory.cpp
+++ b/lib/System/FreeBSD/Memory.cpp
@@ -25,8 +25,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;
@@ -36,14 +36,16 @@ 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.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)) {
+ 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);
}
}