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

AK+Kernel: Remove implicit conversion from Userspace<T*> to FlatPtr

This feels like it was a refactor transition kind of conversion. The
places that were relying on it can easily be changed to explicitly ask
for the ptr() or a new vaddr() method on Userspace<T*>.

FlatPtr can still implicitly convert to Userspace<T> because the
constructor is not explicit, but there's quite a few more places that
are relying on that conversion.
This commit is contained in:
Andrew Kaster 2021-11-14 15:52:48 -07:00 committed by Andreas Kling
parent 7243bcb7da
commit f1d8978804
5 changed files with 14 additions and 11 deletions

View file

@ -10,6 +10,10 @@
#include <AK/StdLibExtras.h>
#include <AK/Types.h>
#ifdef KERNEL
# include <Kernel/VirtualAddress.h>
#endif
namespace AK {
template<typename T>
@ -20,8 +24,6 @@ class Userspace {
public:
Userspace() = default;
operator FlatPtr() const { return (FlatPtr)m_ptr; }
// Disable default implementations that would use surprising integer promotion.
bool operator==(const Userspace&) const = delete;
bool operator<=(const Userspace&) const = delete;
@ -38,7 +40,8 @@ public:
explicit operator bool() const { return m_ptr != 0; }
FlatPtr ptr() const { return m_ptr; }
T unsafe_userspace_ptr() const { return (T)m_ptr; }
VirtualAddress vaddr() const { return VirtualAddress(m_ptr); }
T unsafe_userspace_ptr() const { return reinterpret_cast<T>(m_ptr); }
#else
Userspace(T ptr)
: m_ptr(ptr)