Commit graph

25 commits

Author SHA1 Message Date
Gunnar Beutner
31bd5b1a02 AK+Userland: Stub out code that isn't currently implemented on AARCH64
Even though this almost certainly wouldn't run properly even if we had
a working kernel for AARCH64 this at least lets us build all the
userland binaries.
2022-10-14 13:01:13 +02:00
Undefine
97cc33ca47 Everywhere: Make the codebase more architecture aware 2022-07-27 21:46:42 +00:00
Daniel Bertalan
bcf124c07d LibC: Implement a faster memset routine for x86-64 in assembly
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-05-01 12:42:01 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Brian Gianforcaro
01bd3c5563 LibC: Expose AK::timing_safe_compare via timingsafe_memcmp(..)
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-13 19:08:58 -07:00
Daniel Bertalan
ea52ba9fdc LibC: Set saved_str to null in strtok_r if no tokens were found
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-03-08 23:30:47 +01:00
Linus Groh
471b798eb0 LibC: Implement strsep() 2022-01-10 23:47:30 +01:00
Brian Gianforcaro
fb8df01036 LibC: Add rindex() and index() APIs
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-28 11:00:51 +01:00
Brian Gianforcaro
11a12c2312 LibC: Add POSIX spec comments for string APIs 2021-12-21 18:16:48 -08: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
Idan Horowitz
13dec3cdde LibC: Add a couple of missing errno codes
These are required to compile a port.
2021-12-05 12:53:29 +01:00
Daniel Bertalan
4c0d868bb6 LibC: Add definition for ENOTRECOVERABLE
This is used by the LLVM port.
2021-11-28 09:38:57 -08:00
Andreas Kling
5b19e9239a LibC: Upgrade memmove() to memcpy() when possible
We were missing out on opportunities to use memcpy() instead of
memmove() when the source and destination don't overlap.
2021-09-13 19:11:33 +02:00
Brian Gianforcaro
43f4292ca0 LibC: Implement explicit_bzero with AK::secure_zero 2021-09-13 00:02:42 +02:00
Gunnar Beutner
086b7a4537 LibC: Implement memcpy and memset for x86_64 2021-06-28 22:29:28 +02:00
Jelle Raaijmakers
527dc09542 Libc: Silence debug spam from strerror
Particularly noticeable in ports like openssl, which like to map the
entire error message set from 0 through 128 on startup.
2021-06-11 12:09:58 +02:00
Jelle Raaijmakers
33c3c32a38 LibC: Let strerror_r fail if errnum < 0 2021-06-11 12:09:58 +02:00
Gunnar Beutner
c81b3e1ee3 LibC: Implement strerror_r()
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-25 17:36:02 +02:00
Gunnar Beutner
6afb6eb6a9 LibC: Add definition for EDQUOT
This is used by the libphysfs port.
2021-05-08 18:11:52 +02:00
Gunnar Beutner
a9f488c55b LibC: Make EWOULDBLOCK an alias for EAGAIN
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-05-01 09:02:57 +02:00
Andreas Kling
357a455b5c iLibC: Fix some missed camelCase => snake_case 2021-04-29 10:34:02 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
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-22 11:22:27 +02:00
Gunnar Beutner
0497986572 LibC: Use dbgln() in strerror() and strsignal()
Printing error messages to stdout can have unintended side effects
depending on what the program is doing.
2021-04-12 22:34:07 +02:00
Hendiadyoin1
e8ef10e2a6 Kernel/LibC: Make memset implementations the same
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-04-08 23:57:16 +02:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Renamed from Libraries/LibC/string.cpp (Browse further)