Skip to content

Commit

Permalink
Revert "Kernel: Move Singleton class to AK"
Browse files Browse the repository at this point in the history
This reverts commit f090625.
  • Loading branch information
awesomekling committed Aug 22, 2020
1 parent b0a24a8 commit 8925ad3
Show file tree
Hide file tree
Showing 31 changed files with 71 additions and 87 deletions.
8 changes: 4 additions & 4 deletions AK/FlyString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <AK/FlyString.h>
#include <AK/HashTable.h>
#include <AK/Optional.h>
#include <AK/Singleton.h>
#include <AK/String.h>
#include <AK/StringUtils.h>
#include <AK/StringView.h>
Expand All @@ -48,11 +47,12 @@ struct FlyStringImplTraits : public AK::Traits<StringImpl*> {
}
};

static auto s_table = make_singleton<HashTable<StringImpl*, FlyStringImplTraits>>();

static HashTable<StringImpl*, FlyStringImplTraits>& fly_impls()
{
return *s_table;
static HashTable<StringImpl*, FlyStringImplTraits>* table;
if (!table)
table = new HashTable<StringImpl*, FlyStringImplTraits>;
return *table;
}

void FlyString::did_destroy_impl(Badge<StringImpl>, StringImpl& impl)
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <AK/Singleton.h>
#include <Kernel/Console.h>
#include <Kernel/IO.h>
#include <Kernel/kstdio.h>
#include <Kernel/Singleton.h>
#include <Kernel/SpinLock.h>

// Bytes output to 0xE9 end up on the Bochs console. It's very handy.
#define CONSOLE_OUT_TO_E9

static auto s_the = AK::make_singleton<Console>();
static auto s_the = Kernel::make_singleton<Console>();
static Kernel::SpinLock g_console_lock;

void Console::initialize()
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Devices/BXVGADevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
*/

#include <AK/Checked.h>
#include <AK/Singleton.h>
#include <Kernel/Devices/BXVGADevice.h>
#include <Kernel/IO.h>
#include <Kernel/PCI/Access.h>
#include <Kernel/Process.h>
#include <Kernel/Singleton.h>
#include <Kernel/VM/AnonymousVMObject.h>
#include <Kernel/VM/MemoryManager.h>
#include <LibC/errno_numbers.h>
Expand Down Expand Up @@ -57,7 +57,7 @@ namespace Kernel {
#define VBE_DISPI_ENABLED 0x01
#define VBE_DISPI_LFB_ENABLED 0x40

static auto s_the = AK::make_singleton<BXVGADevice>();
static auto s_the = make_singleton<BXVGADevice>();

void BXVGADevice::initialize()
{
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Devices/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <AK/Singleton.h>
#include <Kernel/Devices/Device.h>
#include <Kernel/FileSystem/InodeMetadata.h>
#include <Kernel/Singleton.h>
#include <LibC/errno_numbers.h>

namespace Kernel {

static auto s_all_devices = AK::make_singleton<HashMap<u32, Device*>>();
static auto s_all_devices = make_singleton<HashMap<u32, Device*>>();

HashMap<u32, Device*>& Device::all_devices()
{
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Devices/KeyboardDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

#include <AK/Assertions.h>
#include <AK/ByteBuffer.h>
#include <AK/Singleton.h>
#include <AK/StringView.h>
#include <AK/Types.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Devices/KeyboardDevice.h>
#include <Kernel/IO.h>
#include <Kernel/Singleton.h>
#include <Kernel/TTY/VirtualConsole.h>

//#define KEYBOARD_DEBUG
Expand Down Expand Up @@ -336,7 +336,7 @@ void KeyboardDevice::handle_irq(const RegisterState&)
}
}

static auto s_the = AK::make_singleton<KeyboardDevice>();
static auto s_the = make_singleton<KeyboardDevice>();

void KeyboardDevice::initialize()
{
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Devices/NullDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
*/

#include "NullDevice.h"
#include <AK/Singleton.h>
#include <AK/StdLibExtras.h>
#include <Kernel/Singleton.h>

namespace Kernel {

static auto s_the = AK::make_singleton<NullDevice>();
static auto s_the = make_singleton<NullDevice>();

void NullDevice::initialize()
{
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Devices/PATAChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
*/

#include <AK/ByteBuffer.h>
#include <AK/Singleton.h>
#include <AK/StringView.h>
#include <Kernel/Devices/PATAChannel.h>
#include <Kernel/Devices/PATADiskDevice.h>
#include <Kernel/FileSystem/ProcFS.h>
#include <Kernel/IO.h>
#include <Kernel/Process.h>
#include <Kernel/Singleton.h>
#include <Kernel/VM/MemoryManager.h>

namespace Kernel {
Expand Down Expand Up @@ -108,7 +108,7 @@ namespace Kernel {
#define PCI_Mass_Storage_Class 0x1
#define PCI_IDE_Controller_Subclass 0x1

static auto s_pata_lock = AK::make_singleton<Lock>();
static auto s_pata_lock = make_singleton<Lock>();

static Lock& s_lock()
{
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Devices/PS2MouseDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
*/

#include <AK/Memory.h>
#include <AK/Singleton.h>
#include <Kernel/Devices/PS2MouseDevice.h>
#include <Kernel/Devices/VMWareBackdoor.h>
#include <Kernel/IO.h>
#include <Kernel/Singleton.h>

namespace Kernel {

Expand Down Expand Up @@ -57,7 +57,7 @@ namespace Kernel {

//#define PS2MOUSE_DEBUG

static auto s_the = AK::make_singleton<PS2MouseDevice>();
static auto s_the = make_singleton<PS2MouseDevice>();

PS2MouseDevice::PS2MouseDevice()
: IRQHandler(IRQ_MOUSE)
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Devices/SB16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
*/

#include <AK/Memory.h>
#include <AK/Singleton.h>
#include <AK/StringView.h>
#include <Kernel/Devices/SB16.h>
#include <Kernel/Thread.h>
#include <Kernel/VM/AnonymousVMObject.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/IO.h>
#include <Kernel/Singleton.h>

//#define SB16_DEBUG

Expand Down Expand Up @@ -77,7 +77,7 @@ void SB16::set_sample_rate(uint16_t hz)
dsp_write((u8)hz);
}

static auto s_the = AK::make_singleton<SB16>();
static auto s_the = make_singleton<SB16>();

SB16::SB16()
: IRQHandler(SB16_DEFAULT_IRQ)
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Devices/VMWareBackdoor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@

#include <AK/Assertions.h>
#include <AK/OwnPtr.h>
#include <AK/Singleton.h>
#include <AK/String.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/CommandLine.h>
#include <Kernel/Devices/VMWareBackdoor.h>
#include <Kernel/API/MousePacket.h>
#include <Kernel/IO.h>
#include <Kernel/Singleton.h>

namespace Kernel {

Expand Down Expand Up @@ -111,7 +111,7 @@ class VMWareBackdoorDetector
OwnPtr<VMWareBackdoor> m_backdoor;
};

static auto s_vmware_backdoor = AK::make_singleton<VMWareBackdoorDetector>();
static auto s_vmware_backdoor = make_singleton<VMWareBackdoorDetector>();

VMWareBackdoor* VMWareBackdoor::the()
{
Expand Down
4 changes: 2 additions & 2 deletions Kernel/FileSystem/DevPtsFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#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 {
Expand All @@ -46,7 +46,7 @@ DevPtsFS::~DevPtsFS()
{
}

static auto s_ptys = AK::make_singleton<HashTable<unsigned>>();
static auto s_ptys = make_singleton<HashTable<unsigned>>();

bool DevPtsFS::initialize()
{
Expand Down
4 changes: 2 additions & 2 deletions Kernel/FileSystem/FIFO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@
*/

#include <AK/HashTable.h>
#include <AK/Singleton.h>
#include <AK/StdLibExtras.h>
#include <AK/StringView.h>
#include <Kernel/FileSystem/FIFO.h>
#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 = AK::make_singleton<Lockable<HashTable<FIFO*>>>();
static auto s_table = make_singleton<Lockable<HashTable<FIFO*>>>();

static Lockable<HashTable<FIFO*>>& all_fifos()
{
Expand Down
4 changes: 2 additions & 2 deletions Kernel/FileSystem/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@

#include <AK/Assertions.h>
#include <AK/HashMap.h>
#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#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 = AK::make_singleton<HashMap<u32, FS*>>();
static auto s_fs_map = make_singleton<HashMap<u32, FS*>>();

static HashMap<u32, FS*>& all_fses()
{
Expand Down
4 changes: 2 additions & 2 deletions Kernel/FileSystem/Inode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/

#include <AK/NonnullRefPtrVector.h>
#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <Kernel/FileSystem/Custody.h>
Expand All @@ -34,12 +33,13 @@
#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 = AK::make_singleton<InlineLinkedList<Inode>>();
static auto s_list = make_singleton<InlineLinkedList<Inode>>();

InlineLinkedList<Inode>& Inode::all_with_lock()
{
Expand Down
4 changes: 2 additions & 2 deletions Kernel/FileSystem/VirtualFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/

#include <AK/LexicalPath.h>
#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <Kernel/Devices/BlockDevice.h>
#include <Kernel/FileSystem/Custody.h>
Expand All @@ -35,13 +34,14 @@
#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 = AK::make_singleton<VFS>();
static auto s_the = make_singleton<VFS>();
static constexpr int symlink_recursion_limit { 5 }; // FIXME: increase?
static constexpr int root_mount_flags = MS_NODEV | MS_NOSUID | MS_RDONLY;

Expand Down
4 changes: 2 additions & 2 deletions Kernel/Interrupts/APIC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#include <AK/Assertions.h>
#include <AK/Memory.h>
#include <AK/Singleton.h>
#include <AK/StringView.h>
#include <AK/Types.h>
#include <Kernel/ACPI/Parser.h>
Expand All @@ -35,6 +34,7 @@
#include <Kernel/IO.h>
#include <Kernel/Interrupts/APIC.h>
#include <Kernel/Interrupts/SpuriousInterruptHandler.h>
#include <Kernel/Singleton.h>
#include <Kernel/Thread.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/PageDirectory.h>
Expand Down Expand Up @@ -69,7 +69,7 @@

namespace Kernel {

static auto s_apic = AK::make_singleton<APIC>();
static auto s_apic = make_singleton<APIC>();

class APICIPIInterruptHandler final : public GenericInterruptHandler {
public:
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Net/IPv4Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <Kernel/Singleton.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Net/ARP.h>
#include <Kernel/Net/ICMP.h>
Expand All @@ -46,7 +46,7 @@

namespace Kernel {

static auto s_table = AK::make_singleton<Lockable<HashTable<IPv4Socket*>>>();
static auto s_table = make_singleton<Lockable<HashTable<IPv4Socket*>>>();

Lockable<HashTable<IPv4Socket*>>& IPv4Socket::all_sockets()
{
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Net/LocalSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/Net/LocalSocket.h>
#include <Kernel/Process.h>
#include <Kernel/Singleton.h>
#include <Kernel/StdLib.h>
#include <Kernel/UnixTypes.h>
#include <LibC/errno_numbers.h>
Expand All @@ -38,7 +38,7 @@

namespace Kernel {

static auto s_list = AK::make_singleton<Lockable<InlineLinkedList<LocalSocket>>>();
static auto s_list = make_singleton<Lockable<InlineLinkedList<LocalSocket>>>();

Lockable<InlineLinkedList<LocalSocket>>& LocalSocket::all_sockets()
{
Expand Down
Loading

0 comments on commit 8925ad3

Please sign in to comment.