aboutsummaryrefslogtreecommitdiff
path: root/kapi
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-12-02 18:49:36 +0100
committerFelix Morgner <felix.morgner@ost.ch>2025-12-02 18:49:36 +0100
commit331c070547634a2096c5e2165559fb0f11ee6330 (patch)
treeb4bb1f0ce663c6eaec81f3d2e5995a94757a32d3 /kapi
parent44d4844ce63e7c00b4028bb918eed5d9fb795578 (diff)
downloadteachos-331c070547634a2096c5e2165559fb0f11ee6330.tar.xz
teachos-331c070547634a2096c5e2165559fb0f11ee6330.zip
kapi: make PLATFORM_*_SIZE constexpr
Diffstat (limited to 'kapi')
-rw-r--r--kapi/include/kapi/memory/frame.hpp8
-rw-r--r--kapi/include/kapi/memory/page.hpp8
2 files changed, 8 insertions, 8 deletions
diff --git a/kapi/include/kapi/memory/frame.hpp b/kapi/include/kapi/memory/frame.hpp
index 5793b8b..10e4172 100644
--- a/kapi/include/kapi/memory/frame.hpp
+++ b/kapi/include/kapi/memory/frame.hpp
@@ -11,10 +11,10 @@
namespace teachos::memory
{
- extern std::size_t const PLATFORM_FRAME_SIZE;
-
struct frame
{
+ constexpr auto static size = PLATFORM_FRAME_SIZE;
+
constexpr frame() = default;
explicit constexpr frame(std::size_t number)
@@ -29,7 +29,7 @@ namespace teachos::memory
*/
constexpr auto static containing(physical_address address) noexcept -> frame
{
- return frame{address.raw() / PLATFORM_FRAME_SIZE};
+ return frame{address.raw() / size};
}
/**
@@ -39,7 +39,7 @@ namespace teachos::memory
*/
[[nodiscard]] constexpr auto start_address() const noexcept -> physical_address
{
- return physical_address{m_number * PLATFORM_FRAME_SIZE};
+ return physical_address{m_number * size};
}
[[nodiscard]] constexpr auto number() const noexcept -> std::size_t
diff --git a/kapi/include/kapi/memory/page.hpp b/kapi/include/kapi/memory/page.hpp
index 473a8b8..9bb22e9 100644
--- a/kapi/include/kapi/memory/page.hpp
+++ b/kapi/include/kapi/memory/page.hpp
@@ -11,10 +11,10 @@
namespace teachos::memory
{
- extern std::size_t const PLATFORM_PAGE_SIZE;
-
struct page
{
+ constexpr auto static size = PLATFORM_FRAME_SIZE;
+
constexpr page() = default;
explicit constexpr page(std::size_t number)
@@ -29,7 +29,7 @@ namespace teachos::memory
*/
constexpr auto static containing(linear_address address) noexcept -> page
{
- return page{address.raw() / PLATFORM_PAGE_SIZE};
+ return page{address.raw() / size};
}
/**
@@ -39,7 +39,7 @@ namespace teachos::memory
*/
[[nodiscard]] constexpr auto start_address() const noexcept -> linear_address
{
- return linear_address{m_number * PLATFORM_PAGE_SIZE};
+ return linear_address{m_number * size};
}
[[nodiscard]] constexpr auto number() const noexcept -> std::size_t