mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00
AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)
Use this instead of uintptr_t throughout the codebase. This makes it possible to pass a FlatPtr to something that has u32 and u64 overloads.
This commit is contained in:
parent
b98d8ad5b0
commit
b1058b33fb
36 changed files with 164 additions and 161 deletions
|
@ -32,23 +32,23 @@
|
|||
class VirtualAddress {
|
||||
public:
|
||||
VirtualAddress() {}
|
||||
explicit VirtualAddress(uintptr_t address)
|
||||
explicit VirtualAddress(FlatPtr address)
|
||||
: m_address(address)
|
||||
{
|
||||
}
|
||||
|
||||
explicit VirtualAddress(const void* address)
|
||||
: m_address((uintptr_t)address)
|
||||
: m_address((FlatPtr)address)
|
||||
{
|
||||
}
|
||||
|
||||
bool is_null() const { return m_address == 0; }
|
||||
bool is_page_aligned() const { return (m_address & 0xfff) == 0; }
|
||||
|
||||
VirtualAddress offset(uintptr_t o) const { return VirtualAddress(m_address + o); }
|
||||
uintptr_t get() const { return m_address; }
|
||||
void set(uintptr_t address) { m_address = address; }
|
||||
void mask(uintptr_t m) { m_address &= m; }
|
||||
VirtualAddress offset(FlatPtr o) const { return VirtualAddress(m_address + o); }
|
||||
FlatPtr get() const { return m_address; }
|
||||
void set(FlatPtr address) { m_address = address; }
|
||||
void mask(FlatPtr m) { m_address &= m; }
|
||||
|
||||
bool operator<=(const VirtualAddress& other) const { return m_address <= other.m_address; }
|
||||
bool operator>=(const VirtualAddress& other) const { return m_address >= other.m_address; }
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
VirtualAddress page_base() const { return VirtualAddress(m_address & 0xfffff000); }
|
||||
|
||||
private:
|
||||
uintptr_t m_address { 0 };
|
||||
FlatPtr m_address { 0 };
|
||||
};
|
||||
|
||||
inline VirtualAddress operator-(const VirtualAddress& a, const VirtualAddress& b)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue