changeset 7509:e7f380bee507

8067015: Implement os::pd_map_memory() on AIX Reviewed-by: dholmes
author simonis
date Wed, 10 Dec 2014 19:12:27 +0100
parents e2457e3f8c0e
children 65a9747147b8
files src/os/aix/vm/os_aix.cpp
diffstat 1 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/aix/vm/os_aix.cpp	Fri Dec 05 16:36:07 2014 -0800
+++ b/src/os/aix/vm/os_aix.cpp	Wed Dec 10 19:12:27 2014 +0100
@@ -4144,8 +4144,29 @@
 char* os::pd_map_memory(int fd, const char* file_name, size_t file_offset,
                         char *addr, size_t bytes, bool read_only,
                         bool allow_exec) {
-  Unimplemented();
-  return NULL;
+  int prot;
+  int flags = MAP_PRIVATE;
+
+  if (read_only) {
+    prot = PROT_READ;
+  } else {
+    prot = PROT_READ | PROT_WRITE;
+  }
+
+  if (allow_exec) {
+    prot |= PROT_EXEC;
+  }
+
+  if (addr != NULL) {
+    flags |= MAP_FIXED;
+  }
+
+  char* mapped_address = (char*)mmap(addr, (size_t)bytes, prot, flags,
+                                     fd, file_offset);
+  if (mapped_address == MAP_FAILED) {
+    return NULL;
+  }
+  return mapped_address;
 }