AK+Kernel: Move KResult.h to Kernel/API for userspace access

This commit moves the KResult and KResultOr objects to Kernel/API to
signify that they may now be freely used by userspace code at points
where a syscall-related error result is to be expected. It also exposes
KResult and KResultOr to the global namespace to make it nicer to use
for userspace code.
This commit is contained in:
sin-ack 2021-09-04 21:04:10 +00:00 committed by Andreas Kling
parent d8de352ead
commit 566c5d1e99
Notes: sideshowbarker 2024-07-18 04:44:10 +09:00
24 changed files with 28 additions and 25 deletions

View file

@ -9,7 +9,7 @@
#include <AK/NonnullOwnPtr.h>
#include <AK/RefCounted.h>
#ifdef KERNEL
# include <Kernel/KResult.h>
# include <Kernel/API/KResult.h>
#endif
namespace AK {

View file

@ -14,9 +14,9 @@
#include <AK/Traits.h>
#include <AK/Types.h>
#ifdef KERNEL
# include <Kernel/API/KResult.h>
# include <Kernel/Arch/x86/Processor.h>
# include <Kernel/Arch/x86/ScopedCritical.h>
# include <Kernel/KResult.h>
#endif
namespace AK {

View file

@ -173,8 +173,12 @@ private:
}
using Kernel::KResult;
using Kernel::KResultOr;
using Kernel::KSuccess;
template<>
struct AK::Formatter<Kernel::KResult> : Formatter<FormatString> {
struct AK::Formatter<KResult> : Formatter<FormatString> {
void format(FormatBuilder& builder, Kernel::KResult value)
{
if (value.is_error())

View file

@ -8,9 +8,9 @@
#include <AK/NonnullOwnPtr.h>
#include <AK/NonnullRefPtr.h>
#include <Kernel/API/KResult.h>
#include <Kernel/Bus/USB/USBHub.h>
#include <Kernel/Bus/USB/USBTransfer.h>
#include <Kernel/KResult.h>
namespace Kernel::USB {

View file

@ -7,9 +7,9 @@
#pragma once
#include <AK/RefCounted.h>
#include <Kernel/API/KResult.h>
#include <Kernel/Bus/USB/USBDevice.h>
#include <Kernel/Bus/USB/USBTransfer.h>
#include <Kernel/KResult.h>
namespace Kernel::USB {

View file

@ -12,9 +12,9 @@
#include <AK/RefPtr.h>
#include <AK/Time.h>
#include <AK/Types.h>
#include <Kernel/API/KResult.h>
#include <Kernel/API/KeyCode.h>
#include <Kernel/API/MousePacket.h>
#include <Kernel/KResult.h>
#include <Kernel/Locking/Spinlock.h>
#include <Kernel/UnixTypes.h>
#include <LibKeyboard/CharacterMap.h>

View file

@ -10,9 +10,9 @@
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/String.h>
#include <Kernel/API/KResult.h>
#include <Kernel/Forward.h>
#include <Kernel/Heap/SlabAllocator.h>
#include <Kernel/KResult.h>
#include <Kernel/KString.h>
namespace Kernel {

View file

@ -11,8 +11,8 @@
#include <AK/String.h>
#include <AK/Types.h>
#include <AK/Weakable.h>
#include <Kernel/API/KResult.h>
#include <Kernel/Forward.h>
#include <Kernel/KResult.h>
#include <Kernel/UnixTypes.h>
#include <Kernel/UserOrKernelBuffer.h>
#include <Kernel/VirtualAddress.h>

View file

@ -9,9 +9,9 @@
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/StringView.h>
#include <Kernel/API/KResult.h>
#include <Kernel/FileSystem/InodeIdentifier.h>
#include <Kernel/Forward.h>
#include <Kernel/KResult.h>
#include <Kernel/Locking/Mutex.h>
#include <Kernel/UnixTypes.h>
#include <Kernel/UserOrKernelBuffer.h>

View file

@ -5,7 +5,6 @@
*/
#include "ISO9660FileSystem.h"
#include "Kernel/FileSystem/BlockBasedFileSystem.h"
#include <AK/CharacterTypes.h>
#include <AK/Endian.h>
#include <AK/HashFunctions.h>
@ -15,9 +14,9 @@
#include <AK/StringHash.h>
#include <AK/StringView.h>
#include <Kernel/Debug.h>
#include <Kernel/FileSystem/BlockBasedFileSystem.h>
#include <Kernel/Forward.h>
#include <Kernel/KBuffer.h>
#include <Kernel/KResult.h>
#include <Kernel/UnixTypes.h>
#include <Kernel/UserOrKernelBuffer.h>

View file

@ -12,10 +12,10 @@
#include <AK/RecursionDecision.h>
#include <AK/StringView.h>
#include <AK/Types.h>
#include <Kernel/API/KResult.h>
#include <Kernel/FileSystem/BlockBasedFileSystem.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/KBuffer.h>
#include <Kernel/KResult.h>
namespace Kernel {

View file

@ -12,12 +12,12 @@
#include <AK/IntrusiveList.h>
#include <AK/String.h>
#include <AK/WeakPtr.h>
#include <Kernel/API/KResult.h>
#include <Kernel/FileSystem/FIFO.h>
#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/FileSystem/InodeIdentifier.h>
#include <Kernel/FileSystem/InodeMetadata.h>
#include <Kernel/Forward.h>
#include <Kernel/KResult.h>
#include <Kernel/Library/ListedRefCounted.h>
#include <Kernel/Locking/Mutex.h>

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/Span.h>
#include <Kernel/API/KResult.h>
#include <Kernel/FileSystem/InodeIdentifier.h>
#include <Kernel/KResult.h>
#include <Kernel/UnixTypes.h>
namespace Kernel {

View file

@ -11,11 +11,11 @@
#include <AK/RefPtr.h>
#include <AK/StringView.h>
#include <AK/Types.h>
#include <Kernel/API/KResult.h>
#include <Kernel/FileSystem/File.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/Forward.h>
#include <Kernel/KResult.h>
namespace Kernel {

View file

@ -13,13 +13,13 @@
#include <AK/OwnPtr.h>
#include <AK/RefPtr.h>
#include <AK/String.h>
#include <Kernel/API/KResult.h>
#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/FileSystem/InodeIdentifier.h>
#include <Kernel/FileSystem/InodeMetadata.h>
#include <Kernel/FileSystem/Mount.h>
#include <Kernel/FileSystem/UnveilNode.h>
#include <Kernel/Forward.h>
#include <Kernel/KResult.h>
#include <Kernel/Locking/MutexProtected.h>
namespace Kernel {

View file

@ -7,7 +7,7 @@
#pragma once
#include <Kernel/KResult.h>
#include <Kernel/API/KResult.h>
#include <Kernel/VirtualAddress.h>
namespace Kernel::Memory {

View file

@ -10,8 +10,8 @@
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/Time.h>
#include <Kernel/API/KResult.h>
#include <Kernel/FileSystem/File.h>
#include <Kernel/KResult.h>
#include <Kernel/Locking/Mutex.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/UnixTypes.h>

View file

@ -10,7 +10,7 @@
#include <AK/HashMap.h>
#include <AK/SinglyLinkedList.h>
#include <AK/WeakPtr.h>
#include <Kernel/KResult.h>
#include <Kernel/API/KResult.h>
#include <Kernel/Locking/MutexProtected.h>
#include <Kernel/Net/IPv4Socket.h>

View file

@ -6,7 +6,7 @@
#pragma once
#include <Kernel/KResult.h>
#include <Kernel/API/KResult.h>
#include <Kernel/Locking/MutexProtected.h>
#include <Kernel/Net/IPv4Socket.h>

View file

@ -6,8 +6,8 @@
#pragma once
#include <Kernel/API/KResult.h>
#include <Kernel/KBuffer.h>
#include <Kernel/KResult.h>
namespace Kernel {

View file

@ -11,12 +11,12 @@
#include <AK/RefPtr.h>
#include <AK/String.h>
#include <AK/Types.h>
#include <Kernel/API/KResult.h>
#include <Kernel/Arch/x86/CPU.h>
#include <Kernel/FileSystem/File.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/KBufferBuilder.h>
#include <Kernel/KResult.h>
#include <Kernel/UserOrKernelBuffer.h>
namespace Kernel {

View file

@ -10,7 +10,7 @@
#include <AK/Forward.h>
#include <AK/Time.h>
#include <AK/Userspace.h>
#include <Kernel/KResult.h>
#include <Kernel/API/KResult.h>
#include <Kernel/KString.h>
#include <Kernel/UnixTypes.h>

View file

@ -19,12 +19,12 @@
#include <AK/Vector.h>
#include <AK/WeakPtr.h>
#include <AK/Weakable.h>
#include <Kernel/API/KResult.h>
#include <Kernel/Arch/x86/RegisterState.h>
#include <Kernel/Arch/x86/SafeMem.h>
#include <Kernel/Debug.h>
#include <Kernel/FileSystem/InodeIdentifier.h>
#include <Kernel/Forward.h>
#include <Kernel/KResult.h>
#include <Kernel/KString.h>
#include <Kernel/Library/ListedRefCounted.h>
#include <Kernel/Locking/LockLocation.h>

View file

@ -11,9 +11,9 @@
#include <AK/RefPtr.h>
#include <AK/Time.h>
#include <AK/Types.h>
#include <Kernel/API/KResult.h>
#include <Kernel/API/TimePage.h>
#include <Kernel/Arch/x86/RegisterState.h>
#include <Kernel/KResult.h>
#include <Kernel/UnixTypes.h>
namespace Kernel {