Преглед изворни кода

AK: Remove bitrotted Traits::dump() mechanism

This was only used by HashTable::dump() which I used when doing the
first HashTable implementation. Removing this allows us to also remove
most includes of <AK/kstdio.h>.
Andreas Kling пре 5 година
родитељ
комит
6cbd72f54f

+ 0 - 1
AK/FileSystemPath.cpp

@@ -27,7 +27,6 @@
 #include "FileSystemPath.h"
 #include "StringBuilder.h"
 #include "Vector.h"
-#include "kstdio.h"
 
 namespace AK {
 

+ 0 - 10
AK/HashMap.h

@@ -30,7 +30,6 @@
 #include <AK/Optional.h>
 #include <AK/StdLibExtras.h>
 #include <AK/Vector.h>
-#include <AK/kstdio.h>
 
 namespace AK {
 
@@ -45,13 +44,6 @@ private:
     struct EntryTraits {
         static unsigned hash(const Entry& entry) { return KeyTraits::hash(entry.key); }
         static bool equals(const Entry& a, const Entry& b) { return KeyTraits::equals(a.key, b.key); }
-        static void dump(const Entry& entry)
-        {
-            kprintf("key=");
-            KeyTraits::dump(entry.key);
-            kprintf(" value=");
-            Traits<V>::dump(entry.value);
-        }
     };
 
 public:
@@ -102,8 +94,6 @@ public:
 
     void ensure_capacity(int capacity) { m_table.ensure_capacity(capacity); }
 
-    void dump() const { m_table.dump(); }
-
     Optional<typename Traits<V>::PeekType> get(const K& key) const
     {
         auto it = find(key);

+ 0 - 18
AK/HashTable.h

@@ -31,7 +31,6 @@
 #include <AK/StdLibExtras.h>
 #include <AK/TemporaryChange.h>
 #include <AK/Traits.h>
-#include <AK/kstdio.h>
 
 namespace AK {
 
@@ -163,8 +162,6 @@ public:
     bool contains(const T&) const;
     void clear();
 
-    void dump() const;
-
     using Iterator = HashTableIterator<HashTable, T, typename Bucket::Iterator>;
     friend Iterator;
     Iterator begin() { return Iterator(*this, is_empty()); }
@@ -380,21 +377,6 @@ auto HashTable<T, TraitsForT>::lookup(const T& value, int* bucket_index) const -
     return m_buckets[hash % m_capacity];
 }
 
-template<typename T, typename TraitsForT>
-void HashTable<T, TraitsForT>::dump() const
-{
-    kprintf("HashTable{%p} m_size=%u, m_capacity=%u, m_buckets=%p\n", this, m_size, m_capacity, m_buckets);
-    for (int i = 0; i < m_capacity; ++i) {
-        auto& bucket = m_buckets[i];
-        kprintf("Bucket %u\n", i);
-        for (auto& e : bucket) {
-            kprintf("  > ");
-            TraitsForT::dump(e);
-            kprintf("\n");
-        }
-    }
-}
-
 }
 
 using AK::HashTable;

+ 0 - 1
AK/IPv4Address.h

@@ -115,7 +115,6 @@ static_assert(sizeof(IPv4Address) == 4);
 template<>
 struct Traits<IPv4Address> : public GenericTraits<IPv4Address> {
     static unsigned hash(const IPv4Address& address) { return string_hash((const char*)&address, sizeof(address)); }
-    static void dump(const IPv4Address& address) { kprintf("%s", address.to_string().characters()); }
 };
 
 inline const LogStream& operator<<(const LogStream& stream, const IPv4Address& value)

+ 0 - 1
AK/NonnullOwnPtr.h

@@ -178,7 +178,6 @@ template<typename T>
 struct Traits<NonnullOwnPtr<T>> : public GenericTraits<NonnullOwnPtr<T>> {
     using PeekType = const T*;
     static unsigned hash(const NonnullOwnPtr<T>& p) { return int_hash((u32)p.ptr()); }
-    static void dump(const NonnullOwnPtr<T>& p) { kprintf("%p", p.ptr()); }
     static bool equals(const NonnullOwnPtr<T>& a, const NonnullOwnPtr<T>& b) { return a.ptr() == b.ptr(); }
 };
 

+ 0 - 1
AK/OwnPtr.h

@@ -205,7 +205,6 @@ template<typename T>
 struct Traits<OwnPtr<T>> : public GenericTraits<OwnPtr<T>> {
     using PeekType = const T*;
     static unsigned hash(const OwnPtr<T>& p) { return int_hash((u32)p.ptr()); }
-    static void dump(const OwnPtr<T>& p) { kprintf("%p", p.ptr()); }
     static bool equals(const OwnPtr<T>& a, const OwnPtr<T>& b) { return a.ptr() == b.ptr(); }
 };
 

+ 0 - 2
AK/String.h

@@ -32,7 +32,6 @@
 #include <AK/StringView.h>
 #include <AK/Traits.h>
 #include <AK/Vector.h>
-#include <AK/kstdio.h>
 
 namespace AK {
 
@@ -264,7 +263,6 @@ inline bool StringView::operator==(const String& string) const
 template<>
 struct Traits<String> : public GenericTraits<String> {
     static unsigned hash(const String& s) { return s.impl() ? s.impl()->hash() : 0; }
-    static void dump(const String& s) { kprintf("%s", s.characters()); }
 };
 
 struct CaseInsensitiveStringTraits : public AK::Traits<String> {

+ 1 - 8
AK/Traits.h

@@ -26,8 +26,7 @@
 
 #pragma once
 
-#include "HashFunctions.h"
-#include "kstdio.h"
+#include <AK/HashFunctions.h>
 
 namespace AK {
 
@@ -46,35 +45,30 @@ template<>
 struct Traits<int> : public GenericTraits<int> {
     static constexpr bool is_trivial() { return true; }
     static unsigned hash(int i) { return int_hash(i); }
-    static void dump(int i) { kprintf("%d", i); }
 };
 
 template<>
 struct Traits<unsigned> : public GenericTraits<unsigned> {
     static constexpr bool is_trivial() { return true; }
     static unsigned hash(unsigned u) { return int_hash(u); }
-    static void dump(unsigned u) { kprintf("%u", u); }
 };
 
 template<>
 struct Traits<u16> : public GenericTraits<u16> {
     static constexpr bool is_trivial() { return true; }
     static unsigned hash(u16 u) { return int_hash(u); }
-    static void dump(u16 u) { kprintf("%u", u); }
 };
 
 template<>
 struct Traits<u64> : public GenericTraits<u64> {
     static constexpr bool is_trivial() { return true; }
     static unsigned hash(u64 u) { return u64_hash(u); }
-    static void dump(u64 u) { kprintf("%u", (unsigned)u); } // FIXME: Implement unsigned long long printf specifier, instead of this sadness :(
 };
 
 template<>
 struct Traits<char> : public GenericTraits<char> {
     static constexpr bool is_trivial() { return true; }
     static unsigned hash(char c) { return int_hash(c); }
-    static void dump(char c) { kprintf("%c", c); }
 };
 
 template<typename T>
@@ -84,7 +78,6 @@ struct Traits<T*> : public GenericTraits<T*> {
         return int_hash((unsigned)(__PTRDIFF_TYPE__)p);
     }
     static constexpr bool is_trivial() { return true; }
-    static void dump(const T* p) { kprintf("%p", p); }
     static bool equals(const T* a, const T* b) { return a == b; }
 };
 

+ 0 - 2
Applications/Taskbar/WindowIdentifier.h

@@ -27,7 +27,6 @@
 #pragma once
 
 #include <AK/Traits.h>
-#include <AK/kstdio.h>
 
 class WindowIdentifier {
 public:
@@ -54,6 +53,5 @@ namespace AK {
 template<>
 struct Traits<WindowIdentifier> : public GenericTraits<WindowIdentifier> {
     static unsigned hash(const WindowIdentifier& w) { return pair_int_hash(w.client_id(), w.window_id()); }
-    static void dump(const WindowIdentifier& w) { kprintf("WindowIdentifier(%d, %d)", w.client_id(), w.window_id()); }
 };
 }

+ 0 - 1
Demos/DynamicLink/LinkLib/DynamicLib.cpp

@@ -24,7 +24,6 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <AK/kstdio.h>
 #include <AK/String.h>
 #include <assert.h>
 #include <stdio.h>

+ 0 - 1
Kernel/Devices/FullDevice.cpp

@@ -26,7 +26,6 @@
 
 #include "FullDevice.h"
 #include <AK/StdLibExtras.h>
-#include <AK/kstdio.h>
 #include <LibC/errno_numbers.h>
 
 FullDevice::FullDevice()

+ 0 - 1
Kernel/Devices/NullDevice.cpp

@@ -26,7 +26,6 @@
 
 #include "NullDevice.h"
 #include <AK/StdLibExtras.h>
-#include <AK/kstdio.h>
 
 static NullDevice* s_the;
 

+ 0 - 1
Kernel/Devices/ZeroDevice.cpp

@@ -26,7 +26,6 @@
 
 #include "ZeroDevice.h"
 #include <AK/StdLibExtras.h>
-#include <AK/kstdio.h>
 
 ZeroDevice::ZeroDevice()
     : CharacterDevice(1, 5)

+ 0 - 2
Kernel/FileSystem/FileSystem.h

@@ -34,7 +34,6 @@
 #include <AK/RefPtr.h>
 #include <AK/String.h>
 #include <AK/WeakPtr.h>
-#include <AK/kstdio.h>
 #include <Kernel/Devices/BlockDevice.h>
 #include <Kernel/FileSystem/InodeIdentifier.h>
 #include <Kernel/FileSystem/InodeMetadata.h>
@@ -128,7 +127,6 @@ namespace AK {
 template<>
 struct Traits<InodeIdentifier> : public GenericTraits<InodeIdentifier> {
     static unsigned hash(const InodeIdentifier& inode) { return pair_int_hash(inode.fsid(), inode.index()); }
-    static void dump(const InodeIdentifier& inode) { kprintf("%02u:%08u", inode.fsid(), inode.index()); }
 };
 
 }

+ 0 - 5
Kernel/Net/IPv4SocketTuple.h

@@ -79,11 +79,6 @@ struct Traits<IPv4SocketTuple> : public GenericTraits<IPv4SocketTuple> {
         auto h2 = pair_int_hash(tuple.peer_address().to_u32(), tuple.peer_port());
         return pair_int_hash(h1, h2);
     }
-
-    static void dump(const IPv4SocketTuple& tuple)
-    {
-        kprintf("%s", tuple.to_string().characters());
-    }
 };
 
 }

+ 0 - 1
Kernel/Net/MACAddress.h

@@ -82,7 +82,6 @@ namespace AK {
 template<>
 struct Traits<MACAddress> : public GenericTraits<MACAddress> {
     static unsigned hash(const MACAddress& address) { return string_hash((const char*)&address, sizeof(address)); }
-    static void dump(const MACAddress& address) { kprintf("%s", address.to_string().characters()); }
 };
 
 }

+ 0 - 1
Kernel/ProcessTracer.cpp

@@ -24,7 +24,6 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <AK/kstdio.h>
 #include <Kernel/ProcessTracer.h>
 
 ProcessTracer::ProcessTracer(pid_t pid)

+ 2 - 0
Kernel/SharedBuffer.cpp

@@ -100,6 +100,8 @@ void* SharedBuffer::ref_for_process_and_get_address(Process& process)
 void SharedBuffer::share_with(pid_t peer_pid)
 {
     LOCKER(shared_buffers().lock());
+    if (m_global)
+        return;
     for (auto& ref : m_refs) {
         if (ref.pid == peer_pid) {
             // don't increment the reference count yet; let them get_shared_buffer it first.

+ 0 - 1
Kernel/TestModule.cpp

@@ -25,7 +25,6 @@
  */
 
 #include <Kernel/Process.h>
-#include <LibBareMetal/Output/kstdio.h>
 
 extern "C" const char module_name[] = "TestModule";
 

+ 0 - 1
Kernel/VM/MemoryManager.cpp

@@ -27,7 +27,6 @@
 #include "CMOS.h"
 #include "Process.h"
 #include <AK/Assertions.h>
-#include <AK/kstdio.h>
 #include <Kernel/Arch/i386/CPU.h>
 #include <Kernel/FileSystem/Inode.h>
 #include <Kernel/Multiboot.h>

+ 0 - 1
Kernel/init.cpp

@@ -70,7 +70,6 @@
 #include <Kernel/TTY/PTYMultiplexer.h>
 #include <Kernel/TTY/VirtualConsole.h>
 #include <Kernel/VM/MemoryManager.h>
-#include <LibBareMetal/Output/kstdio.h>
 
 [[noreturn]] static void init_stage2();
 static void setup_serial_debug();

+ 0 - 1
Libraries/LibCore/Object.cpp

@@ -26,7 +26,6 @@
 
 #include <AK/Assertions.h>
 #include <AK/JsonObject.h>
-#include <AK/kstdio.h>
 #include <LibCore/Event.h>
 #include <LibCore/EventLoop.h>
 #include <LibCore/Object.h>

+ 0 - 1
Libraries/LibELF/ELFImage.cpp

@@ -25,7 +25,6 @@
  */
 
 #include <AK/StringBuilder.h>
-#include <AK/kstdio.h>
 #include <LibELF/ELFImage.h>
 
 ELFImage::ELFImage(const u8* buffer, size_t size)

+ 0 - 1
Libraries/LibELF/ELFLoader.cpp

@@ -27,7 +27,6 @@
 #include "ELFLoader.h"
 #include <AK/Demangle.h>
 #include <AK/QuickSort.h>
-#include <AK/kstdio.h>
 
 #ifdef KERNEL
 #include <Kernel/VM/MemoryManager.h>