1094
1095 // return the size of the file for the given file descriptor
1096 // or 0 if it is not a valid size for a shared memory file
1097 //
1098 static size_t sharedmem_filesize(int fd, TRAPS) {
1099
1100 struct stat statbuf;
1101 int result;
1102
1103 RESTARTABLE(::fstat(fd, &statbuf), result);
1104 if (result == OS_ERR) {
1105 if (PrintMiscellaneous && Verbose) {
1106 warning("fstat failed: %s\n", os::strerror(errno));
1107 }
1108 THROW_MSG_0(vmSymbols::java_io_IOException(),
1109 "Could not determine PerfMemory size");
1110 }
1111
1112 if ((statbuf.st_size == 0) ||
1113 ((size_t)statbuf.st_size % os::vm_page_size() != 0)) {
1114 THROW_MSG_0(vmSymbols::java_lang_Exception(),
1115 "Invalid PerfMemory size");
1116 }
1117
1118 return (size_t)statbuf.st_size;
1119 }
1120
1121 // attach to a named shared memory region.
1122 //
1123 static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemoryMode mode, char** addr, size_t* sizep, TRAPS) {
1124
1125 char* mapAddress;
1126 int result;
1127 int fd;
1128 size_t size = 0;
1129 const char* luser = NULL;
1130
1131 int mmap_prot;
1132 int file_flags;
1133
1134 ResourceMark rm;
|
1094
1095 // return the size of the file for the given file descriptor
1096 // or 0 if it is not a valid size for a shared memory file
1097 //
1098 static size_t sharedmem_filesize(int fd, TRAPS) {
1099
1100 struct stat statbuf;
1101 int result;
1102
1103 RESTARTABLE(::fstat(fd, &statbuf), result);
1104 if (result == OS_ERR) {
1105 if (PrintMiscellaneous && Verbose) {
1106 warning("fstat failed: %s\n", os::strerror(errno));
1107 }
1108 THROW_MSG_0(vmSymbols::java_io_IOException(),
1109 "Could not determine PerfMemory size");
1110 }
1111
1112 if ((statbuf.st_size == 0) ||
1113 ((size_t)statbuf.st_size % os::vm_page_size() != 0)) {
1114 THROW_MSG_0(vmSymbols::java_io_IOException(),
1115 "Invalid PerfMemory size");
1116 }
1117
1118 return (size_t)statbuf.st_size;
1119 }
1120
1121 // attach to a named shared memory region.
1122 //
1123 static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemoryMode mode, char** addr, size_t* sizep, TRAPS) {
1124
1125 char* mapAddress;
1126 int result;
1127 int fd;
1128 size_t size = 0;
1129 const char* luser = NULL;
1130
1131 int mmap_prot;
1132 int file_flags;
1133
1134 ResourceMark rm;
|