Commit graph

2289 commits

Author SHA1 Message Date
Brian Gianforcaro 48206be121 AK: Use MUST + try_empend so AK::Trie continues to compile in the kernel 2022-01-05 14:04:18 +01:00
Brian Gianforcaro 7d27798c8d AK: Use unchecked_append in AK::Stack, as we always validate the size
This removes one additional usage of Vector::append that stops us from
disabling it when compiling the Kernel.
2022-01-05 14:04:18 +01:00
Jelle Raaijmakers 8da0925d6d AK: Add mix 2022-01-04 17:48:28 +00:00
B0IIZZ 6124050187 AK: Fix UFixedBigInt comparison operators
Instead of using the specified type U like we want,
we were using the type T all along when comparing with
smaller integers. This is now fixed.
2022-01-04 06:01:22 +00:00
James Puleo 5b164e9934 AK: Include utility from the STD if we aren't replacing STD
If we didn't define our own `move` and `forward` and inject it into the
`std` namespace, then we would error just after trying to `using` those,
if no one has included it before. Now, we will include `utility` from
the STD if we aren't replacing the `std`.
2022-01-02 12:05:12 +01:00
Daniel Bertalan 1d2f78682b Kernel+AK: Eliminate a couple of temporary String allocations 2021-12-30 14:16:03 +01:00
Andreas Kling ac7ce12123 Kernel: Remove the kmalloc_eternal heap :^)
This was a premature optimization from the early days of SerenityOS.
The eternal heap was a simple bump pointer allocator over a static
byte array. My original idea was to avoid heap fragmentation and improve
data locality, but both ideas were rooted in cargo culting, not data.

We would reserve 4 MiB at boot and only ended up using ~256 KiB, wasting
the rest.

This patch replaces all kmalloc_eternal() usage by regular kmalloc().
2021-12-28 21:02:38 +01:00
Andreas Kling 1c2aa7396d AK: Don't include AK::demangle() in KERNEL builds
This was not used anywhere in the kernel anyway.
2021-12-26 21:22:59 +01:00
Andreas Kling 8a51f64503 AK: Increase StringBuilder's inline buffer size from 128 to 256 bytes 2021-12-26 01:42:58 +01:00
Ali Mohammad Pur 986d63466e AK: Remove Variant<Ts...>::operator Variant<NewTs...>()
This is an interface to downcast(), which degrades errors into runtime
errors, and allows seemingly-correct-but-not-quite constructs like the
following to appear to compile, but fail at runtime:

    Variant<NonnullRefPtr<T>, U> foo = ...;
    Variant<RefPtr<T>, U> bar = foo;

The expectation here is that `foo` is converted to a RefPtr<T> if it
contains one, and remains a U otherwise, but in reality, the
NonnullRefPtr<T> variant is simply dropped on the floor, and the
resulting variant becomes invalid, failing the assertion in downcast().

This commit adds a Variant<Ts...>(Variant<NewTs...>) constructor that
ensures that no alternative can be left out at compiletime, for the
users that were using this interface for merely increasing the number of
alternatives (for instance, LibSQL's Value class).
2021-12-25 18:24:43 +03:30
Daniel Bertalan 2b1864c53a AK: Add missing Array.h include to CheckedFormatString.h
GCC 12 complains that iota_array is used before it's declared. GCC 11
works fine without it though.
2021-12-24 14:35:33 -08:00
Michel Hermier 4758dac218 AK: Make Disjoint*::is_empty() not call size
This is a raffinement of 49cbd4dcca.

Previously, the container was scanned to compute the size in the unhappy
path. Now, using `all_of` happy and unhappy path should be fast.
2021-12-24 05:55:34 -08:00
Michel Hermier 3a177b9209 AK: Add DisjointChunkc::ensure_capacity 2021-12-24 05:55:34 -08:00
Nick Johnson 08e4a1a4dc AK+Everywhere: Replace __builtin bit functions
In order to reduce our reliance on __builtin_{ffs, clz, ctz, popcount},
this commit removes all calls to these functions and replaces them with
the equivalent functions in AK/BuiltinWrappers.h.
2021-12-21 22:13:51 +01:00
Xavier Defrang 9e97823ff8 AK: Add convert_to_uint_from_octal 2021-12-21 13:13:04 -08:00
Ali Mohammad Pur 49cbd4dcca AK: Make DisjointChunks not query size() when there are no chunks 2021-12-21 22:10:07 +01:00
Ali Mohammad Pur 2df54a7b56 AK: Add Disjoint(Chunks Spans)::find(index)
For when the may or may not be out of bounds.
2021-12-21 22:10:07 +01:00
Ali Mohammad Pur f0709c7a24 LibC+AK: Implement all sorts of wprintf variants 2021-12-21 21:24:36 +03:30
Andreas Kling 452a5531be AK+LibMain: Improve formatter for AK::Error in userspace
Print the full associated string metadata by default (if available.)
2021-12-20 21:13:42 +01:00
Nick Johnson e122502f70 AK: Speed up BitmapView::find_next_range_of_unset_bits
While watching Andreas' most recent video, I noticed that this function
only worked with 32 bit values, but was a serious performance
bottleneck for the kernel. As such, I reworked it to use `size_t`, so
it now can switch to 64-bit sweeps on 64-bit platforms. This caused
test-js to go from 12.5 seconds hot to 11.5 seconds hot on my machine
when running on KVM x86_64.
2021-12-18 23:36:08 +01:00
Nick Johnson 548529ace4 AK: Add BuiltinWrappers.h
The goal of this file is to enable C++ overloaded functions for
standard builtin functions that we use. It contains fallback
implementations for systems that do not have the builtins available.
2021-12-18 23:36:08 +01:00
kleines Filmröllchen 3891d6d73a AK: Fast path for single-element TypedTransfer::copy
Co-Authored-By: Brian Gianforcaro <bgianf@serenityos.org>
2021-12-17 13:13:00 -08:00
kleines Filmröllchen d5dce448ea AK: Bypass Buffered's buffer for large reads
Before, if we couldn't read enough data out of the buffer, we would re-
fill the buffer and recursively call read(), which in turn reads data
from the buffer into the resliced target span. This incurs very
intensive superflous memmove's when large chunks of data are read from
a buffered stream.

This commit changes the behavior so that when we exhaust the buffer, we
first read any necessary additional data directly into the target, then
fill up the buffer again. Effectively, this results in drastically
reduced overhead from Buffered when reading large contiguous chunks.
Of course, Buffered is designed to speed up data access patterns with
small frequent reads, but it's nice to be able to combine both access
patterns on one stream without penalties either way.

The final performance gain is about an additional 80% of abench decoding
speed.
2021-12-17 13:13:00 -08:00
Andreas Kling a409b832fa AK: Make JsonValue::from_string("") return a null JsonValue
This unbreaks the /var/run/utmp system which starts out as an empty
string, and is then turned into an object by the first update.

This isn't necessarily the best way for this to work, but it's how
it used to work, so this just fixes the regression for now.
2021-12-16 22:48:17 +01:00
sin-ack 69ef211925 Kernel+LibC: Move errno definitions to Kernel/API/POSIX
This fixes at least half of our LibC includes in the kernel. The source
of truth for errno codes and their description strings now lives in
Kernel/API/POSIX/errno.h as an enumeration, which LibC includes.
2021-12-16 22:21:35 +03:30
sin-ack e4a1bc1542 AK: Use __builtin_memmove for ByteBuffer and Span's overwrite
__builtin_memcpy will fail when the target area and the source area
overlap. Using __builtin_memmove will handle this case as well.
2021-12-16 22:21:35 +03:30
Ben Wiederhake 208d85e707 AK+Tests: Use less space in ErrorOr 2021-12-16 09:32:51 +01:00
Hendiadyoin1 c673b7220a AK: Enable fast path for removal by hash-compatible key in HashMap/Table 2021-12-15 23:35:14 -08:00
Hendiadyoin1 b429f9c7aa AK: Add implied const qualifiers to the Json interface
As specified by clang-tidy.
2021-12-15 23:35:14 -08:00
Hendiadyoin1 b39c4c62d0 AK: Use StringView as key-type when removing a Value from an JsonObject 2021-12-15 23:35:14 -08:00
Hendiadyoin1 e35709cbd2 AK: Return bool in JsonValue::as_bool() 2021-12-15 23:35:14 -08:00
Andrew Kaster db33cdbc2f AK+LibSanitizer: Add method to zero out a UBSAN SourceLocation
This is the same strategy that LLVM's compiler-rt uses to make sure that
each UBSAN error is only reported once, when UBSAN is *not* deadly.

Otherwise, each time we head through a UB codepath, we will log the same
error over and over. That behavior just adds noise to the logs and makes
it nearly impossible to run binaires that have some common code path
with flagged UB in them.

compiler-rt goes the extra step to make sure the "clear" action is
atomic, but we don't really have that many multi-threaded apps gettting
tested with UBSAN yet, so we can add that later.
2021-12-15 10:30:32 -08:00
Hendiadyoin1 422b624743 AK: Convert JsonObject to use StringViews for lookup
Most of the Keys we use are compile-time strings anyway, there is no
need to use the heap to pass them around.
2021-12-15 13:09:49 +03:30
Hendiadyoin1 d50360f5dd AK: Allow hash-compatible key types in Hash[Table|Map] lookup
This will allow us to avoid some potentially expensive type conversion
during lookup, like form String to StringView, which would allocate
memory otherwise.
2021-12-15 13:09:49 +03:30
Hendiadyoin1 c8bee92fb9 AK: Add the concept of hash-compatible types 2021-12-15 13:09:49 +03:30
Hendiadyoin1 92e824afa1 AK: Add a Concept for any String type 2021-12-15 13:09:49 +03:30
Hendiadyoin1 6c6e917cf0 AK: Add dedicated Traits for c-strings 2021-12-15 13:09:49 +03:30
Hendiadyoin1 ceb0e28ea5 AK: Add helper to test for pointer and cv-pointer at the same time 2021-12-15 13:09:49 +03:30
Hendiadyoin1 dfe2cf3a40 AK: Add a Decay helper for Concepts 2021-12-15 13:09:49 +03:30
Martin Blicha c4c8f59284 AK: Fix preprocessor OS check
Instead of checking __linux__ macro directly, the code should check if
this macro is defined. This is already done correctly a couple of lines
above.

I ran into this when trying to build libjs-test262 on MacOS where I got
the following error message
   error: "__linux__" is not defined, evaluates to 0 [-Werror=undef]
2021-12-12 11:10:34 -08:00
Jelle Raaijmakers bc36e39d07 AK: Simplify Array::back() by checking for Size > 0
We do not want `Array::max()` to be used here at all - we know the
size at compile-time, after all.
2021-12-11 23:15:24 +01:00
Andreas Kling c9a35e104b AK: Add RefCountForwarder<T>
This is a convenience template that implements reference count
forwarding. This means that an object forwards ref() and unref() to
another object.

We can use this when two ref-counted objects need to keep each other
alive. This situation poses two problems:

- Using 2x RefPtr would cause a ref cycle and leak both objects.
- Using 2x WeakPtr would allow one of them to be destroyed early.

With RefCountForwarder, only one of the objects has a ref count. The
object with the ref count points to the forwarding object by using a
non-counting smart pointer (OwnPtr or NonnullOwnPtr). Thus, both objects
are kept alive by the same ref count, and they can safely point to each
other without worrying about disjoint lifetimes.
2021-12-09 21:28:52 +01:00
Tim Schumacher 5c511de4cc AK: Zero-pad automatically if formatting with precision 2021-12-07 20:13:59 -08:00
Ben Wiederhake 6f37510a71 AK: Implement missing const getters in AK::Error, fix typo
Note that the return type for the non-const method error() changed. This
is most likely an accident, hidden by the fact that ErrorType typically
is Error.
2021-12-05 22:59:09 +01:00
Ben Wiederhake dbd60f9ff4 AK: Implement Formatter for ErrorOr<>
As the Formatter for Error already exists, this apparently was just
accidentally omitted.
2021-12-05 22:59:09 +01:00
Sam Atkins 5013a6480d AK: Mark smart pointer classes as [[nodiscard]]
This makes it an error to not do something with a returned smart
pointer, which should help prevent mistakes. In cases where you do need
to ignore the value, casting to void will placate the compiler.

I did have to add comments to disable clang-format on a couple of lines,
where it wanted to format the code like this:

```c++
private : NonnullRefPtr() = delete;
```
2021-12-05 15:31:03 +01:00
James Mintram ef52fe7d2f Kernel: Add VALIDATE_IS_X86 macro 2021-12-01 11:22:04 -08:00
Andreas Kling cb9cac4e40 LibIPC+IPCCompiler+AK: Make IPC value decoders return ErrorOr<void>
This allows us to use TRY() in decoding helpers, leading to a nice
reduction in line count.
2021-11-28 23:14:19 +01:00
kleines Filmröllchen 295eec2d49 AK: Stop Vector::extend from unnecessary reallocation
Previously, Vector::extend for a moved vector would move the other
vector into this vector if this vector was empty, thereby throwing away
existing allocated capacity. Therefore, this commit allows the move to
only happen if this vector's capacity is too small to fit the other
vector. This will also alleviate bugs where callers relied on the
capacity to never shrink with calls to unchecked_append, extend and the
like.
2021-11-28 13:33:51 -08:00
kleines Filmröllchen 05cb499d58 AK: Add Vector::unchecked_append for data pointers
This mirrors the existence of append() for data pointers and is very
useful when the program needs to have a guarantee of no allocations,
as is necessary for real-time audio.
2021-11-28 13:33:51 -08:00
kleines Filmröllchen cbb2b4fe71 AK: Expose Buffered's buffer size and underlying stream 2021-11-28 13:33:51 -08:00
Hendiadyoin1 6f74c1bb11 AK: Allow to "get a result" from Result<void>
This is to make Result<void> work inside TRY
2021-11-28 13:33:51 -08:00
Ben Wiederhake b1982267b2 AK: Remove unused static member of Bitmap
This is a remnant of the Bitmap/BitmapView split.
2021-11-28 13:16:41 -08:00
csb6 d55dfe2418 AK: On macOS host builds, wrap unistd.h with missing extern "C"
During the build process on macOS, multiple versions of <unistd.h> were
being included (Apple's version and GCC's version). It appears that
all other places #include the version from GCC, but in Platform.h the
Apple header was being used. GCC's <unistd.h> is wrapped in
`extern "C"`, while Apple's is not. This causes a conflicting
declaration, so we need to wrap the #include with extern "C".

Issue has been observed on macOS Mojave.

See https://github.com/microsoft/vcpkg/issues/11320 for a similar issue.
2021-11-23 18:48:59 +00:00
Andreas Kling 58fb3ebf66 LibCore+AK: Move MappedFile from AK to LibCore
MappedFile is strictly a userspace thing, so it doesn't belong in AK
(which is supposed to be user/kernel agnostic.)
2021-11-23 11:33:36 +01:00
Andreas Kling 4e530135d5 AK+LibSystem+LibMain: Add Error::from_syscall() for syscall failures
This creates an error that contains the name of the syscall that failed.
This allows error handlers to print out the name of the call if they
want to. :^)
2021-11-22 19:28:31 +01:00
Tim Schumacher 07351762c7 AK: Add LexicalPath::prepend() 2021-11-22 09:03:47 +01:00
Andrew Kaster bf33a14081 AK: Mark MemMem header-only functions as inline rather than static
Avoid including a per-translation unit copy of all these functions.

Also, drive-by two clang-tidy fixes for readability-qualified-auto and
readability-implicit-bool-conversion.
2021-11-22 05:23:24 +03:30
James Mintram bcd518a228 Kernel: Wrap format timespec assignment in a check for !AARCH64
Currently TimeManagement wont compile on AARCH64, so it is not included.
This creates a link error since format.cpp now relies on functionality
in TimeManagement.cpp to add timestamps to log lines.

This PR disables that functionality for AARCH64 builds until
TimeManagement will compile.
2021-11-21 09:12:16 +01:00
Andreas Kling 0f22ba5bf2 AK: Make RedBlackTree::try_insert() return ErrorOr<void> instead of bool 2021-11-18 21:11:30 +01:00
Jelle Raaijmakers dfbdd035da AK: Implement acos<T> correctly
This is a naive implementation based on the symmetry with `asin`.

Before, I'm not really sure what we were doing, but it was returning
wildly incorrect results.
2021-11-18 21:10:30 +01:00
Andreas Kling 8fe1c1f788 AK: Add missing return in Formatter<unsigned char[Size]>::format()
Caught by ENABLE_ALL_THE_DEBUG_MACROS.
2021-11-17 07:45:10 +01:00
Andreas Kling 216e21a1fa AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
This isn't a complete conversion to ErrorOr<void>, but a good chunk.
The end goal here is to propagate buffer allocation failures to the
caller, and allow the use of TRY() with formatting functions.
2021-11-17 00:21:13 +01:00
Andreas Kling 008355c222 AK: Add failable try_* functions to StringBuilder
These will allow us to start using TRY() with StringBuilder operations.
2021-11-17 00:21:13 +01:00
Andreas Kling 11aad74dce AK: Forward declare Error and ErrorOr in AK/Forward.h 2021-11-17 00:21:12 +01:00
Andreas Kling 587f9af960 AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
Also add slightly richer parse errors now that we can include a string
literal with returned errors.

This will allow us to use TRY() when working with JSON data.
2021-11-17 00:21:10 +01:00
Hendiadyoin1 6cb42d8a40 AK: Verify that we are not overreaching in StringView's substring_view() 2021-11-16 00:49:48 +00:00
Andrew Kaster f1d8978804 AK+Kernel: Remove implicit conversion from Userspace<T*> to FlatPtr
This feels like it was a refactor transition kind of conversion. The
places that were relying on it can easily be changed to explicitly ask
for the ptr() or a new vaddr() method on Userspace<T*>.

FlatPtr can still implicitly convert to Userspace<T> because the
constructor is not explicit, but there's quite a few more places that
are relying on that conversion.
2021-11-16 00:13:22 +01:00
Andrew Kaster 6f580f2047 AK: Resolve clang-tidy readability-const-return-type warning in Bitmap
Returning a const BitmapView doesn't make much sense :^)
2021-11-14 22:52:35 +01:00
Andrew Kaster f32e185269 AK: Suppress false positive readability-non-const-parameter in Function
In AK::Function::CallableWrapper::init_and_swap(), clang-tidy wants us
to mark the destination argument as pointer to const, which doesn't work
because we use placement new to construct a move'd *this into.
2021-11-14 22:52:35 +01:00
Andrew Kaster 7014d37dd6 AK+Kernel: Suppress clang-tidy warnings from the cert-* category
cert-dcl50-cpp: No variadic functions, suppressed in RefCounted and
ThreadSafeRefCounted for implementing the magic one_ref_left and
will_be_destroyed functions.

cert-dcl58-cpp: No opening ::std, suppressed in the places we put names
in ::std to aid tools (move, forward, nullptr_t, align_val_t, etc).
2021-11-14 22:52:35 +01:00
Andrew Kaster 2b16ee742e AK: Avoid implicit conversion clang-tidy warnings in AK::Time 2021-11-14 22:52:35 +01:00
Andrew Kaster 2c4f7fae1e AK: Move StandardFormatter argument into base class initializer
Subclasses of StandardFormatter don't need to use the formatter argument
in their constructor, so move() it into the base class initializer.
2021-11-14 22:52:35 +01:00
Andrew Kaster 74e8aa73e5 AK: Avoid implicit conversions in TypeErasedParameter::to_size()
Refactor to a visitor+functor pattern that does an explicit static_cast
to size_t after performing suitable range checks for each type.
2021-11-14 22:52:35 +01:00
Andrew Kaster 762b92c650 AK: Resolve clang-tidy readability-qualified-auto warnings
... In files included by Kernel/Process.cpp and Kernel/Thread.cpp
2021-11-14 22:52:35 +01:00
Andrew Kaster 64edf17eb2 AK: Mark StringView::find_any_of() as const 2021-11-14 22:52:35 +01:00
Andrew Kaster 163367da39 AK: Resolve clang-tidy warnings about unusual assignment operators
Either not returning *this, or in the case of Variant, not checking for
self assignment. In AK::Atomic, we can't return *this due to the wrapper
semantics Atomic implements.
2021-11-14 22:52:35 +01:00
Andrew Kaster 22feb9d47b AK: Resolve clang-tidy readability-bool-conversion warnings
... In files included by Kernel/Process.cpp and Kernel/Thread.cpp
2021-11-14 22:52:35 +01:00
Andrew Kaster 10d0cac73c AK: Use capitalized literal suffixes for AK::abs() overloads
Using `l` for long double causes a clang-tidy warning, so use all caps
suffixes for all of the AK::abs() overloads for consistency. Also, avoid
leaking the internal __DEFINE_GENERIC_ABS macro.
2021-11-14 22:52:35 +01:00
Andrew Kaster e982253c33 AK: Avoid else after return in files commonly included by the Kernel 2021-11-14 22:52:35 +01:00
Andrew Kaster 07f4e91b94 AK: Use proper type for bool NumericLimits::min and max specialization
We had these declared as returning char, which looks like a copy paste
error. Found by clang-tidy.
2021-11-14 22:52:35 +01:00
Andrew Kaster 7e2ee2e725 AK: Suppress false-positive clang-tidy warning in Assertions.h
The definition of VERIFY_NOT_REACHED() as `assert(false)` causes the
tool to suggest converting it to a static_assert. Which doesn't make
any sense in context for what the macro is trying to do: crash the
program at runtime.
2021-11-14 22:52:35 +01:00
Andrew Kaster 3eeca784d2 Meta: Add basic clang-tidy configuration
Add a basic clang-tidy configuration that enables checks from the
following categories:

- bugprone
- cert
- clang-analyzer
- concurrency
- misc
- performance
- portability
- readability

The noisiest rules that have conflicts with the project style guide or
accepted practices have been turned off.

There's absolutely more work to be done here before we could consider
setting any of these warnings as errors and enforcing them in CI, but
committing a project clang-tidy configuration should help the rules
become more visible and let other contributors take a crack at tweaking
rules and/or finding possible bugs.

Sadly the cpp-core-guidelines and modernize categories are very, very
noisy. If we want to enable rules from these categories, they would need
to be on a rule by rule basis.
2021-11-14 22:52:35 +01:00
Brian Gianforcaro d1806d44fa AK: Swallow 'L' format specifier until it is properly implemented
Previously if code attempted to use the format specifier somewhere
(Ex: "%#4.3Lg"), the specifier would get dropped and we would just
print "g" instead of any value. Now at least we print a value.
2021-11-14 16:18:45 +00:00
Ali Mohammad Pur 7d1142e2c8 LibWasm: Implement module validation 2021-11-11 09:20:04 +01:00
Hendiadyoin1 f76241914c AK: Allow to clear HashTables/Maps with capacity 2021-11-11 09:19:17 +01:00
Andreas Kling 80d4e830a0 Everywhere: Pass AK::ReadonlyBytes by value 2021-11-11 01:27:46 +01:00
Andreas Kling 8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling 9d1f238450 AK: Make HashTable and HashMap try_* functions return ErrorOr<T>
This allows us to use TRY() and MUST() with them.
2021-11-11 01:27:46 +01:00
Andreas Kling a15ed8743d AK: Make ByteBuffer::try_* functions return ErrorOr<void>
Same as Vector, ByteBuffer now also signals allocation failure by
returning an ENOMEM Error instead of a bool, allowing us to use the
TRY() and MUST() patterns.
2021-11-10 21:58:58 +01:00
Andreas Kling 88b6428c25 AK: Make Vector::try_* functions return ErrorOr<void>
Instead of signalling allocation failure with a bool return value
(false), we now use ErrorOr<void> and return ENOMEM as appropriate.
This allows us to use TRY() and MUST() with Vector. :^)
2021-11-10 21:58:58 +01:00
Andreas Kling cd49f30bea AK+LibJS: Simplify MUST() and move it from LibJS to AK/Try.h
This is generally useful so let's move it to AK. Also it seems that we
don't need the temporary variable hack anymore, so let's lose that.
2021-11-10 21:58:58 +01:00
Andreas Kling 5f7d008791 AK+Everywhere: Stop including Vector.h from StringView.h
Preparation for using Error.h from Vector.h. This required moving some
things out of line.
2021-11-10 21:58:58 +01:00
Ben Wiederhake b7e6118098 AK: Properly declare inheritance of Bitmap from BitmapView
All the read-only methods of Bitmap simply defer to BitmapView. Let's
make this relationship official by using class inheritance. This might
even shave off a few instructions, although any sufficiently optimizing
compiler probably already optimized them away.
2021-11-10 14:39:42 +01:00
Ben Wiederhake bf7a2ff941 AK+Kernel: Make BitmapView read-only 2021-11-10 14:39:42 +01:00
Andreas Kling 79fa9765ca Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace!
This was a slightly tedious refactoring that took a long time, so it's
not unlikely that some bugs crept in.

Nevertheless, it does pass basic functionality testing, and it's just
real nice to finally see the same pattern in all contexts. :^)
2021-11-08 01:10:53 +01:00
Andreas Kling 7ee10c6926 AK: Add some more ways to construct Error and ErrorOr<T>
This is preparation for using Error in the kernel instead of KResult.
2021-11-08 00:36:35 +01:00
Andreas Kling 5e473a63d3 AK: Make Error.h pull in Try.h
Users of this API will want TRY().
2021-11-08 00:36:19 +01:00
Andreas Kling e841f3c283 AK: Add a variant of adopt_nonnull_own_or_enomem() for userspace
This variant returns ErrorOr<NonnullOwnPtr<T>> instead of KResultOr.
Eventually the KResultOr variant should go away once the kernel adopts
Error and ErrorOr<T>.
2021-11-08 00:35:27 +01:00
Andreas Kling 184810a581 AK: Remove now-unused OSError class
This has been superseded by the more generally useful AK::Error :^)
2021-11-08 00:35:27 +01:00