Skip to content

Commit 7c28db3

Browse files
committed
system/PageAllocator: move PAGE_SIZE and AlignToPageSize() to PageSize.hxx
1 parent 2bfe3b0 commit 7c28db3

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

src/memory/SlicePool.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "Checker.hxx"
88
#include "AllocatorStats.hxx"
99
#include "system/PageAllocator.hxx"
10+
#include "system/PageSize.hxx"
1011
#include "system/HugePage.hxx"
1112
#include "system/VmaName.hxx"
1213
#include "util/DivideRoundUp.hxx"

src/system/LargeAllocation.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "LargeAllocation.hxx"
66
#include "PageAllocator.hxx"
7+
#include "PageSize.hxx"
78

89
#include <new>
910

src/system/PageAllocator.hxx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@
1111

1212
#include <sys/mman.h>
1313

14-
static constexpr std::size_t PAGE_SIZE = 4096;
15-
16-
/**
17-
* Round up the parameter, make it page-aligned.
18-
*/
19-
static constexpr std::size_t
20-
AlignToPageSize(std::size_t size) noexcept
21-
{
22-
return RoundUpToPowerOfTwo(size, PAGE_SIZE);
23-
}
24-
2514
/**
2615
* Allocate pages from the kernel
2716
*

src/system/PageSize.hxx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: BSD-2-Clause
2+
// Copyright CM4all GmbH
3+
// author: Max Kellermann <max.kellermann@ionos.com>
4+
5+
#pragma once
6+
7+
#include "util/RoundPowerOfTwo.hxx"
8+
9+
#include <cstddef>
10+
11+
#include <sys/mman.h>
12+
13+
static constexpr std::size_t PAGE_SIZE = 4096;
14+
15+
/**
16+
* Round up the parameter, make it page-aligned.
17+
*/
18+
static constexpr std::size_t
19+
AlignToPageSize(std::size_t size) noexcept
20+
{
21+
return RoundUpToPowerOfTwo(size, PAGE_SIZE);
22+
}

0 commit comments

Comments
 (0)