[llvm-commits] CVS: llvm/lib/System/FreeBSD/Memory.cpp
Reid Spencer
reid at x10sys.com
Mon Sep 13 15:38:24 PDT 2004
Changes in directory llvm/lib/System/FreeBSD:
Memory.cpp updated: 1.2 -> 1.3
---
Log message:
Simplify the sys::Memory interface per Chris' request.
---
Diffs of the changes: (+9 -7)
Index: llvm/lib/System/FreeBSD/Memory.cpp
diff -u llvm/lib/System/FreeBSD/Memory.cpp:1.2 llvm/lib/System/FreeBSD/Memory.cpp:1.3
--- llvm/lib/System/FreeBSD/Memory.cpp:1.2 Sat Sep 11 15:18:08 2004
+++ llvm/lib/System/FreeBSD/Memory.cpp Mon Sep 13 17:38:12 2004
@@ -25,8 +25,8 @@
//=== 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 @@
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);
}
}
More information about the llvm-commits
mailing list