From b3a42fa0667caeeebabd9e6aeb46a9534810c2f3 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Thu, 5 Jul 2018 14:40:58 +0100 Subject: [PATCH] vma/tests: Fix compilation if limits.h defines PAGE_SIZE (v2) per POSIX, limits.h may define PAGE_SIZE when the value is not indeterminate v2: just change the variable name, since there's no intended correlation here between this value and the machine's actual page size. Signed-off-by: Jon Turney Reviewed-by: Scott D Phillips --- src/util/tests/vma/vma_random_test.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/util/tests/vma/vma_random_test.cpp b/src/util/tests/vma/vma_random_test.cpp index de887fead30..1f194fcdf92 100644 --- a/src/util/tests/vma/vma_random_test.cpp +++ b/src/util/tests/vma/vma_random_test.cpp @@ -40,7 +40,7 @@ namespace { -static const uint64_t PAGE_SIZE = 4096; +static const uint64_t MEM_PAGE_SIZE = 4096; struct allocation { uint64_t start_page; @@ -62,12 +62,12 @@ constexpr uint64_t allocation_end_page(const allocation& a) { struct random_test { static const uint64_t MEM_START_PAGE = 1; static const uint64_t MEM_SIZE = 0xfffffffffffff000; - static const uint64_t MEM_PAGES = MEM_SIZE / PAGE_SIZE; + static const uint64_t MEM_PAGES = MEM_SIZE / MEM_PAGE_SIZE; random_test(uint_fast32_t seed) : heap_holes{allocation{MEM_START_PAGE, MEM_PAGES}}, rand{seed} { - util_vma_heap_init(&heap, MEM_START_PAGE * PAGE_SIZE, MEM_SIZE); + util_vma_heap_init(&heap, MEM_START_PAGE * MEM_PAGE_SIZE, MEM_SIZE); } void test(unsigned long count) @@ -89,12 +89,12 @@ struct random_test { if (align_order > 51) align_order = std::min(dist(rand), 51); uint64_t align_pages = 1ULL << align_order; - uint64_t align = align_pages * PAGE_SIZE; + uint64_t align = align_pages * MEM_PAGE_SIZE; if (size_order > 51) size_order = std::min(dist(rand), 51); uint64_t size_pages = 1ULL << size_order; - uint64_t size = size_pages * PAGE_SIZE; + uint64_t size = size_pages * MEM_PAGE_SIZE; uint64_t addr = util_vma_heap_alloc(&heap, size, align); @@ -110,7 +110,7 @@ struct random_test { return false; } else { assert(addr % align == 0); - uint64_t addr_page = addr / PAGE_SIZE; + uint64_t addr_page = addr / MEM_PAGE_SIZE; allocation a{addr_page, size_pages}; auto i = heap_holes.find(a); assert(i != end(heap_holes)); @@ -146,8 +146,8 @@ struct random_test { allocation a = allocations.back(); allocations.pop_back(); - util_vma_heap_free(&heap, a.start_page * PAGE_SIZE, - a.num_pages * PAGE_SIZE); + util_vma_heap_free(&heap, a.start_page * MEM_PAGE_SIZE, + a.num_pages * MEM_PAGE_SIZE); assert(heap_holes.find(a) == end(heap_holes)); auto next = heap_holes.upper_bound(a); -- 2.30.2