summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC/string.cpp
AgeCommit message (Collapse)Author
2022-05-01LibC: Implement a faster memset routine for x86-64 in assemblyDaniel Bertalan
This commit addresses the following shortcomings of our current, simple and elegant memset function: - REP STOSB/STOSQ has considerable startup overhead, it's impractical to use for smaller sizes. - Up until very recently, AMD CPUs didn't have support for "Enhanced REP MOVSB/STOSB", so it performed pretty poorly on them. With this commit applied, I could measure a ~5% decrease in `test-js`'s runtime when I used qemu's TCG backend. The implementation is based on the following article from Microsoft: https://msrc-blog.microsoft.com/2021/01/11/building-faster-amd64-memset-routines Two versions of the routine are implemented: one that uses the ERMS extension mentioned above, and one that performs plain SSE stores. The version appropriate for the CPU is selected at load time using an IFUNC.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-13LibC: Expose AK::timing_safe_compare via `timingsafe_memcmp(..)`Brian Gianforcaro
Ports / other userland often needs such an implementation to function. Lets expose `AK::timing_safe_compare` under the same name used used in OpenBSD / FreeBSD / Solaris and other projects.
2022-03-08LibC: Set `saved_str` to null in strtok_r if no tokens were foundDaniel Bertalan
If we do not do this, the next call to strtok_r will start tokenizing (and possibly modifying!) the memory pointed to by `saved_ptr`.
2022-01-10LibC: Implement strsep()Linus Groh
2021-12-28LibC: Add rindex() and index() APIsBrian Gianforcaro
These POSIX APIs are defined as mapping directly to `strrchr` and `strchr` respectively. These are needed for the latest version of the stress-ng port, and also give us better POSIX compliance.
2021-12-21LibC: Add POSIX spec comments for string APIsBrian Gianforcaro
2021-12-16Kernel+LibC: Move errno definitions to Kernel/API/POSIXsin-ack
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-05LibC: Add a couple of missing errno codesIdan Horowitz
These are required to compile a port.
2021-11-28LibC: Add definition for ENOTRECOVERABLEDaniel Bertalan
This is used by the LLVM port.
2021-09-13LibC: Upgrade memmove() to memcpy() when possibleAndreas Kling
We were missing out on opportunities to use memcpy() instead of memmove() when the source and destination don't overlap.
2021-09-13LibC: Implement explicit_bzero with AK::secure_zeroBrian Gianforcaro
2021-06-28LibC: Implement memcpy and memset for x86_64Gunnar Beutner
2021-06-11Libc: Silence debug spam from `strerror`Jelle Raaijmakers
Particularly noticeable in ports like openssl, which like to map the entire error message set from 0 through 128 on startup.
2021-06-11LibC: Let `strerror_r` fail if `errnum` < 0Jelle Raaijmakers
2021-05-25LibC: Implement strerror_r()Gunnar Beutner
This implements the XSI-compliant version of strerror_r() - as opposed to the GNU-specific variant. The function explicitly saves errno so as to not accidentally change it with one of the calls to other functions.
2021-05-08LibC: Add definition for EDQUOTGunnar Beutner
This is used by the libphysfs port.
2021-05-01LibC: Make EWOULDBLOCK an alias for EAGAINGunnar Beutner
According to POSIX.1 all error codes have to be distinct - with the exception for EAGAIN and EWOULDBLOCK. Other libcs including eglibc and newlib define EWOULDBLOCK as an alias for EAGAIN and some software including OpenTTD expect this behavior.
2021-04-29iLibC: Fix some missed camelCase => snake_caseAndreas Kling
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-12LibC: Use dbgln() in strerror() and strsignal()Gunnar Beutner
Printing error messages to stdout can have unintended side effects depending on what the program is doing.
2021-04-08Kernel/LibC: Make memset implementations the sameHendiadyoin1
I dont know why we do a fast path in the Kernel, but not in Userspace Also simplified the byte explosion in memset to "explode_byte" it even seemed so, that we missed the highest byte when memseting something
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling