[llvm-commits] CVS: llvm/lib/System/Darwin/Memory.cpp

Reid Spencer reid at x10sys.com
Mon Sep 13 15:38:24 PDT 2004



Changes in directory llvm/lib/System/Darwin:

Memory.cpp updated: 1.1 -> 1.2
---
Log message:

Simplify the sys::Memory interface per Chris' request.


---
Diffs of the changes:  (+9 -8)

Index: llvm/lib/System/Darwin/Memory.cpp
diff -u llvm/lib/System/Darwin/Memory.cpp:1.1 llvm/lib/System/Darwin/Memory.cpp:1.2
--- llvm/lib/System/Darwin/Memory.cpp:1.1	Fri Sep 10 23:59:30 2004
+++ llvm/lib/System/Darwin/Memory.cpp	Mon Sep 13 17:38:12 2004
@@ -30,8 +30,8 @@
 /// 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 @@
     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;






More information about the llvm-commits mailing list