summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Console.cpp4
-rw-r--r--Kernel/Devices/BXVGADevice.cpp4
-rw-r--r--Kernel/Devices/Device.cpp4
-rw-r--r--Kernel/Devices/KeyboardDevice.cpp4
-rw-r--r--Kernel/Devices/NullDevice.cpp4
-rw-r--r--Kernel/Devices/PATAChannel.cpp4
-rw-r--r--Kernel/Devices/PS2MouseDevice.cpp4
-rw-r--r--Kernel/Devices/SB16.cpp4
-rw-r--r--Kernel/Devices/VMWareBackdoor.cpp4
-rw-r--r--Kernel/FileSystem/DevPtsFS.cpp4
-rw-r--r--Kernel/FileSystem/FIFO.cpp4
-rw-r--r--Kernel/FileSystem/FileSystem.cpp4
-rw-r--r--Kernel/FileSystem/Inode.cpp4
-rw-r--r--Kernel/FileSystem/VirtualFileSystem.cpp4
-rw-r--r--Kernel/Interrupts/APIC.cpp4
-rw-r--r--Kernel/Net/IPv4Socket.cpp4
-rw-r--r--Kernel/Net/LocalSocket.cpp4
-rw-r--r--Kernel/Net/LoopbackAdapter.cpp4
-rw-r--r--Kernel/Net/NetworkAdapter.cpp4
-rw-r--r--Kernel/Net/Routing.cpp4
-rw-r--r--Kernel/Net/TCPSocket.cpp13
-rw-r--r--Kernel/Net/UDPSocket.cpp4
-rw-r--r--Kernel/Random.cpp4
-rw-r--r--Kernel/SharedBuffer.cpp4
-rw-r--r--Kernel/Singleton.h110
-rw-r--r--Kernel/TTY/PTYMultiplexer.cpp4
-rw-r--r--Kernel/Time/TimeManagement.cpp4
-rw-r--r--Kernel/TimerQueue.cpp4
-rw-r--r--Kernel/VM/MemoryManager.cpp4
-rw-r--r--Kernel/VM/PageDirectory.cpp4
30 files changed, 62 insertions, 173 deletions
diff --git a/Kernel/Console.cpp b/Kernel/Console.cpp
index f1416cb535..c3fa023521 100644
--- a/Kernel/Console.cpp
+++ b/Kernel/Console.cpp
@@ -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 = Kernel::make_singleton<Console>();
+static auto s_the = AK::make_singleton<Console>();
static Kernel::SpinLock g_console_lock;
void Console::initialize()
diff --git a/Kernel/Devices/BXVGADevice.cpp b/Kernel/Devices/BXVGADevice.cpp
index c31e6ec1f1..ee822dac29 100644
--- a/Kernel/Devices/BXVGADevice.cpp
+++ b/Kernel/Devices/BXVGADevice.cpp
@@ -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>
@@ -57,7 +57,7 @@ namespace Kernel {
#define VBE_DISPI_ENABLED 0x01
#define VBE_DISPI_LFB_ENABLED 0x40
-static auto s_the = make_singleton<BXVGADevice>();
+static auto s_the = AK::make_singleton<BXVGADevice>();
void BXVGADevice::initialize()
{
diff --git a/Kernel/Devices/Device.cpp b/Kernel/Devices/Device.cpp
index d89a57506c..e08a0ac6f5 100644
--- a/Kernel/Devices/Device.cpp
+++ b/Kernel/Devices/Device.cpp
@@ -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 = make_singleton<HashMap<u32, Device*>>();
+static auto s_all_devices = AK::make_singleton<HashMap<u32, Device*>>();
HashMap<u32, Device*>& Device::all_devices()
{
diff --git a/Kernel/Devices/KeyboardDevice.cpp b/Kernel/Devices/KeyboardDevice.cpp
index 2fd53797e6..192b54c721 100644
--- a/Kernel/Devices/KeyboardDevice.cpp
+++ b/Kernel/Devices/KeyboardDevice.cpp
@@ -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
@@ -336,7 +336,7 @@ void KeyboardDevice::handle_irq(const RegisterState&)
}
}
-static auto s_the = make_singleton<KeyboardDevice>();
+static auto s_the = AK::make_singleton<KeyboardDevice>();
void KeyboardDevice::initialize()
{
diff --git a/Kernel/Devices/NullDevice.cpp b/Kernel/Devices/NullDevice.cpp
index 5e64920acc..e879759d1d 100644
--- a/Kernel/Devices/NullDevice.cpp
+++ b/Kernel/Devices/NullDevice.cpp
@@ -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 = make_singleton<NullDevice>();
+static auto s_the = AK::make_singleton<NullDevice>();
void NullDevice::initialize()
{
diff --git a/Kernel/Devices/PATAChannel.cpp b/Kernel/Devices/PATAChannel.cpp
index 59295e5373..553acd412b 100644
--- a/Kernel/Devices/PATAChannel.cpp
+++ b/Kernel/Devices/PATAChannel.cpp
@@ -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 {
@@ -108,7 +108,7 @@ namespace Kernel {
#define PCI_Mass_Storage_Class 0x1
#define PCI_IDE_Controller_Subclass 0x1
-static auto s_pata_lock = make_singleton<Lock>();
+static auto s_pata_lock = AK::make_singleton<Lock>();
static Lock& s_lock()
{
diff --git a/Kernel/Devices/PS2MouseDevice.cpp b/Kernel/Devices/PS2MouseDevice.cpp
index dfb5f01bec..913b6d5c73 100644
--- a/Kernel/Devices/PS2MouseDevice.cpp
+++ b/Kernel/Devices/PS2MouseDevice.cpp
@@ -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 {
@@ -57,7 +57,7 @@ namespace Kernel {
//#define PS2MOUSE_DEBUG
-static auto s_the = make_singleton<PS2MouseDevice>();
+static auto s_the = AK::make_singleton<PS2MouseDevice>();
PS2MouseDevice::PS2MouseDevice()
: IRQHandler(IRQ_MOUSE)
diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp
index 38f81f2680..8e5611a836 100644
--- a/Kernel/Devices/SB16.cpp
+++ b/Kernel/Devices/SB16.cpp
@@ -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
@@ -77,7 +77,7 @@ void SB16::set_sample_rate(uint16_t hz)
dsp_write((u8)hz);
}
-static auto s_the = make_singleton<SB16>();
+static auto s_the = AK::make_singleton<SB16>();
SB16::SB16()
: IRQHandler(SB16_DEFAULT_IRQ)
diff --git a/Kernel/Devices/VMWareBackdoor.cpp b/Kernel/Devices/VMWareBackdoor.cpp
index 8ba15600da..04499e522a 100644
--- a/Kernel/Devices/VMWareBackdoor.cpp
+++ b/Kernel/Devices/VMWareBackdoor.cpp
@@ -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 {
@@ -111,7 +111,7 @@ private:
OwnPtr<VMWareBackdoor> m_backdoor;
};
-static auto s_vmware_backdoor = make_singleton<VMWareBackdoorDetector>();
+static auto s_vmware_backdoor = AK::make_singleton<VMWareBackdoorDetector>();
VMWareBackdoor* VMWareBackdoor::the()
{
diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp
index b3db215c5d..2849b8f58b 100644
--- a/Kernel/FileSystem/DevPtsFS.cpp
+++ b/Kernel/FileSystem/DevPtsFS.cpp
@@ -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 {
@@ -46,7 +46,7 @@ DevPtsFS::~DevPtsFS()
{
}
-static auto s_ptys = make_singleton<HashTable<unsigned>>();
+static auto s_ptys = AK::make_singleton<HashTable<unsigned>>();
bool DevPtsFS::initialize()
{
diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp
index 670266cbce..52daa26f50 100644
--- a/Kernel/FileSystem/FIFO.cpp
+++ b/Kernel/FileSystem/FIFO.cpp
@@ -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 = make_singleton<Lockable<HashTable<FIFO*>>>();
+static auto s_table = AK::make_singleton<Lockable<HashTable<FIFO*>>>();
static Lockable<HashTable<FIFO*>>& all_fifos()
{
diff --git a/Kernel/FileSystem/FileSystem.cpp b/Kernel/FileSystem/FileSystem.cpp
index 450f401253..2a96fb6e6c 100644
--- a/Kernel/FileSystem/FileSystem.cpp
+++ b/Kernel/FileSystem/FileSystem.cpp
@@ -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 = make_singleton<HashMap<u32, FS*>>();
+static auto s_fs_map = AK::make_singleton<HashMap<u32, FS*>>();
static HashMap<u32, FS*>& all_fses()
{
diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp
index c136ffc2a0..edfba2eac9 100644
--- a/Kernel/FileSystem/Inode.cpp
+++ b/Kernel/FileSystem/Inode.cpp
@@ -25,6 +25,7 @@
*/
#include <AK/NonnullRefPtrVector.h>
+#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <Kernel/FileSystem/Custody.h>
@@ -33,13 +34,12 @@
#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>>();
+static auto s_list = AK::make_singleton<InlineLinkedList<Inode>>();
InlineLinkedList<Inode>& Inode::all_with_lock()
{
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp
index cc0510a570..9ea1a2d5c7 100644
--- a/Kernel/FileSystem/VirtualFileSystem.cpp
+++ b/Kernel/FileSystem/VirtualFileSystem.cpp
@@ -25,6 +25,7 @@
*/
#include <AK/LexicalPath.h>
+#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <Kernel/Devices/BlockDevice.h>
#include <Kernel/FileSystem/Custody.h>
@@ -34,14 +35,13 @@
#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 auto s_the = AK::make_singleton<VFS>();
static constexpr int symlink_recursion_limit { 5 }; // FIXME: increase?
static constexpr int root_mount_flags = MS_NODEV | MS_NOSUID | MS_RDONLY;
diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp
index d3e86af19d..d92416ab9c 100644
--- a/Kernel/Interrupts/APIC.cpp
+++ b/Kernel/Interrupts/APIC.cpp
@@ -26,6 +26,7 @@
#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>
@@ -34,7 +35,6 @@
#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>
@@ -69,7 +69,7 @@
namespace Kernel {
-static auto s_apic = make_singleton<APIC>();
+static auto s_apic = AK::make_singleton<APIC>();
class APICIPIInterruptHandler final : public GenericInterruptHandler {
public:
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index 8286e5a2e8..2861f1a90e 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -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>
@@ -46,7 +46,7 @@
namespace Kernel {
-static auto s_table = make_singleton<Lockable<HashTable<IPv4Socket*>>>();
+static auto s_table = AK::make_singleton<Lockable<HashTable<IPv4Socket*>>>();
Lockable<HashTable<IPv4Socket*>>& IPv4Socket::all_sockets()
{
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index c703cc8ac6..6750f93403 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -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>
@@ -38,7 +38,7 @@
namespace Kernel {
-static auto s_list = make_singleton<Lockable<InlineLinkedList<LocalSocket>>>();
+static auto s_list = AK::make_singleton<Lockable<InlineLinkedList<LocalSocket>>>();
Lockable<InlineLinkedList<LocalSocket>>& LocalSocket::all_sockets()
{
diff --git a/Kernel/Net/LoopbackAdapter.cpp b/Kernel/Net/LoopbackAdapter.cpp
index 27faa8bfad..6b858c9549 100644
--- a/Kernel/Net/LoopbackAdapter.cpp
+++ b/Kernel/Net/LoopbackAdapter.cpp
@@ -24,12 +24,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Singleton.h>
#include <Kernel/Net/LoopbackAdapter.h>
-#include <Kernel/Singleton.h>
namespace Kernel {
-static auto s_loopback = make_singleton<LoopbackAdapter>();
+static auto s_loopback = AK::make_singleton<LoopbackAdapter>();
LoopbackAdapter& LoopbackAdapter::the()
{
diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp
index 936bf9a2e7..898c95d710 100644
--- a/Kernel/Net/NetworkAdapter.cpp
+++ b/Kernel/Net/NetworkAdapter.cpp
@@ -25,6 +25,7 @@
*/
#include <AK/HashTable.h>
+#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <Kernel/Heap/kmalloc.h>
#include <Kernel/Lock.h>
@@ -33,12 +34,11 @@
#include <Kernel/Net/LoopbackAdapter.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/Random.h>
-#include <Kernel/Singleton.h>
#include <Kernel/StdLib.h>
namespace Kernel {
-static auto s_table = make_singleton<Lockable<HashTable<NetworkAdapter*>>>();
+static auto s_table = AK::make_singleton<Lockable<HashTable<NetworkAdapter*>>>();
static Lockable<HashTable<NetworkAdapter*>>& all_adapters()
{
diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp
index 5f72ab1166..d73704cccf 100644
--- a/Kernel/Net/Routing.cpp
+++ b/Kernel/Net/Routing.cpp
@@ -25,16 +25,16 @@
*/
#include <AK/HashMap.h>
+#include <AK/Singleton.h>
#include <Kernel/Net/LoopbackAdapter.h>
#include <Kernel/Net/Routing.h>
#include <Kernel/Thread.h>
-#include <Kernel/Singleton.h>
//#define ROUTING_DEBUG
namespace Kernel {
-static auto s_arp_table = make_singleton<Lockable<HashMap<IPv4Address, MACAddress>>>();
+static auto s_arp_table = AK::make_singleton<Lockable<HashMap<IPv4Address, MACAddress>>>();
Lockable<HashMap<IPv4Address, MACAddress>>& arp_table()
{
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index 7b8c12a49c..af7f5bb9f4 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Singleton.h>
#include <AK/Time.h>
#include <Kernel/Devices/RandomDevice.h>
#include <Kernel/FileSystem/FileDescription.h>
@@ -33,7 +34,6 @@
#include <Kernel/Net/TCPSocket.h>
#include <Kernel/Process.h>
#include <Kernel/Random.h>
-#include <Kernel/Singleton.h>
//#define TCP_SOCKET_DEBUG
@@ -63,19 +63,18 @@ void TCPSocket::set_state(State new_state)
}
}
+static auto s_socket_closing = AK::make_singleton<Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>>();
+
Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>& TCPSocket::closing_sockets()
{
- static Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>* s_map;
- if (!s_map)
- s_map = new Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>;
- return *s_map;
+ return *s_socket_closing;
}
-static auto s_map = make_singleton<Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>>();
+static auto s_socket_tuples = AK::make_singleton<Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>>();
Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>& TCPSocket::sockets_by_tuple()
{
- return *s_map;
+ return *s_socket_tuples;
}
RefPtr<TCPSocket> TCPSocket::from_tuple(const IPv4SocketTuple& tuple)
diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp
index ad57696675..27901a2e82 100644
--- a/Kernel/Net/UDPSocket.cpp
+++ b/Kernel/Net/UDPSocket.cpp
@@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Singleton.h>
#include <Kernel/Devices/RandomDevice.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/Net/Routing.h>
@@ -31,7 +32,6 @@
#include <Kernel/Net/UDPSocket.h>
#include <Kernel/Process.h>
#include <Kernel/Random.h>
-#include <Kernel/Singleton.h>
namespace Kernel {
@@ -42,7 +42,7 @@ void UDPSocket::for_each(Function<void(const UDPSocket&)> callback)
callback(*it.value);
}
-static auto s_map = make_singleton<Lockable<HashMap<u16, UDPSocket*>>>();
+static auto s_map = AK::make_singleton<Lockable<HashMap<u16, UDPSocket*>>>();
Lockable<HashMap<u16, UDPSocket*>>& UDPSocket::sockets_by_port()
{
diff --git a/Kernel/Random.cpp b/Kernel/Random.cpp
index b01b4aa5da..472f4519c5 100644
--- a/Kernel/Random.cpp
+++ b/Kernel/Random.cpp
@@ -25,15 +25,15 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Singleton.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Devices/RandomDevice.h>
#include <Kernel/Random.h>
-#include <Kernel/Singleton.h>
#include <Kernel/Time/TimeManagement.h>
namespace Kernel {
-static auto s_the = make_singleton<KernelRng>();
+static auto s_the = AK::make_singleton<KernelRng>();
KernelRng& KernelRng::the()
{
diff --git a/Kernel/SharedBuffer.cpp b/Kernel/SharedBuffer.cpp
index 49401e15e0..a5186773a4 100644
--- a/Kernel/SharedBuffer.cpp
+++ b/Kernel/SharedBuffer.cpp
@@ -24,13 +24,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Singleton.h>
#include <Kernel/Process.h>
-#include <Kernel/Singleton.h>
#include <Kernel/SharedBuffer.h>
namespace Kernel {
-static auto s_map = make_singleton<Lockable<HashMap<int, NonnullOwnPtr<SharedBuffer>>>>();
+static auto s_map = AK::make_singleton<Lockable<HashMap<int, NonnullOwnPtr<SharedBuffer>>>>();
Lockable<HashMap<int, NonnullOwnPtr<SharedBuffer>>>& shared_buffers()
{
diff --git a/Kernel/Singleton.h b/Kernel/Singleton.h
deleted file mode 100644
index 5271aa08ee..0000000000
--- a/Kernel/Singleton.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2020, the SerenityOS developers.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <AK/Atomic.h>
-#include <Kernel/Arch/i386/CPU.h>
-
-namespace Kernel {
-
-template<typename T, T* (*InitFunction)()>
-class Singleton {
-public:
- T* ptr() const
- {
- T* obj = AK::atomic_load(&m_obj, AK::memory_order_consume);
- if (FlatPtr(obj) <= 0x1) {
- // If this is the first time, see if we get to initialize it
- ScopedCritical critical;
- if (obj == nullptr && AK::atomic_compare_exchange_strong(&m_obj, obj, (T*)0x1, AK::memory_order_acq_rel)) {
- // We're the first one
- obj = InitFunction();
- AK::atomic_store(&m_obj, obj, AK::memory_order_release);
- } else {
- // Someone else was faster, wait until they're done
- while (obj == (T*)0x1) {
- Processor::wait_check();
- obj = AK::atomic_load(&m_obj, AK::memory_order_consume);
- }
- }
- // We should always return an instance
- ASSERT(obj != nullptr);
- ASSERT(obj != (T*)0x1);
- }
- return obj;
- }
-
- T* operator->() const
- {
- return ptr();
- }
-
- T& operator*() const
- {
- return *ptr();
- }
-
- operator T*() const
- {
- return ptr();
- }
-
- operator T&() const
- {
- return *ptr();
- }
-
- bool is_initialized() const
- {
- T* obj = AK::atomic_load(&m_obj, AK::memory_order_consume);
- return FlatPtr(obj) > 0x1;
- }
-
- void ensure_instance()
- {
- (void)ptr();
- }
-
-private:
- mutable T* m_obj { nullptr }; // atomic
-};
-
-template<typename T>
-struct SingletonInstanceCreator {
- static T* create()
- {
- return new T();
- }
-};
-
-template<typename T>
-static Singleton<T, SingletonInstanceCreator<T>::create> make_singleton()
-{
- return Singleton<T, SingletonInstanceCreator<T>::create>();
-}
-
-}
diff --git a/Kernel/TTY/PTYMultiplexer.cpp b/Kernel/TTY/PTYMultiplexer.cpp
index 4f8d48806e..c44a565ae9 100644
--- a/Kernel/TTY/PTYMultiplexer.cpp
+++ b/Kernel/TTY/PTYMultiplexer.cpp
@@ -26,9 +26,9 @@
#include "PTYMultiplexer.h"
#include "MasterPTY.h"
+#include <AK/Singleton.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Process.h>
-#include <Kernel/Singleton.h>
#include <LibC/errno_numbers.h>
//#define PTMX_DEBUG
@@ -36,7 +36,7 @@
namespace Kernel {
static const unsigned s_max_pty_pairs = 8;
-static auto s_the = make_singleton<PTYMultiplexer>();
+static auto s_the = AK::make_singleton<PTYMultiplexer>();
PTYMultiplexer& PTYMultiplexer::the()
{
diff --git a/Kernel/Time/TimeManagement.cpp b/Kernel/Time/TimeManagement.cpp
index 7982c354b5..ff37fa33aa 100644
--- a/Kernel/Time/TimeManagement.cpp
+++ b/Kernel/Time/TimeManagement.cpp
@@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Singleton.h>
#include <Kernel/ACPI/Parser.h>
#include <Kernel/CommandLine.h>
#include <Kernel/Scheduler.h>
@@ -32,7 +33,6 @@
#include <Kernel/Time/HardwareTimer.h>
#include <Kernel/Time/PIT.h>
#include <Kernel/Time/RTC.h>
-#include <Kernel/Singleton.h>
#include <Kernel/Time/TimeManagement.h>
#include <Kernel/VM/MemoryManager.h>
@@ -40,7 +40,7 @@
namespace Kernel {
-static auto s_the = make_singleton<TimeManagement>();
+static auto s_the = AK::make_singleton<TimeManagement>();
TimeManagement& TimeManagement::the()
{
diff --git a/Kernel/TimerQueue.cpp b/Kernel/TimerQueue.cpp
index 41197d6861..d12e4ecd52 100644
--- a/Kernel/TimerQueue.cpp
+++ b/Kernel/TimerQueue.cpp
@@ -27,14 +27,14 @@
#include <AK/Function.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/OwnPtr.h>
+#include <AK/Singleton.h>
#include <Kernel/Scheduler.h>
-#include <Kernel/Singleton.h>
#include <Kernel/Time/TimeManagement.h>
#include <Kernel/TimerQueue.h>
namespace Kernel {
-static auto s_the = make_singleton<TimerQueue>();
+static auto s_the = AK::make_singleton<TimerQueue>();
TimerQueue& TimerQueue::the()
{
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index 8280503679..9c984de81e 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -26,6 +26,7 @@
#include <AK/Assertions.h>
#include <AK/Memory.h>
+#include <AK/Singleton.h>
#include <AK/StringView.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/CMOS.h>
@@ -39,7 +40,6 @@
#include <Kernel/VM/PhysicalRegion.h>
#include <Kernel/VM/PurgeableVMObject.h>
#include <Kernel/VM/SharedInodeVMObject.h>
-#include <Kernel/Singleton.h>
#include <Kernel/StdLib.h>
//#define MM_DEBUG
@@ -51,7 +51,7 @@ extern FlatPtr end_of_kernel_bss;
namespace Kernel {
-static auto s_the = make_singleton<MemoryManager>();
+static auto s_the = AK::make_singleton<MemoryManager>();
RecursiveSpinLock s_mm_lock;
MemoryManager& MM
diff --git a/Kernel/VM/PageDirectory.cpp b/Kernel/VM/PageDirectory.cpp
index 1b15853d94..573caa28db 100644
--- a/Kernel/VM/PageDirectory.cpp
+++ b/Kernel/VM/PageDirectory.cpp
@@ -25,9 +25,9 @@
*/
#include <AK/Memory.h>
+#include <AK/Singleton.h>
#include <Kernel/Process.h>
#include <Kernel/Random.h>
-#include <Kernel/Singleton.h>
#include <Kernel/Thread.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/PageDirectory.h>
@@ -38,7 +38,7 @@ static const FlatPtr userspace_range_base = 0x00800000;
static const FlatPtr userspace_range_ceiling = 0xbe000000;
static const FlatPtr kernelspace_range_base = 0xc0800000;
-static auto s_cr3_map = make_singleton<HashMap<u32, PageDirectory*>>();
+static auto s_cr3_map = AK::make_singleton<HashMap<u32, PageDirectory*>>();
static HashMap<u32, PageDirectory*>& cr3_map()
{