src/os/aix/vm/os_aix.cpp

Print this page
rev 7454 : 8067015: Implement os::pd_map_memory() on AIX


4127         *bytes = n;
4128         return 1;
4129       }
4130     }
4131   }
4132   if ((cur = ::lseek64(fd, 0L, SEEK_CUR)) == -1) {
4133     return 0;
4134   } else if ((end = ::lseek64(fd, 0L, SEEK_END)) == -1) {
4135     return 0;
4136   } else if (::lseek64(fd, cur, SEEK_SET) == -1) {
4137     return 0;
4138   }
4139   *bytes = end - cur;
4140   return 1;
4141 }
4142 
4143 // Map a block of memory.
4144 char* os::pd_map_memory(int fd, const char* file_name, size_t file_offset,
4145                         char *addr, size_t bytes, bool read_only,
4146                         bool allow_exec) {
4147   Unimplemented();



















4148   return NULL;


4149 }
4150 
4151 
4152 // Remap a block of memory.
4153 char* os::pd_remap_memory(int fd, const char* file_name, size_t file_offset,
4154                           char *addr, size_t bytes, bool read_only,
4155                           bool allow_exec) {
4156   // same as map_memory() on this OS
4157   return os::map_memory(fd, file_name, file_offset, addr, bytes, read_only,
4158                         allow_exec);
4159 }
4160 
4161 // Unmap a block of memory.
4162 bool os::pd_unmap_memory(char* addr, size_t bytes) {
4163   return munmap(addr, bytes) == 0;
4164 }
4165 
4166 // current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool)
4167 // are used by JVM M&M and JVMTI to get user+sys or user CPU time
4168 // of a thread.




4127         *bytes = n;
4128         return 1;
4129       }
4130     }
4131   }
4132   if ((cur = ::lseek64(fd, 0L, SEEK_CUR)) == -1) {
4133     return 0;
4134   } else if ((end = ::lseek64(fd, 0L, SEEK_END)) == -1) {
4135     return 0;
4136   } else if (::lseek64(fd, cur, SEEK_SET) == -1) {
4137     return 0;
4138   }
4139   *bytes = end - cur;
4140   return 1;
4141 }
4142 
4143 // Map a block of memory.
4144 char* os::pd_map_memory(int fd, const char* file_name, size_t file_offset,
4145                         char *addr, size_t bytes, bool read_only,
4146                         bool allow_exec) {
4147   int prot;
4148   int flags = MAP_PRIVATE;
4149 
4150   if (read_only) {
4151     prot = PROT_READ;
4152   } else {
4153     prot = PROT_READ | PROT_WRITE;
4154   }
4155 
4156   if (allow_exec) {
4157     prot |= PROT_EXEC;
4158   }
4159 
4160   if (addr != NULL) {
4161     flags |= MAP_FIXED;
4162   }
4163 
4164   char* mapped_address = (char*)mmap(addr, (size_t)bytes, prot, flags,
4165                                      fd, file_offset);
4166   if (mapped_address == MAP_FAILED) {
4167     return NULL;
4168   }
4169   return mapped_address;
4170 }
4171 
4172 
4173 // Remap a block of memory.
4174 char* os::pd_remap_memory(int fd, const char* file_name, size_t file_offset,
4175                           char *addr, size_t bytes, bool read_only,
4176                           bool allow_exec) {
4177   // same as map_memory() on this OS
4178   return os::map_memory(fd, file_name, file_offset, addr, bytes, read_only,
4179                         allow_exec);
4180 }
4181 
4182 // Unmap a block of memory.
4183 bool os::pd_unmap_memory(char* addr, size_t bytes) {
4184   return munmap(addr, bytes) == 0;
4185 }
4186 
4187 // current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool)
4188 // are used by JVM M&M and JVMTI to get user+sys or user CPU time
4189 // of a thread.