mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
kern: fix KTypedAddress, strengthen assertions
This commit is contained in:
parent
47f2e93a42
commit
fac502aaa3
1 changed files with 26 additions and 5 deletions
|
@ -32,13 +32,10 @@ namespace ams::kern {
|
|||
constexpr ALWAYS_INLINE explicit KTypedAddress(U *ptr) : address(reinterpret_cast<uintptr_t>(ptr)) { /* ... */ }
|
||||
|
||||
/* Copy constructor. */
|
||||
constexpr ALWAYS_INLINE KTypedAddress(const KTypedAddress &rhs) : address(rhs.address) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE KTypedAddress(const KTypedAddress &rhs) = default;
|
||||
|
||||
/* Assignment operator. */
|
||||
constexpr ALWAYS_INLINE KTypedAddress operator=(KTypedAddress rhs) {
|
||||
this->address = rhs.address;
|
||||
return *this;
|
||||
}
|
||||
constexpr ALWAYS_INLINE KTypedAddress &operator=(const KTypedAddress &rhs) = default;
|
||||
|
||||
/* Arithmetic operators. */
|
||||
template<typename I>
|
||||
|
@ -203,6 +200,26 @@ namespace ams::kern {
|
|||
static_assert(sizeof(KVirtualAddress) == sizeof(uintptr_t));
|
||||
static_assert(sizeof(KProcessAddress) == sizeof(uintptr_t));
|
||||
|
||||
static_assert(std::is_trivially_copyable<KPhysicalAddress>::value);
|
||||
static_assert(std::is_trivially_copyable<KVirtualAddress>::value);
|
||||
static_assert(std::is_trivially_copyable<KProcessAddress>::value);
|
||||
|
||||
static_assert(std::is_trivially_copy_constructible<KPhysicalAddress>::value);
|
||||
static_assert(std::is_trivially_copy_constructible<KVirtualAddress>::value);
|
||||
static_assert(std::is_trivially_copy_constructible<KProcessAddress>::value);
|
||||
|
||||
static_assert(std::is_trivially_move_constructible<KPhysicalAddress>::value);
|
||||
static_assert(std::is_trivially_move_constructible<KVirtualAddress>::value);
|
||||
static_assert(std::is_trivially_move_constructible<KProcessAddress>::value);
|
||||
|
||||
static_assert(std::is_trivially_copy_assignable<KPhysicalAddress>::value);
|
||||
static_assert(std::is_trivially_copy_assignable<KVirtualAddress>::value);
|
||||
static_assert(std::is_trivially_copy_assignable<KProcessAddress>::value);
|
||||
|
||||
static_assert(std::is_trivially_move_assignable<KPhysicalAddress>::value);
|
||||
static_assert(std::is_trivially_move_assignable<KVirtualAddress>::value);
|
||||
static_assert(std::is_trivially_move_assignable<KProcessAddress>::value);
|
||||
|
||||
static_assert(std::is_trivially_destructible<KPhysicalAddress>::value);
|
||||
static_assert(std::is_trivially_destructible<KVirtualAddress>::value);
|
||||
static_assert(std::is_trivially_destructible<KProcessAddress>::value);
|
||||
|
@ -212,6 +229,10 @@ namespace ams::kern {
|
|||
static_assert(Null<KVirtualAddress> == Null<uintptr_t>);
|
||||
static_assert(Null<KProcessAddress> == Null<uintptr_t>);
|
||||
|
||||
/* Constructor/assignment validations. */
|
||||
static_assert([]{ const KPhysicalAddress a(5); KPhysicalAddress b(a); return b; }() == KPhysicalAddress(5));
|
||||
static_assert([]{ const KPhysicalAddress a(5); KPhysicalAddress b(10); b = a; return b; }() == KPhysicalAddress(5));
|
||||
|
||||
/* Arithmetic validations. */
|
||||
static_assert(KPhysicalAddress(10) + 5 == KPhysicalAddress(15));
|
||||
static_assert(KPhysicalAddress(10) - 5 == KPhysicalAddress(5));
|
||||
|
|
Loading…
Reference in a new issue