src/os/posix/vm/os_posix.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hs-gc-mmap Cdiff src/os/posix/vm/os_posix.cpp
src/os/posix/vm/os_posix.cpp
Print this page
rev 3899 : [mq]: mickes-originalpatch
*** 91,100 ****
--- 91,133 ----
void os::wait_for_keypress_at_exit(void) {
// don't do anything on posix platforms
return;
}
+ char* os::reserve_memory_aligned(size_t bytes, size_t alignment) {
+ size_t size = align_size_up(bytes, alignment);
+ size_t extra_size = size + alignment;
+ char* extra_base = os::reserve_memory(extra_size, NULL, alignment);
+
+ if (extra_base == NULL) {
+ return NULL;
+ }
+
+ // Do manual alignment
+ char* aligned_base = (char*) align_size_up((uintptr_t) extra_base, alignment);
+
+ // [ | | ]
+ // ^ extra_base
+ // ^ extra_base + begin_offset == aligned_base
+ // extra_base + begin_offset + size ^
+ // extra_base + extra_size ^
+ // |<>| == begin_offset
+ // end_offset == |<>|
+ size_t begin_offset = aligned_base - extra_base;
+ size_t end_offset = (extra_base + extra_size) - (aligned_base + size);
+
+ if (begin_offset > 0) {
+ os::release_memory(extra_base, begin_offset);
+ }
+
+ if (end_offset > 0) {
+ os::release_memory(extra_base + begin_offset + size, end_offset);
+ }
+
+ return aligned_base;
+ }
+
void os::Posix::print_load_average(outputStream* st) {
st->print("load average:");
double loadavg[3];
os::loadavg(loadavg, 3);
st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
src/os/posix/vm/os_posix.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File