< prev index next >

src/os/posix/vm/os_posix.cpp

Print this page




 119 
 120 bool os::unsetenv(const char* name) {
 121   assert(name != NULL, "Null pointer");
 122   return (::unsetenv(name) == 0);
 123 }
 124 
 125 int os::get_last_error() {
 126   return errno;
 127 }
 128 
 129 bool os::is_debugger_attached() {
 130   // not implemented
 131   return false;
 132 }
 133 
 134 void os::wait_for_keypress_at_exit(void) {
 135   // don't do anything on posix platforms
 136   return;
 137 }
 138 















 139 // Multiple threads can race in this code, and can remap over each other with MAP_FIXED,
 140 // so on posix, unmap the section at the start and at the end of the chunk that we mapped
 141 // rather than unmapping and remapping the whole chunk to get requested alignment.
 142 char* os::reserve_memory_aligned(size_t size, size_t alignment) {
 143   assert((alignment & (os::vm_allocation_granularity() - 1)) == 0,
 144       "Alignment must be a multiple of allocation granularity (page size)");
 145   assert((size & (alignment -1)) == 0, "size must be 'alignment' aligned");
 146 
 147   size_t extra_size = size + alignment;
 148   assert(extra_size >= size, "overflow, size is too large to allow alignment");
 149 
 150   char* extra_base = os::reserve_memory(extra_size, NULL, alignment);
 151 
 152   if (extra_base == NULL) {
 153     return NULL;
 154   }
 155 
 156   // Do manual alignment
 157   char* aligned_base = (char*) align_size_up((uintptr_t) extra_base, alignment);
 158 




 119 
 120 bool os::unsetenv(const char* name) {
 121   assert(name != NULL, "Null pointer");
 122   return (::unsetenv(name) == 0);
 123 }
 124 
 125 int os::get_last_error() {
 126   return errno;
 127 }
 128 
 129 bool os::is_debugger_attached() {
 130   // not implemented
 131   return false;
 132 }
 133 
 134 void os::wait_for_keypress_at_exit(void) {
 135   // don't do anything on posix platforms
 136   return;
 137 }
 138 
 139 // Reserve memory by creating a temporary file in the provided directory and using it for mmap() call
 140 // This function is only relevant to Linux. Report failure when called for other OSes
 141 char* os::reserve_memory_with_backing_file(size_t bytes, char* requested_addr, size_t alignment_hint, const char* backingFileDir) {
 142 #ifdef TARGET_OS_FAMILY_linux
 143   char* result = os::Linux::reserve_memory_with_backing_file(bytes, requested_addr, alignment_hint, backingFileDir);
 144   if (result != NULL) {
 145     MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC);
 146   }
 147   return result;
 148 #else
 149   VMError::report_and_die("Allocating object heap with backing file is not supported for this OS");
 150   return NULL;
 151 #endif
 152 }
 153 
 154 // Multiple threads can race in this code, and can remap over each other with MAP_FIXED,
 155 // so on posix, unmap the section at the start and at the end of the chunk that we mapped
 156 // rather than unmapping and remapping the whole chunk to get requested alignment.
 157 char* os::reserve_memory_aligned(size_t size, size_t alignment) {
 158   assert((alignment & (os::vm_allocation_granularity() - 1)) == 0,
 159       "Alignment must be a multiple of allocation granularity (page size)");
 160   assert((size & (alignment -1)) == 0, "size must be 'alignment' aligned");
 161 
 162   size_t extra_size = size + alignment;
 163   assert(extra_size >= size, "overflow, size is too large to allow alignment");
 164 
 165   char* extra_base = os::reserve_memory(extra_size, NULL, alignment);
 166 
 167   if (extra_base == NULL) {
 168     return NULL;
 169   }
 170 
 171   // Do manual alignment
 172   char* aligned_base = (char*) align_size_up((uintptr_t) extra_base, alignment);
 173 


< prev index next >