diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-09-18 19:34:09 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-09-18 19:34:09 +0000 |
commit | 111a3484359f66090acf8ea3d5a74583c0a75349 (patch) | |
tree | bb27659408268306a0b72510fbfa730c75155574 /lib | |
parent | d0c9e0ee0d56a8e00b413c77b5579533105d8275 (diff) | |
download | external_llvm-111a3484359f66090acf8ea3d5a74583c0a75349.zip external_llvm-111a3484359f66090acf8ea3d5a74583c0a75349.tar.gz external_llvm-111a3484359f66090acf8ea3d5a74583c0a75349.tar.bz2 |
Use the /dev/zero device as the device on which the pages are mapped.
Patch contributed by Henrik Bach. Thanks Henrik!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16397 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/System/Interix/Memory.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/System/Interix/Memory.cpp b/lib/System/Interix/Memory.cpp index 94e5893..771c99d 100644 --- a/lib/System/Interix/Memory.cpp +++ b/lib/System/Interix/Memory.cpp @@ -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 @@ MemoryBlock Memory::AllocateRWX(unsigned NumBytes) { 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); } |