125 return (::unsetenv(name) == 0);
126 }
127
128 int os::get_last_error() {
129 return errno;
130 }
131
132 bool os::is_debugger_attached() {
133 // not implemented
134 return false;
135 }
136
137 void os::wait_for_keypress_at_exit(void) {
138 // don't do anything on posix platforms
139 return;
140 }
141
142 // Multiple threads can race in this code, and can remap over each other with MAP_FIXED,
143 // so on posix, unmap the section at the start and at the end of the chunk that we mapped
144 // rather than unmapping and remapping the whole chunk to get requested alignment.
145 char* os::reserve_memory_aligned(size_t size, size_t alignment) {
146 assert((alignment & (os::vm_allocation_granularity() - 1)) == 0,
147 "Alignment must be a multiple of allocation granularity (page size)");
148 assert((size & (alignment -1)) == 0, "size must be 'alignment' aligned");
149
150 size_t extra_size = size + alignment;
151 assert(extra_size >= size, "overflow, size is too large to allow alignment");
152
153 char* extra_base = os::reserve_memory(extra_size, NULL, alignment);
154
155 if (extra_base == NULL) {
156 return NULL;
157 }
158
159 // Do manual alignment
160 char* aligned_base = (char*) align_size_up((uintptr_t) extra_base, alignment);
161
162 // [ | | ]
163 // ^ extra_base
164 // ^ extra_base + begin_offset == aligned_base
165 // extra_base + begin_offset + size ^
166 // extra_base + extra_size ^
167 // |<>| == begin_offset
168 // end_offset == |<>|
169 size_t begin_offset = aligned_base - extra_base;
170 size_t end_offset = (extra_base + extra_size) - (aligned_base + size);
171
172 if (begin_offset > 0) {
173 os::release_memory(extra_base, begin_offset);
174 }
175
176 if (end_offset > 0) {
177 os::release_memory(extra_base + begin_offset + size, end_offset);
178 }
179
180 return aligned_base;
181 }
182
183 int os::log_vsnprintf(char* buf, size_t len, const char* fmt, va_list args) {
184 return vsnprintf(buf, len, fmt, args);
185 }
186
187 int os::get_fileno(FILE* fp) {
188 return NOT_AIX(::)fileno(fp);
189 }
190
191 struct tm* os::gmtime_pd(const time_t* clock, struct tm* res) {
192 return gmtime_r(clock, res);
193 }
194
195 void os::Posix::print_load_average(outputStream* st) {
196 st->print("load average:");
197 double loadavg[3];
198 os::loadavg(loadavg, 3);
199 st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
|
125 return (::unsetenv(name) == 0);
126 }
127
128 int os::get_last_error() {
129 return errno;
130 }
131
132 bool os::is_debugger_attached() {
133 // not implemented
134 return false;
135 }
136
137 void os::wait_for_keypress_at_exit(void) {
138 // don't do anything on posix platforms
139 return;
140 }
141
142 // Multiple threads can race in this code, and can remap over each other with MAP_FIXED,
143 // so on posix, unmap the section at the start and at the end of the chunk that we mapped
144 // rather than unmapping and remapping the whole chunk to get requested alignment.
145 char* os::reserve_memory_aligned(size_t size, size_t alignment, int file_desc) {
146 assert((alignment & (os::vm_allocation_granularity() - 1)) == 0,
147 "Alignment must be a multiple of allocation granularity (page size)");
148 assert((size & (alignment -1)) == 0, "size must be 'alignment' aligned");
149
150 size_t extra_size = size + alignment;
151 assert(extra_size >= size, "overflow, size is too large to allow alignment");
152
153 char* extra_base = os::reserve_memory(extra_size, NULL, alignment);
154
155 if (extra_base == NULL) {
156 return NULL;
157 }
158
159 // Do manual alignment
160 char* aligned_base = (char*) align_size_up((uintptr_t) extra_base, alignment);
161
162 // [ | | ]
163 // ^ extra_base
164 // ^ extra_base + begin_offset == aligned_base
165 // extra_base + begin_offset + size ^
166 // extra_base + extra_size ^
167 // |<>| == begin_offset
168 // end_offset == |<>|
169 size_t begin_offset = aligned_base - extra_base;
170 size_t end_offset = (extra_base + extra_size) - (aligned_base + size);
171
172 if (begin_offset > 0) {
173 os::release_memory(extra_base, begin_offset);
174 }
175
176 if (end_offset > 0) {
177 os::release_memory(extra_base + begin_offset + size, end_offset);
178 }
179
180 if (file_desc != -1) {
181 if (os::map_memory_to_file(aligned_base, size, file_desc) == NULL) {
182 vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory"));
183 }
184 }
185 return aligned_base;
186 }
187
188 int os::log_vsnprintf(char* buf, size_t len, const char* fmt, va_list args) {
189 return vsnprintf(buf, len, fmt, args);
190 }
191
192 int os::get_fileno(FILE* fp) {
193 return NOT_AIX(::)fileno(fp);
194 }
195
196 struct tm* os::gmtime_pd(const time_t* clock, struct tm* res) {
197 return gmtime_r(clock, res);
198 }
199
200 void os::Posix::print_load_average(outputStream* st) {
201 st->print("load average:");
202 double loadavg[3];
203 os::loadavg(loadavg, 3);
204 st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
|