8067015: Implement os::pd_map_memory() on AIX
authorsimonis
Wed, 10 Dec 2014 19:12:27 +0100
changeset 27927 354a5ba966a9
parent 27926 0e2e188ab887
child 27928 c12e49897c5a
8067015: Implement os::pd_map_memory() on AIX Reviewed-by: dholmes
hotspot/src/os/aix/vm/os_aix.cpp
--- a/hotspot/src/os/aix/vm/os_aix.cpp	Fri Dec 05 16:36:07 2014 -0800
+++ b/hotspot/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;
 }