summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2021-07-16AK+Kernel: Implement and use EnumBits has_any_flag()Timothy
This duplicates the old functionality of has_flag and will return true when any flags present in the mask are also in the value.
2021-07-16AK: Change EnumBits has_flag() to check all flags in mask are presentTimothy
Co-authored-by: Brian Gianforcaro <b.gianfo@gmail.com>
2021-07-15AK: Add workaround for clang-format 12 problems with conceptsDaniel Bertalan
2021-07-15AK: Allow getting the key from a RedBlackTree iteratorAndreas Kling
2021-07-15AK: Make RedBlackTree non-copyable and non-movableAndreas Kling
2021-07-15AK: Make JsonParser correctly parse unsigned values larger than u32Ali Mohammad Pur
Prior to this, it'd try to stuff them into an i64, which could fail and give us nothing. Even though this is an extension we've made to JSON, the parser should be able to correctly round-trip from whatever our serialiser has generated.
2021-07-15AK: Expose RedBlackTree allocation failures via try_insertIdan Horowitz
This should help with using the RedBlackTree in a more OOM-safe way in the kernel.
2021-07-14AK: Add free function to wrap around __atomic_is_lock_free built-inTimothy Flynn
Note: this exact implementation is needed for __atomic_is_lock_free to link with both GCC (for the SerenityOS build) and Clang (for the Fuzzer build). The size argument must be a compile-time constant, otherwise it fails to link with both compilers. Alternatively, the following definition links with GCC but fails with Clang: template<size_t S> static inline bool atomic_is_lock_free(volatile void* ptr = nullptr) { return __atomic_is_lock_free(S, ptr); }
2021-07-14AK: Avoid pagefaults when repeatedly enqueing/dequeing items in a QueueGunnar Beutner
When repeatedly enqueing and dequeing a single item in a Queue we end up faulting in all the pages for the underlying Vector. This is a performance issue - especially where the element type is large.
2021-07-14AK: Avoid allocations for the Queue classGunnar Beutner
Previously the Queue class used a SinglyLinkedList to manage its queue segments. This changes the Queue class to use the IntrusiveList class instead which saves us one allocation per segment.
2021-07-14AK: Generalize ByteReaderHendiadyoin1
Also use it instead of CPU.h's possibly_unaligned_data interface
2021-07-13AK: Make Bitmap::set() non-constAndreas Kling
2021-07-13AK: Add Formatter for Vectorkleines Filmröllchen
For debugging purposes, it is very useful to look at a Vector in a simple list representation. Therefore, the new Formatter for Vector provides a string representation of the following form: ``` [ 1, 2, 3, 4, 5 ] ``` This requires the content type of Vector to be formattable with default arguments. The current implementation ignores width and precision, which may be accounted for later or passed down to the content formatter.
2021-07-13HashMap: Rename finders with a more accurate and self-descripting namengc6302h
2021-07-13HashTable: Rename finders with a more accurate and self-descripting namengc6302h
2021-07-13Vector: Homogenize type and parameter names for predicatesngc6302h
2021-07-12AK: Make Traits<T*> use ptr_hash() and not assume 32-bit pointersAli Mohammad Pur
As a nice bonus, it also simplifies the code quite a bit.
2021-07-12AK: Replace all explicit specialisations of Traits with a single oneAli Mohammad Pur
This commit un-confuses the many specialisations of AK::Traits, and makes it work correctly for all integral types. Prior to this, `AK::Traits<size_t>` would've been instantiating the base Traits implementation, not `Traits<u32>` or `Traits<u64>`.
2021-07-12AK: Add a DateTimeLexerIdan Horowitz
This is an AK::GenericLexer that exposes helper methods for parsing date and time related literals (years, months, days, hours, minutes, seconds, fractional seconds & more)
2021-07-12AK: Add a retreat(count) method to GenericLexerIdan Horowitz
This method can be used to rewind a constant amount backwards in the source instead of one by one with retract()
2021-07-12AK: Add load64 and load_pointer to AK::ByteReaderAndrew Kaster
This lets us load misaligned 64 bit integers, and misaligned pointers in a platform agnostic way.
2021-07-12AK+Meta: Remove unused AUTOCOMPLETE_DEBUG flagAndrew Kaster
2021-07-11AK: Add FixedArray::span()Andreas Kling
2021-07-11AK: Bring back FixedArray<T>Andreas Kling
Let's bring this class back, but without the confusing resize() API. A FixedArray<T> is simply a fixed-size array of T. The size is provided at run-time, unlike Array<T> where the size is provided at compile-time.
2021-07-11AK: Don't forget to kfree_sized() in ByteBufferAndreas Kling
2021-07-11Kernel: Remove krealloc()Andreas Kling
This was only used by a single class (AK::ByteBuffer) in the kernel and not in an OOM-safe way. Now that ByteBuffer no longer uses it, there's no need for the kernel heap to burden itself with supporting this.
2021-07-11AK: Don't use realloc() in AK::ByteBufferAndreas Kling
This class is the only reason we have to support krealloc() in the kernel heap, something which adds a lot of complexity. Let's move towards a simpler path and do malloc+memset in the ByteBuffer code (where we know the sizes anyway.)
2021-07-11AK: Use kfree_sized() in AK::VectorAndreas Kling
2021-07-11AK: Use kfree_sized() in AK::StringImplAndreas Kling
2021-07-11AK: Use kfree_sized() in AK::HashTableAndreas Kling
2021-07-11AK: Use kfree_sized() in AK::ByteBufferAndreas Kling
2021-07-11AK: Use kfree_sized() in AK::BitmapAndreas Kling
2021-07-11AK: Make kfree_sized() forward to kfree() in non-kernel code for nowAndreas Kling
2021-07-10AK: Remove unused NO_RETURN macroGunnar Beutner
2021-07-08LibSQL+SQLServer: Build SQLServer system serviceJan de Visser
This patch introduces the SQLServer system server. This service is supposed to be the only process/application talking to database storage. This makes things like locking and caching more reliable, easier to implement, and more efficient. In LibSQL we added a client component that does the ugly IPC nitty- gritty for you. All that's needed is setting a number of event handler lambdas and you can connect to databases and execute statements on them. Applications that wish to use this SQLClient class obviously need to link LibSQL and LibIPC.
2021-07-08AK: Fix `UFixedBigInt` not building with ClangDaniel Bertalan
Clang does not like that we are trying to refer to our own size while our declaration is not yet complete, and fails to compile this file. This is fixed by introducing a function which returns the correct sizeof. This only gets evaluated in the `requires` clause after the whole class has been parsed, so it will compile fine.
2021-07-08Everywhere: Use the correct literal suffixesDaniel Bertalan
When performing arithmetic with long doubles/floats, we want to avoid floating point promotion and narrowing.
2021-07-08AK+Userland: Add generic `AK::abs()` function and use itDaniel Bertalan
Previously, in LibGFX's `Point` class, calculated distances were passed to the integer `abs` function, even if the stored type was a float. This caused the value to unexpectedly be truncated. Luckily, this API was not used with floating point types, but that can change in the future, so why not fix it now :^) Since we are in C++, we can use function overloading to make things easy, and to automatically use the right version. This is even better than the LibC/LibM functions, as using a bit of hackery, they are able to be constant-evaluated. They use compiler intrinsics, so they do not depend on external code and the compiler can emit the most optimized code by default. Since we aren't using the C++ standard library's trick of importing everything into the `AK` namespace, this `abs` function cannot be exported to the global namespace, as the names would clash.
2021-07-08AK+Kernel: Fix perfect forwarding constructors shadowing othersDaniel Bertalan
If a non-const lvalue reference is passed to these constructors, the converting constructor will be selected instead of the desired copy/move constructor. Since I needed to touch `KResultOr` anyway, I made the forwarding converting constructor use `forward<U>` instead of `move`. This meant that previously, if a lvalue was passed to it, a move operation took place even if no `move()` was called on it. Member initializers and if-else statements have been changed to match our current coding style.
2021-07-07AK: Replace usages of ctype.h with CharacterTypes.hMax Wipfli
This replaces all remaining usages of ctype.h in AK with CharacterTypes.h.
2021-07-05AK: Declare operators `new` and `delete` as global functionsDaniel Bertalan
This fixes a build issue introduced in 23d66fe, where the compiler statically detected that that mismatching new and delete operators were used. Clang generates a warning for this, for the reasons described in the comment in `AK/kmalloc.cpp`, but GCC does not. Besides moving the allocator functions into a `.cpp` file, declarations in `AK/kmalloc.cpp` were reordered to have imports at the top, in order to make the code more readable.
2021-07-05Kernel: Replace raw asm functions with naked onesHendiadyoin1
2021-07-05JsonParser: Bring parser more to specstelar7
2021-07-05Kernel: Merge the x86 and x86_64 boot code into a single fileGunnar Beutner
They're mostly the same apart from some x86_64-specific parts.
2021-07-04Meta: Remove the LibJS OBJECT_DEBUG debug macroLinus Groh
I didn't add any debug logging to the object rewrite, so this is now unused. It's much more correct though, so we can get away with adding ad-hoc logging, should that ever be necessary :^) Side note: this should have a prefix, i.e. JS_OBJECT_DEBUG. The previous name is too generic.
2021-07-04AK: Add generation of roman numerals to AK::StringTobias Christiansen
We now can generate roman numbers using String::roman_number_from() similar to String::bijective_base_from().
2021-07-04AK: Explicitly require Checked types to be IntegralIdan Horowitz
These were already implicitly required to be integral via the usage of the is_within_range templated function, but making them explicit should produce nicer error messages when building, and make the IDE highlight the incorrect usage.
2021-07-04AK+LibIPC: Make all enums codableTimothy
If an enum has a supported underlying type we can provide encoding and decoding for the enum as well.
2021-07-04AK: Destroy original value when assigning to VariantDaniel Bertalan
2021-07-04AK: Use conditionally trivial special member functionsDaniel Bertalan
This commit makes use of the conditionally trivial special member functions introduced in C++20. Basically, `Optional` and `Variant` inherits whether its wrapped type is trivially copy constructible, trivially copy assignable or trivially destructible. This lets the compiler optimize optimize a large number of their use cases. The constraints have been applied to `Optional`'s converting constructors too in order to make the API more explicit. This feature is not supported by Clang yet, so we use conditional compilation so that Lagom can be built on macOS. Once Clang has P0848R3 support, these can be removed.