summaryrefslogtreecommitdiff
path: root/tests/allocator.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-15 21:44:52 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-15 21:44:52 -0700
commitbb3aee447b698c7dcec6428a17c61e66dd43dfd6 (patch)
tree55d2efbec08ee116ae1131d51920b121b8a7d877 /tests/allocator.cpp
parent8c8940430ac0d0f82add6fb028ffe9712c9669e8 (diff)
tests: Use malloc for OSX/Linux page heap
Switch to malloc and manually aligning the pointer to the page boundary. mmap is much slower than malloc; this change makes tests ~4x faster.
Diffstat (limited to 'tests/allocator.cpp')
-rw-r--r--tests/allocator.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/allocator.cpp b/tests/allocator.cpp
index 8ca0963..a43e14a 100644
--- a/tests/allocator.cpp
+++ b/tests/allocator.cpp
@@ -80,7 +80,9 @@ namespace
void* allocate_page_aligned(size_t size)
{
- return mmap(0, size + page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+ void* result = malloc(size + page_size);
+
+ return reinterpret_cast<void*>(align_to_page(reinterpret_cast<size_t>(result)));
}
void* allocate(size_t size)