diff options
author | Andrew Kaster <akaster@serenityos.org> | 2023-01-07 13:57:33 -0700 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2023-01-21 10:43:59 -0700 |
commit | 7ab37ee22cb85820ec73f0677f06125c466feeff (patch) | |
tree | 2c379f4e95a9b48dfb20a4d615b39d583bd96149 /Kernel | |
parent | 0420736143067c16339a08ced1ff16da36e4e163 (diff) | |
download | serenity-7ab37ee22cb85820ec73f0677f06125c466feeff.zip |
Everywhere: Remove string.h include from AK/Traits.h and resolve fallout
A lot of places were relying on AK/Traits.h to give it strnlen, memcmp,
memcpy and other related declarations.
In the quest to remove inclusion of LibC headers from Kernel files, deal
with all the fallout of this included-everywhere header including less
things.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Bus/USB/USBConfiguration.cpp | 1 | ||||
-rw-r--r-- | Kernel/Bus/USB/USBTransfer.cpp | 1 | ||||
-rw-r--r-- | Kernel/FileSystem/Ext2FS/Inode.cpp | 6 | ||||
-rw-r--r-- | Kernel/KBuffer.h | 1 | ||||
-rw-r--r-- | Kernel/StdLib.h | 2 |
5 files changed, 8 insertions, 3 deletions
diff --git a/Kernel/Bus/USB/USBConfiguration.cpp b/Kernel/Bus/USB/USBConfiguration.cpp index 93229d1e88..bf913f0006 100644 --- a/Kernel/Bus/USB/USBConfiguration.cpp +++ b/Kernel/Bus/USB/USBConfiguration.cpp @@ -9,6 +9,7 @@ #include <Kernel/Bus/USB/USBConfiguration.h> #include <Kernel/Bus/USB/USBInterface.h> #include <Kernel/Bus/USB/USBRequest.h> +#include <Kernel/StdLib.h> namespace Kernel::USB { diff --git a/Kernel/Bus/USB/USBTransfer.cpp b/Kernel/Bus/USB/USBTransfer.cpp index ada524d4f0..528df1ae30 100644 --- a/Kernel/Bus/USB/USBTransfer.cpp +++ b/Kernel/Bus/USB/USBTransfer.cpp @@ -6,6 +6,7 @@ #include <Kernel/Bus/USB/USBTransfer.h> #include <Kernel/Memory/MemoryManager.h> +#include <Kernel/StdLib.h> namespace Kernel::USB { diff --git a/Kernel/FileSystem/Ext2FS/Inode.cpp b/Kernel/FileSystem/Ext2FS/Inode.cpp index 9ac62cb7d6..29436f1821 100644 --- a/Kernel/FileSystem/Ext2FS/Inode.cpp +++ b/Kernel/FileSystem/Ext2FS/Inode.cpp @@ -992,11 +992,11 @@ ErrorOr<void> Ext2FSInode::update_timestamps(Optional<Time> atime, Optional<Time MutexLocker locker(m_inode_lock); if (fs().is_readonly()) return EROFS; - if (atime.value_or({}).to_timespec().tv_sec > INT32_MAX) + if (atime.value_or({}).to_timespec().tv_sec > NumericLimits<i32>::max()) return EINVAL; - if (ctime.value_or({}).to_timespec().tv_sec > INT32_MAX) + if (ctime.value_or({}).to_timespec().tv_sec > NumericLimits<i32>::max()) return EINVAL; - if (mtime.value_or({}).to_timespec().tv_sec > INT32_MAX) + if (mtime.value_or({}).to_timespec().tv_sec > NumericLimits<i32>::max()) return EINVAL; if (atime.has_value()) m_raw_inode.i_atime = atime.value().to_timespec().tv_sec; diff --git a/Kernel/KBuffer.h b/Kernel/KBuffer.h index a3bf599820..77a1729b8a 100644 --- a/Kernel/KBuffer.h +++ b/Kernel/KBuffer.h @@ -18,6 +18,7 @@ #include <AK/Assertions.h> #include <AK/StringView.h> #include <Kernel/Memory/MemoryManager.h> +#include <Kernel/StdLib.h> // For memcpy. FIXME: Make memcpy less expensive to access a declaration of in the Kernel. namespace Kernel { diff --git a/Kernel/StdLib.h b/Kernel/StdLib.h index d45d33872e..b420e0dc44 100644 --- a/Kernel/StdLib.h +++ b/Kernel/StdLib.h @@ -51,6 +51,8 @@ void const* memmem(void const* haystack, size_t, void const* needle, size_t); [[nodiscard]] inline u16 htons(u16 w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); } } +#define offsetof(type, member) __builtin_offsetof(type, member) + template<typename T> [[nodiscard]] inline ErrorOr<void> copy_from_user(T* dest, T const* src) { |