1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:37:34 +00:00

Kernel: Make VirtualAddress methods constexpr

In order to use VirtualAddresses as compile time constants in the
AddressSanitizer implementation, we need to be able to use these
methods in constexpr functions / variable initializations.
This commit is contained in:
Brian Gianforcaro 2021-08-24 20:39:33 -07:00 committed by Andreas Kling
parent 665e848576
commit 9acf449ced

View file

@ -12,7 +12,7 @@
class VirtualAddress { class VirtualAddress {
public: public:
VirtualAddress() = default; VirtualAddress() = default;
explicit VirtualAddress(FlatPtr address) constexpr explicit VirtualAddress(FlatPtr address)
: m_address(address) : m_address(address)
{ {
} }
@ -22,11 +22,11 @@ public:
{ {
} }
[[nodiscard]] bool is_null() const { return m_address == 0; } [[nodiscard]] constexpr bool is_null() const { return m_address == 0; }
[[nodiscard]] bool is_page_aligned() const { return (m_address & 0xfff) == 0; } [[nodiscard]] constexpr bool is_page_aligned() const { return (m_address & 0xfff) == 0; }
[[nodiscard]] VirtualAddress offset(FlatPtr o) const { return VirtualAddress(m_address + o); } [[nodiscard]] constexpr VirtualAddress offset(FlatPtr o) const { return VirtualAddress(m_address + o); }
[[nodiscard]] FlatPtr get() const { return m_address; } [[nodiscard]] constexpr FlatPtr get() const { return m_address; }
void set(FlatPtr address) { m_address = address; } void set(FlatPtr address) { m_address = address; }
void mask(FlatPtr m) { m_address &= m; } void mask(FlatPtr m) { m_address &= m; }