From: Amelia Coutard Date: Mon, 9 May 2022 09:29:54 +0000 (+0200) Subject: Added operator- to phys_ptrs, which allowed for simplifying a bit of the code X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=5907f488af24c0e1f5d39518accc719a80a53e79;p=voyage-au-centre-des-fichiers.git Added operator- to phys_ptrs, which allowed for simplifying a bit of the code --- diff --git a/src/kernel.cpp b/src/kernel.cpp index 32ec362..9512d14 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -91,7 +91,7 @@ extern "C" void kmain(unsigned long magic, os::phys_ptr operator-(phys_ptr ptr, std::ptrdiff_t offset) { return phys_ptr{ptr.phys_addr - offset * sizeof(T)}; } + friend constexpr std::ptrdiff_t operator-(phys_ptr a, phys_ptr b) { + return (a.phys_addr - b.phys_addr) / sizeof(T); + } constexpr std::uintptr_t get_phys_addr() const { return phys_addr;