From e9dd8ea4343b943032f2af87fbae9f46fe1f9328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Mon, 14 Oct 2024 09:55:11 +0000 Subject: Move 8 byte alignment into seperate method --- arch/x86_64/src/kernel/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'arch/x86_64/src') diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index 1c6aa55..106ca2a 100644 --- a/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp @@ -94,6 +94,13 @@ namespace teachos::arch::kernel assert(dynamic_section_count <= 1U); } + template + requires std::is_pointer::value + auto align_to_8_byte_boundary(T ptr, uint32_t size) -> T + { + return reinterpret_cast(reinterpret_cast(ptr) + ((size + 7) & ~7)); + } + auto main() -> void { using namespace video::vga; @@ -121,8 +128,7 @@ namespace teachos::arch::kernel * The increment part aligns the size to an 8-byte address. */ for (auto tag = multiboot_tag; tag->type != arch::memory::multi_boot_tag_type::END; - tag = reinterpret_cast((reinterpret_cast(tag)) + - ((tag->size + 7) & ~7))) + tag = align_to_8_byte_boundary(tag, tag->size)) { switch (tag->type) { -- cgit v1.2.3