< prev index next >

src/hotspot/os/bsd/perfMemory_bsd.cpp

Print this page




1011 
1012 // return the size of the file for the given file descriptor
1013 // or 0 if it is not a valid size for a shared memory file
1014 //
1015 static size_t sharedmem_filesize(int fd, TRAPS) {
1016 
1017   struct stat statbuf;
1018   int result;
1019 
1020   RESTARTABLE(::fstat(fd, &statbuf), result);
1021   if (result == OS_ERR) {
1022     if (PrintMiscellaneous && Verbose) {
1023       warning("fstat failed: %s\n", os::strerror(errno));
1024     }
1025     THROW_MSG_0(vmSymbols::java_io_IOException(),
1026                 "Could not determine PerfMemory size");
1027   }
1028 
1029   if ((statbuf.st_size == 0) ||
1030      ((size_t)statbuf.st_size % os::vm_page_size() != 0)) {
1031     THROW_MSG_0(vmSymbols::java_io_IOException(),
1032                 "Invalid PerfMemory size");
1033   }
1034 
1035   return (size_t)statbuf.st_size;
1036 }
1037 
1038 // attach to a named shared memory region.
1039 //
1040 static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemoryMode mode, char** addr, size_t* sizep, TRAPS) {
1041 
1042   char* mapAddress;
1043   int result;
1044   int fd;
1045   size_t size = 0;
1046   const char* luser = NULL;
1047 
1048   int mmap_prot;
1049   int file_flags;
1050 
1051   ResourceMark rm;




1011 
1012 // return the size of the file for the given file descriptor
1013 // or 0 if it is not a valid size for a shared memory file
1014 //
1015 static size_t sharedmem_filesize(int fd, TRAPS) {
1016 
1017   struct stat statbuf;
1018   int result;
1019 
1020   RESTARTABLE(::fstat(fd, &statbuf), result);
1021   if (result == OS_ERR) {
1022     if (PrintMiscellaneous && Verbose) {
1023       warning("fstat failed: %s\n", os::strerror(errno));
1024     }
1025     THROW_MSG_0(vmSymbols::java_io_IOException(),
1026                 "Could not determine PerfMemory size");
1027   }
1028 
1029   if ((statbuf.st_size == 0) ||
1030      ((size_t)statbuf.st_size % os::vm_page_size() != 0)) {
1031     THROW_MSG_0(vmSymbols::java_lang_Exception(),
1032                 "Invalid PerfMemory size");
1033   }
1034 
1035   return (size_t)statbuf.st_size;
1036 }
1037 
1038 // attach to a named shared memory region.
1039 //
1040 static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemoryMode mode, char** addr, size_t* sizep, TRAPS) {
1041 
1042   char* mapAddress;
1043   int result;
1044   int fd;
1045   size_t size = 0;
1046   const char* luser = NULL;
1047 
1048   int mmap_prot;
1049   int file_flags;
1050 
1051   ResourceMark rm;


< prev index next >