From 2fd9e722647b0a9b90b0380b898c17787918b451 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 22 Aug 2020 17:53:34 +0200 Subject: Revert "Kernel: Switch singletons to use new Singleton class" This reverts commit f48feae0b2a300992479abf0b2ded85e45ac6045. --- Kernel/FileSystem/DevPtsFS.cpp | 17 ++++++++++------- Kernel/FileSystem/FIFO.cpp | 6 +++--- Kernel/FileSystem/FileSystem.cpp | 5 +++-- Kernel/FileSystem/Inode.cpp | 7 ++++--- Kernel/FileSystem/VirtualFileSystem.cpp | 10 +++------- Kernel/FileSystem/VirtualFileSystem.h | 1 - 6 files changed, 23 insertions(+), 23 deletions(-) (limited to 'Kernel/FileSystem') diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp index b3db215c5d..ac060d026b 100644 --- a/Kernel/FileSystem/DevPtsFS.cpp +++ b/Kernel/FileSystem/DevPtsFS.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include namespace Kernel { @@ -46,10 +45,14 @@ DevPtsFS::~DevPtsFS() { } -static auto s_ptys = make_singleton>(); +static HashTable* ptys; bool DevPtsFS::initialize() { + if (ptys == nullptr) { + ptys = new HashTable(); + } + m_root_inode = adopt(*new DevPtsFSInode(*this, 1)); m_root_inode->m_metadata.inode = { fsid(), 1 }; m_root_inode->m_metadata.mode = 0040555; @@ -101,12 +104,12 @@ RefPtr DevPtsFS::get_inode(InodeIdentifier inode_id) const void DevPtsFS::register_slave_pty(SlavePTY& slave_pty) { - s_ptys->set(slave_pty.index()); + ptys->set(slave_pty.index()); } void DevPtsFS::unregister_slave_pty(SlavePTY& slave_pty) { - s_ptys->remove(slave_pty.index()); + ptys->remove(slave_pty.index()); } DevPtsFSInode::DevPtsFSInode(DevPtsFS& fs, unsigned index) @@ -141,7 +144,7 @@ KResult DevPtsFSInode::traverse_as_directory(Function DevPtsFSInode::directory_entry_count() const { ASSERT(identifier().index() == 1); - return 2 + s_ptys->size(); + return 2 + ptys->size(); } RefPtr DevPtsFSInode::lookup(StringView name) @@ -167,7 +170,7 @@ RefPtr DevPtsFSInode::lookup(StringView name) auto& fs = static_cast(this->fs()); auto pty_index = name.to_uint(); - if (pty_index.has_value() && s_ptys->contains(pty_index.value())) { + if (pty_index.has_value() && ptys->contains(pty_index.value())) { return fs.get_inode({ fsid(), pty_index_to_inode_index(pty_index.value()) }); } diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp index 670266cbce..9881b6916b 100644 --- a/Kernel/FileSystem/FIFO.cpp +++ b/Kernel/FileSystem/FIFO.cpp @@ -31,17 +31,17 @@ #include #include #include -#include #include //#define FIFO_DEBUG namespace Kernel { -static auto s_table = make_singleton>>(); - static Lockable>& all_fifos() { + static Lockable>* s_table; + if (!s_table) + s_table = new Lockable>; return *s_table; } diff --git a/Kernel/FileSystem/FileSystem.cpp b/Kernel/FileSystem/FileSystem.cpp index 450f401253..e4ed6fd98b 100644 --- a/Kernel/FileSystem/FileSystem.cpp +++ b/Kernel/FileSystem/FileSystem.cpp @@ -31,17 +31,18 @@ #include #include #include -#include #include #include namespace Kernel { static u32 s_lastFileSystemID; -static auto s_fs_map = make_singleton>(); +static HashMap* s_fs_map; static HashMap& all_fses() { + if (!s_fs_map) + s_fs_map = new HashMap(); return *s_fs_map; } diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp index c136ffc2a0..127ad174f6 100644 --- a/Kernel/FileSystem/Inode.cpp +++ b/Kernel/FileSystem/Inode.cpp @@ -33,19 +33,20 @@ #include #include #include -#include #include namespace Kernel { static SpinLock s_all_inodes_lock; -static auto s_list = make_singleton>(); InlineLinkedList& Inode::all_with_lock() { ASSERT(s_all_inodes_lock.is_locked()); - return *s_list; + static InlineLinkedList* list; + if (!list) + list = new InlineLinkedList; + return *list; } void Inode::sync() diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index cc0510a570..5febd7c5e6 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -34,24 +34,19 @@ #include #include #include -#include #include //#define VFS_DEBUG namespace Kernel { -static auto s_the = make_singleton(); +static VFS* s_the; static constexpr int symlink_recursion_limit { 5 }; // FIXME: increase? static constexpr int root_mount_flags = MS_NODEV | MS_NOSUID | MS_RDONLY; -void VFS::initialize() -{ - s_the.ensure_instance(); -} - VFS& VFS::the() { + ASSERT(s_the); return *s_the; } @@ -60,6 +55,7 @@ VFS::VFS() #ifdef VFS_DEBUG klog() << "VFS: Constructing VFS"; #endif + s_the = this; } VFS::~VFS() diff --git a/Kernel/FileSystem/VirtualFileSystem.h b/Kernel/FileSystem/VirtualFileSystem.h index 1969327698..35b17e0da8 100644 --- a/Kernel/FileSystem/VirtualFileSystem.h +++ b/Kernel/FileSystem/VirtualFileSystem.h @@ -78,7 +78,6 @@ public: int m_flags; }; - static void initialize(); static VFS& the(); VFS(); -- cgit v1.2.3