aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/Unix/Memory.inc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/Unix/Memory.inc')
-rw-r--r--lib/Support/Unix/Memory.inc10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Support/Unix/Memory.inc b/lib/Support/Unix/Memory.inc
index 9a8abd27f1..f4cfbc65cf 100644
--- a/lib/Support/Unix/Memory.inc
+++ b/lib/Support/Unix/Memory.inc
@@ -12,9 +12,11 @@
//===----------------------------------------------------------------------===//
#include "Unix.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Process.h"
+#include "llvm/Support/Debug.h"
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
@@ -145,8 +147,12 @@ Memory::protectMappedMemory(const MemoryBlock &M, unsigned Flags) {
return error_code(EINVAL, generic_category());
int Protect = getPosixProtectionFlags(Flags);
-
+#ifndef __native_client__
int Result = ::mprotect(M.Address, M.Size, Protect);
+#else
+ int Result = -1;
+ llvm_unreachable("Native client does not support mprotect");
+#endif
if (Result != 0)
return error_code(errno, system_category());
@@ -194,8 +200,10 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock,
void *pa = ::mmap(start, pageSize*NumPages, PROT_READ|PROT_EXEC,
flags, fd, 0);
#else
+dbgs() << "calling mmap, start " << start << "\n";
void *pa = ::mmap(start, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
flags, fd, 0);
+ DEBUG(dbgs() << "mmap returned " << pa<<"\n");
#endif
if (pa == MAP_FAILED) {
if (NearBlock) //Try again without a near hint