summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2019-10-01AK: Remove empty files JsonArray.cpp and JsonObject.cppAndreas Kling
2019-09-30ByteBuffer: Remove pointer() in favor of data()Andreas Kling
We had two ways to get the data inside a ByteBuffer. That was silly.
2019-09-29AK: Add StringBuilder::length() and trim(int)Andreas Kling
Sometimes you want to trim a byte or two off the end.
2019-09-28AK: Add StringBuilder::string_view() and StringBuilder::clear()Sergey Bugaev
The former allows you to inspect the string while it's being built. It's an explicit method rather than `operator StringView()` because you must remember you can only look at it in between modifications; appending to the StringBuilder invalidates the StringView. The latter lets you clear the state of a StringBuilder explicitly, to start from an empty string again.
2019-09-28AK: Add a keep_empty argument to String[View]::substring{_view}Sergey Bugaev
2019-09-27Kernel: Make Region single-owner instead of ref-countedAndreas Kling
This simplifies the ownership model and makes Region easier to reason about. Userspace Regions are now primarily kept by Process::m_regions. Kernel Regions are kept in various OwnPtr<Regions>'s. Regions now only ever get unmapped when they are destroyed.
2019-09-27ELF: Make code a little more buildable on other platformsAndreas Kling
Patch from Anonymous.
2019-09-22AK: Add AK_MAKE_NONMOVABLEAndreas Kling
2019-09-16Kernel: Move kmalloc() into a Kernel/Heap/ directoryAndreas Kling
2019-09-15Utf8View: Don't print potentially unterminated string in debug messageAndreas Kling
2019-09-13Revert "AK: Made Strings reversible"Andreas Kling
This reverts commit 26e81ad574d463faee19f5973108f80d0e02aaf6. We forgot to consider UTF-8 here. String is UTF-8 and we need to be careful about things like this.
2019-09-13AK: Made Strings reversibleJesse Buhagiar
`AK::String` can now be reversed via AK::String::reverse(). This makes life a lot easier for functions like `itoa()`, where the output ends up being backwards. Very much not like the normal STL (which requires an `std::reverse` object) way of doing things. A call to reverse returns a new `AK::String` so as to not upset any of the possible references to the same `StringImpl` shared between Strings.
2019-09-13TestStringView: Add test for starts_withMinusGix
2019-09-13StringView: Add starts_with methodMinusGix
2019-09-11printf: %w, %b, and %p should be zero-padded but not left-paddedAndreas Kling
This fixes the goofy issue with %p coming out as " 0x123" instead of "0x00000123".
2019-09-11AK: Add LogStream operator<< for ByteBufferAndreas Kling
2019-09-11AK: Add String::number(size_t) overloadAndreas Kling
2019-09-08AK: Fix buffer overrun in Utf8CodepointIterator::operator++Sergey Bugaev
The old implementation tried to move forward as long as the current byte looks like a UTF-8 character continuation byte (has its two most significant bits set to 10). This is correct as long as we assume the string is actually valid UTF-8, which we do (we also have a separate method that can check whether it is the case). We can't, however, assume that the data after the end of our string is also valid UTF-8 (in fact, we're not even allowed to look at data outside out string, but it happens to a valid memory region most of the time). If the byte after the end of our string also has its most significant bits set to 10, we would move one byte forward, and then fail the m_length > 0 assertion. One way to fix this would be to add a length check inside the loop condition. The other one, implemented in this commit, is to reimplement the whole function in terms of decode_first_byte(), which gives us the length as encoded in the first byte. This also brings it more in line with the other functions around it that do UTF-8 decoding.
2019-09-08AK: Pad %b and %w to two and four places in printfConrad Pankoff
2019-09-07Kernel: Support thread-local storageAndreas Kling
This patch adds support for TLS according to the x86 System V ABI. Each thread gets a thread-specific memory region, and the GS segment register always points _to a pointer_ to the thread-specific memory. In other words, to access thread-local variables, userspace programs start by dereferencing the pointer at [gs:0]. The Process keeps a master copy of the TLS segment that new threads should use, and when a new thread is created, they get a copy of it. It's basically whatever the PT_TLS program header in the ELF says.
2019-09-07AK: Add a useful align_up_to(value, power_of_two) functionAndreas Kling
2019-09-06AK: When printf assert on unsupported specifier, specify which one!Andreas Kling
We were asserting without saying why. That's a bit unhelpful. :^)
2019-09-06AK: Rename <AK/AKString.h> to <AK/String.h>Andreas Kling
This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
2019-09-05Utf8View: Try fixing the travis-ci buildAndreas Kling
There's some overload ambiguity when doing Utf8View("literal")
2019-09-05AK: Log UTF-8 validation errorsSergey Bugaev
2019-09-05AK: Add some more utility methods to Utf8ViewSergey Bugaev
2019-09-04Json: Add serializer fast-path for string valuesAndreas Kling
Passing these through the generic JsonValue path was causing us to instantiate temporary JsonValues that incurred a heap allocation. This avoids that by adding specialized overloads for string types.
2019-09-03AK: Fix printf %x padding and %p lengthConrad Pankoff
2019-09-02AK: Abort on unknown printf formatting charactersConrad Pankoff
Right now if we encounter an unknown character, printf (and its related functions) fail in a really bad way, where they forget to pull things off the stack. This usually leads to a crash somewhere else, which is hard to debug. This patch makes printf abort as soon as it encounters a formatting character that it can't handle. This is not the optimal solution, but it is an improvement for debugging.
2019-09-02AK: Support %i as an alias for %d in printfConrad Pankoff
2019-08-29Kernel/AK: Add is_zero helpers for IP and MAC addressesConrad Pankoff
2019-08-28AK: Add a Utf8View type for iterating over UTF-8 codepointsSergey Bugaev
Utf8View wraps a StringView and implements begin() and end() that return a Utf8CodepointIterator, which parses UTF-8-encoded Unicode codepoints and returns them as 32-bit integers. This is the first step towards supporting emojis in Serenity ^) https://github.com/SerenityOS/serenity/issues/490
2019-08-28AK: Make printf %x actually work properlyConrad Pankoff
When printing hex numbers, we were printing the wrong thing sometimes. This was because we were dividing the digit to print by 15 instead of 16. Also, dividing by 16 is the same as shifting four bits to the right, which is a bit closer to our actual intention in this case, so let's use a shift instead.
2019-08-27JSON: Port JsonArray and JsonObject serialization to serializersSergey Bugaev
This way, primitive JsonValue serialization is still handled by JsonValue::serialize(), but JsonArray and JsonObject serialization always goes through serializer classes. This is no less efficient if you have the whole JSON in memory already.
2019-08-27JSON: Add JSON serializersSergey Bugaev
These are two new types that allow serializing JSON on-the-fly as it's generated, without building the whole JSON in memory first.
2019-08-26Kernel: Display virtual addresses as V%p instead of L%xAndreas Kling
The L was a leftover from when these were called linear addresses.
2019-08-25AK: Make HashTable.h compile inside the SDL2 portAndreas Kling
2019-08-25AK: Add StringView::hash()Andreas Kling
This grabs the hash from the underlying StringImpl if there is one, otherwise it's computed on the fly.
2019-08-25AK: Add HashMap::find() with customizable finder callbackAndreas Kling
This will allow clients to search the map without having to instantiate a key value.
2019-08-25AK: Add String::operator==(StringView)Andreas Kling
Comparing a String to a StringView would instantiate a temporary String just for the comparison. Let's not do that. :^)
2019-08-25AK: Optional::operator bool() should consume the OptionalAndreas Kling
We use consumable annotations to catch bugs where you get the .value() of an Optional before verifying that it's okay. The bug here was that only has_value() would set the consumed state, even though operator bool() does the same job.
2019-08-23AK: Make FileSystemPath better at handling relative pathsAndreas Kling
Relative paths now canonicalize into a string starting with "./" Previously, "foo" would be canonicalized as "/foo" which was clearly not right.
2019-08-19NonnullPtrVector: Add ptr_at() getters for accessing the NonnullPtrAndreas Kling
Normally you want to access the T&, but sometimes you need to grab at the NonnullPtr, for example when moving it out of the Vector before a call to remove(). This is generally a weird pattern, but I don't have a better solution at the moment.
2019-08-18AK: The printf family was mixing up case and alternate form settingsAndreas Kling
2019-08-17IntrusiveList: Make Iterator::operator* return a T&Andreas Kling
This makes iteration a little more pleasant :^)
2019-08-15LogStream: Prefix userspace dbg() output with "ProcessName(PID): "Andreas Kling
Using the new get_process_name() syscall, we can automatically prefix all userspace debug logging. Hopefully this is more helpful than annoying. We'll find out! :^)
2019-08-15AK: Add a simple TriState typeAndreas Kling
enum class TriState : u8 { False, True, Unknown };
2019-08-15StringView: Add StringView::operator==(StringView)Andreas Kling
Previously we'd implicitly convert the second StringView to a String when comparing two StringViews, which is obviously not what we wanted.
2019-08-14AK: Use int_hash() to generate less idiotic hashes for {Nonnull,}OwnPtrAndreas Kling
2019-08-14JsonParser: "" is an empty string, not a null valueAndreas Kling