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

Reid Spencer reid at x10sys.com
Sat Sep 18 12:34:20 PDT 2004



Changes in directory llvm/lib/System/Interix:

Memory.cpp updated: 1.3 -> 1.4
---
Log message:

Use the /dev/zero device as the device on which the pages are mapped.

Patch contributed by Henrik Bach. Thanks Henrik!


---
Diffs of the changes:  (+7 -1)

Index: llvm/lib/System/Interix/Memory.cpp
diff -u llvm/lib/System/Interix/Memory.cpp:1.3 llvm/lib/System/Interix/Memory.cpp:1.4
--- llvm/lib/System/Interix/Memory.cpp:1.3	Mon Sep 13 17:38:12 2004
+++ llvm/lib/System/Interix/Memory.cpp	Sat Sep 18 14:34:09 2004
@@ -15,6 +15,7 @@
 // Include the generic unix implementation
 #include "../Unix/Memory.cpp"
 #include "llvm/System/Process.h"
+#include <fcntl.h>
 #include <sys/mman.h>
 
 namespace llvm {
@@ -30,9 +31,14 @@
 
   static const long pageSize = Process::GetPageSize();
   unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
+  
+  int fd = open("/dev/zero", O_RDWR);
+  if (fd == -1) {
+    throw std::string("Can't open /dev/zero device: ") + strerror(errno);
+  }
 
   void *pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
-                  MAP_PRIVATE|MAP_ANON|MAP_NOCORE, -1, 0);
+                  MAP_SHARED, fd, 0);
   if (pa == (void*)-1) {
     throw std::string("Can't allocate RWX Memory: ") + strerror(errno);
   }






More information about the llvm-commits mailing list