mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:37:44 +00:00
Revert "Kernel: Switch singletons to use new Singleton class"
This reverts commit f48feae0b2
.
This commit is contained in:
parent
0addcb45b8
commit
2fd9e72264
44 changed files with 146 additions and 184 deletions
|
@ -28,7 +28,6 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <Kernel/FileSystem/DevPtsFS.h>
|
||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
#include <Kernel/TTY/SlavePTY.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
@ -46,10 +45,14 @@ DevPtsFS::~DevPtsFS()
|
|||
{
|
||||
}
|
||||
|
||||
static auto s_ptys = make_singleton<HashTable<unsigned>>();
|
||||
static HashTable<unsigned>* ptys;
|
||||
|
||||
bool DevPtsFS::initialize()
|
||||
{
|
||||
if (ptys == nullptr) {
|
||||
ptys = new HashTable<unsigned>();
|
||||
}
|
||||
|
||||
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<Inode> 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<bool(const FS::DirectoryEn
|
|||
callback({ ".", identifier(), 0 });
|
||||
callback({ "..", identifier(), 0 });
|
||||
|
||||
for (unsigned pty_index : *s_ptys) {
|
||||
for (unsigned pty_index : *ptys) {
|
||||
String name = String::number(pty_index);
|
||||
InodeIdentifier identifier = { fsid(), pty_index_to_inode_index(pty_index) };
|
||||
callback({ name, identifier, 0 });
|
||||
|
@ -154,7 +157,7 @@ KResultOr<size_t> DevPtsFSInode::directory_entry_count() const
|
|||
{
|
||||
ASSERT(identifier().index() == 1);
|
||||
|
||||
return 2 + s_ptys->size();
|
||||
return 2 + ptys->size();
|
||||
}
|
||||
|
||||
RefPtr<Inode> DevPtsFSInode::lookup(StringView name)
|
||||
|
@ -167,7 +170,7 @@ RefPtr<Inode> DevPtsFSInode::lookup(StringView name)
|
|||
auto& fs = static_cast<DevPtsFS&>(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()) });
|
||||
}
|
||||
|
||||
|
|
|
@ -31,17 +31,17 @@
|
|||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/Lock.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
#include <Kernel/Thread.h>
|
||||
|
||||
//#define FIFO_DEBUG
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
static auto s_table = make_singleton<Lockable<HashTable<FIFO*>>>();
|
||||
|
||||
static Lockable<HashTable<FIFO*>>& all_fifos()
|
||||
{
|
||||
static Lockable<HashTable<FIFO*>>* s_table;
|
||||
if (!s_table)
|
||||
s_table = new Lockable<HashTable<FIFO*>>;
|
||||
return *s_table;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,17 +31,18 @@
|
|||
#include <Kernel/FileSystem/FileSystem.h>
|
||||
#include <Kernel/FileSystem/Inode.h>
|
||||
#include <Kernel/Net/LocalSocket.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
static u32 s_lastFileSystemID;
|
||||
static auto s_fs_map = make_singleton<HashMap<u32, FS*>>();
|
||||
static HashMap<u32, FS*>* s_fs_map;
|
||||
|
||||
static HashMap<u32, FS*>& all_fses()
|
||||
{
|
||||
if (!s_fs_map)
|
||||
s_fs_map = new HashMap<u32, FS*>();
|
||||
return *s_fs_map;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,19 +33,20 @@
|
|||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/KBufferBuilder.h>
|
||||
#include <Kernel/Net/LocalSocket.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
#include <Kernel/VM/SharedInodeVMObject.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
static SpinLock s_all_inodes_lock;
|
||||
static auto s_list = make_singleton<InlineLinkedList<Inode>>();
|
||||
|
||||
InlineLinkedList<Inode>& Inode::all_with_lock()
|
||||
{
|
||||
ASSERT(s_all_inodes_lock.is_locked());
|
||||
|
||||
return *s_list;
|
||||
static InlineLinkedList<Inode>* list;
|
||||
if (!list)
|
||||
list = new InlineLinkedList<Inode>;
|
||||
return *list;
|
||||
}
|
||||
|
||||
void Inode::sync()
|
||||
|
|
|
@ -34,24 +34,19 @@
|
|||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/KSyms.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/Singleton.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
|
||||
//#define VFS_DEBUG
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
static auto s_the = make_singleton<VFS>();
|
||||
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()
|
||||
|
|
|
@ -78,7 +78,6 @@ public:
|
|||
int m_flags;
|
||||
};
|
||||
|
||||
static void initialize();
|
||||
static VFS& the();
|
||||
|
||||
VFS();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue