< prev index next >
os/posix/os_posix.cpp
Print this page
rev 1 : G1GC+POGC+NVDIMM Patch with latest comments incorporated from all.
rev 2 : Removed fcntl and fixed hotspot else violation
*** 236,263 ****
#else
return posix_fallocate(fd, offset, len);
#endif
}
// Map the given address range to the provided file descriptor.
! char* os::map_memory_to_file(char* base, size_t size, int fd) {
assert(fd != -1, "File descriptor is not valid");
// allocate space for the file
! int ret = util_posix_fallocate(fd, 0, (off_t)size);
! if (ret != 0) {
! vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory. error(%d)", ret));
return NULL;
}
! int prot = PROT_READ | PROT_WRITE;
int flags = MAP_SHARED;
if (base != NULL) {
flags |= MAP_FIXED;
}
- char* addr = (char*)mmap(base, size, prot, flags, fd, 0);
if (addr == MAP_FAILED) {
warning("Failed mmap to file. (%s)", os::strerror(errno));
return NULL;
}
if (base != NULL && addr != base) {
--- 236,276 ----
#else
return posix_fallocate(fd, offset, len);
#endif
}
+ // Allocates space for the file on diven device
+ int os::allocate_file(int file_desc, size_t size) {
+ // allocate space for the file
+ if (file_desc == -1) {
+ vm_exit_during_initialization(err_msg("Invalid file descriptor passed (%d)", file_desc));
+ }
+ int ret = util_posix_fallocate(file_desc, 0, (off_t)size);
+ if (ret != 0) {
+ vm_exit_during_initialization(err_msg("Could not allocate file to map Java heap on given filesystem... error(%d)", ret));
+ }
+ return ret;
+ }
+
// Map the given address range to the provided file descriptor.
! char* os::map_memory_to_file(char* base, size_t size, int fd, int offset, bool exec, bool allocate) {
assert(fd != -1, "File descriptor is not valid");
// allocate space for the file
! if (allocate == true) {
! if (os::allocate_file(fd, size) != 0) {
return NULL;
}
+ }
! int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
int flags = MAP_SHARED;
if (base != NULL) {
flags |= MAP_FIXED;
}
+ char* addr = (char*)mmap(base, size, prot, flags, fd, offset);
if (addr == MAP_FAILED) {
warning("Failed mmap to file. (%s)", os::strerror(errno));
return NULL;
}
if (base != NULL && addr != base) {
< prev index next >