summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-09-18 19:34:09 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-09-18 19:34:09 +0000
commit91e6f5e975af31ef9bac6b5e17d277564388476d (patch)
tree27ca2bf1685c6dd2e8b6504b3942b72962bad419
parent0e86336edc9302c5dd6cdcdd0d3635d3b7059318 (diff)
downloadbcm5719-llvm-91e6f5e975af31ef9bac6b5e17d277564388476d.tar.gz
bcm5719-llvm-91e6f5e975af31ef9bac6b5e17d277564388476d.zip
Use the /dev/zero device as the device on which the pages are mapped.
Patch contributed by Henrik Bach. Thanks Henrik! llvm-svn: 16397
-rw-r--r--llvm/lib/System/Interix/Memory.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/System/Interix/Memory.cpp b/llvm/lib/System/Interix/Memory.cpp
index 94e58939328..771c99d1d30 100644
--- a/llvm/lib/System/Interix/Memory.cpp
+++ b/llvm/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);
}
OpenPOWER on IntegriCloud