From 7d0bf9b5a9b635eb54f34843d17ea38d7c18092e Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sat, 4 Apr 2020 15:48:28 +0430 Subject: [PATCH] Kernel+AK: Separate out MACAddress and move it into AK --- {Kernel/Net => AK}/MACAddress.h | 7 +++---- Kernel/Net/ARP.h | 2 +- Kernel/Net/EthernetFrameHeader.h | 2 +- Kernel/Net/ICMP.h | 2 +- Kernel/Net/NetworkAdapter.h | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) rename {Kernel/Net => AK}/MACAddress.h (94%) diff --git a/Kernel/Net/MACAddress.h b/AK/MACAddress.h similarity index 94% rename from Kernel/Net/MACAddress.h rename to AK/MACAddress.h index 4ad391d0fa..4de31bfcc8 100644 --- a/Kernel/Net/MACAddress.h +++ b/AK/MACAddress.h @@ -29,7 +29,6 @@ #include #include #include -#include class [[gnu::packed]] MACAddress { @@ -37,7 +36,7 @@ public: MACAddress() {} MACAddress(const u8 data[6]) { - memcpy(m_data, data, 6); + __builtin_memcpy(m_data, data, 6); } MACAddress(u8 a, u8 b, u8 c, u8 d, u8 e, u8 f) { @@ -58,7 +57,7 @@ public: bool operator==(const MACAddress& other) const { - return !memcmp(m_data, other.m_data, sizeof(m_data)); + return !__builtin_memcmp(m_data, other.m_data, sizeof(m_data)); } String to_string() const @@ -79,7 +78,7 @@ static_assert(sizeof(MACAddress) == 6); namespace AK { -template<> +template <> struct Traits : public GenericTraits { static unsigned hash(const MACAddress& address) { return string_hash((const char*)&address, sizeof(address)); } }; diff --git a/Kernel/Net/ARP.h b/Kernel/Net/ARP.h index 37e6faa140..e467faec20 100644 --- a/Kernel/Net/ARP.h +++ b/Kernel/Net/ARP.h @@ -26,10 +26,10 @@ #pragma once +#include #include #include #include -#include namespace Kernel { diff --git a/Kernel/Net/EthernetFrameHeader.h b/Kernel/Net/EthernetFrameHeader.h index 7d68561f08..f73ae2a358 100644 --- a/Kernel/Net/EthernetFrameHeader.h +++ b/Kernel/Net/EthernetFrameHeader.h @@ -26,8 +26,8 @@ #pragma once +#include #include -#include #pragma GCC diagnostic ignored "-Warray-bounds" diff --git a/Kernel/Net/ICMP.h b/Kernel/Net/ICMP.h index 9ed356bfcd..bf9a2265e0 100644 --- a/Kernel/Net/ICMP.h +++ b/Kernel/Net/ICMP.h @@ -26,8 +26,8 @@ #pragma once +#include #include -#include struct ICMPType { enum { diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h index b7cea4f5ed..59f6767da0 100644 --- a/Kernel/Net/NetworkAdapter.h +++ b/Kernel/Net/NetworkAdapter.h @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -36,7 +37,6 @@ #include #include #include -#include namespace Kernel {