diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-01 15:32:06 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-01 15:32:44 +0100 |
commit | 7c3b6b10e4230a24dbe44df4f942d63ee27cac89 (patch) | |
tree | e2a5a28649da389f4d1d79308f9e981f9df22815 /Kernel | |
parent | aa92adeedf345b4e66a2ccdd3153510cfbf5f620 (diff) | |
download | serenity-7c3b6b10e4230a24dbe44df4f942d63ee27cac89.zip |
Kernel: Remove the limited use of AK::TypeTraits we had in the kernel
This was only used for VMObject and we can do without it there. This is
preparation for migrating to dynamic_cast-based helpers in userspace.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Syscalls/purge.cpp | 10 | ||||
-rw-r--r-- | Kernel/VM/AnonymousVMObject.h | 4 | ||||
-rw-r--r-- | Kernel/VM/ContiguousVMObject.h | 4 | ||||
-rw-r--r-- | Kernel/VM/InodeVMObject.h | 4 | ||||
-rw-r--r-- | Kernel/VM/MemoryManager.cpp | 6 | ||||
-rw-r--r-- | Kernel/VM/PurgeableVMObject.h | 4 | ||||
-rw-r--r-- | Kernel/VM/VMObject.h | 1 |
7 files changed, 10 insertions, 23 deletions
diff --git a/Kernel/Syscalls/purge.cpp b/Kernel/Syscalls/purge.cpp index 536463a3b8..be3bcce6c6 100644 --- a/Kernel/Syscalls/purge.cpp +++ b/Kernel/Syscalls/purge.cpp @@ -42,8 +42,9 @@ int Process::sys$purge(int mode) NonnullRefPtrVector<PurgeableVMObject> vmobjects; { InterruptDisabler disabler; - MM.for_each_vmobject_of_type<PurgeableVMObject>([&](auto& vmobject) { - vmobjects.append(vmobject); + MM.for_each_vmobject([&](auto& vmobject) { + if (vmobject.is_purgeable()) + vmobjects.append(static_cast<PurgeableVMObject&>(vmobject)); return IterationDecision::Continue; }); } @@ -55,8 +56,9 @@ int Process::sys$purge(int mode) NonnullRefPtrVector<InodeVMObject> vmobjects; { InterruptDisabler disabler; - MM.for_each_vmobject_of_type<InodeVMObject>([&](auto& vmobject) { - vmobjects.append(vmobject); + MM.for_each_vmobject([&](auto& vmobject) { + if (vmobject.is_inode()) + vmobjects.append(static_cast<InodeVMObject&>(vmobject)); return IterationDecision::Continue; }); } diff --git a/Kernel/VM/AnonymousVMObject.h b/Kernel/VM/AnonymousVMObject.h index 1a0f5f13ba..aa5c189b7f 100644 --- a/Kernel/VM/AnonymousVMObject.h +++ b/Kernel/VM/AnonymousVMObject.h @@ -57,7 +57,3 @@ private: }; } - -AK_BEGIN_TYPE_TRAITS(Kernel::AnonymousVMObject) -static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_anonymous(); } -AK_END_TYPE_TRAITS() diff --git a/Kernel/VM/ContiguousVMObject.h b/Kernel/VM/ContiguousVMObject.h index 0df4f9c40d..13a633ba26 100644 --- a/Kernel/VM/ContiguousVMObject.h +++ b/Kernel/VM/ContiguousVMObject.h @@ -52,7 +52,3 @@ private: }; } - -AK_BEGIN_TYPE_TRAITS(Kernel::ContiguousVMObject) -static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_contiguous(); } -AK_END_TYPE_TRAITS() diff --git a/Kernel/VM/InodeVMObject.h b/Kernel/VM/InodeVMObject.h index 94e7073709..035663aa12 100644 --- a/Kernel/VM/InodeVMObject.h +++ b/Kernel/VM/InodeVMObject.h @@ -67,7 +67,3 @@ protected: }; } - -AK_BEGIN_TYPE_TRAITS(Kernel::InodeVMObject) -static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_inode(); } -AK_END_TYPE_TRAITS() diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index b2f3dcd30f..622b0ba4ca 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -509,8 +509,10 @@ RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill s if (!page) { // We didn't have a single free physical page. Let's try to free something up! // First, we look for a purgeable VMObject in the volatile state. - for_each_vmobject_of_type<PurgeableVMObject>([&](auto& vmobject) { - int purged_page_count = vmobject.purge_with_interrupts_disabled({}); + for_each_vmobject([&](auto& vmobject) { + if (!vmobject.is_purgeable()) + return IterationDecision::Continue; + int purged_page_count = static_cast<PurgeableVMObject&>(vmobject).purge_with_interrupts_disabled({}); if (purged_page_count) { klog() << "MM: Purge saved the day! Purged " << purged_page_count << " pages from PurgeableVMObject{" << &vmobject << "}"; page = find_free_user_physical_page(); diff --git a/Kernel/VM/PurgeableVMObject.h b/Kernel/VM/PurgeableVMObject.h index 846222deab..5e100aa5f0 100644 --- a/Kernel/VM/PurgeableVMObject.h +++ b/Kernel/VM/PurgeableVMObject.h @@ -65,7 +65,3 @@ private: }; } - -AK_BEGIN_TYPE_TRAITS(Kernel::PurgeableVMObject) -static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_purgeable(); } -AK_END_TYPE_TRAITS() diff --git a/Kernel/VM/VMObject.h b/Kernel/VM/VMObject.h index 11bb4dada5..e126113f79 100644 --- a/Kernel/VM/VMObject.h +++ b/Kernel/VM/VMObject.h @@ -29,7 +29,6 @@ #include <AK/InlineLinkedList.h> #include <AK/RefCounted.h> #include <AK/RefPtr.h> -#include <AK/TypeCasts.h> #include <AK/Vector.h> #include <AK/Weakable.h> #include <Kernel/Lock.h> |