1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-17 18:45:08 +00:00
Commit graph

513 commits

Author SHA1 Message Date
Daniel Bertalan
b3ac24a939 LibC: Use a sensible MB_CUR_MAX value
We always use UTF-8, meaning that a single `wchar_t` might be converted
into up to 4 `char`s. This would cause a buffer overflow if something
actually relied on this being the right value.
2021-10-23 23:31:43 -07:00
Daniel Bertalan
ba975f4ba4 LibC: Define locale categories (LC_*) as macros
The C standard states that these symbols should be declared as macros,
not as emum variants as we were doing previously. This is used in some
ports (e.g. bash) to conditionally compile locale-dependent
functionality.

We now use the same trick here as with the errno constants. We keep the
enum, but also create macros that defer to the enum variants.
2021-10-23 23:31:43 -07:00
Jean-Baptiste Boric
68c457b601 LibC: Add definition for FOPEN_MAX 2021-10-23 15:06:33 +02:00
Tim Schumacher
79bcfa967b LibC: Fix up mblen 2021-10-22 13:28:56 -07:00
Tim Schumacher
8df6955838 LibC: Fix up mbtowc
One more proper implementation and one less FIXME.
2021-10-22 13:28:56 -07:00
Tim Schumacher
89afd4d063 LibC: Implement mbsnrtowcs 2021-10-21 23:57:32 -07:00
Tim Schumacher
552ae77f0d LibC: Implement wcsnrtombs 2021-10-21 23:57:32 -07:00
Tim Schumacher
e618602433 LibC: Implement mbrlen 2021-10-21 23:47:20 -07:00
Ben Wiederhake
f53b80e04f LibC: Add missing header in search.h 2021-10-20 09:20:18 +01:00
L Pereira
f4ea3b0168 LibC: Define ULLONG_MAX
Some ports require this constant to be defined as it is specified in
the standard[1].

[1] https://www.cplusplus.com/reference/climits/
2021-10-17 23:43:43 +01:00
Daniel Bertalan
a8fefd89cd Everywhere: Make some symbols __attribute__((used)) for LTO
With these changes, the userland builds correctly with Clang's ThinLTO
enabled.
2021-10-17 17:09:58 +01:00
Daniel Bertalan
95c32fdf19 LibC: Primitively implement wcsxfrm
The `wcsxfrm` function copies a wide character string into a buffer,
such that comparing the new string against any similarly pre-processed
string with `wcscmp` produces the same result as if the original strings
were compared with `wcscoll`.

Our current `wcscoll` implementation is simply an alias for `wcscmp`, so
`wcsxfrm` needs to perform no actions other than copying the string.
2021-10-17 17:09:58 +01:00
Daniel Bertalan
13e6d9d71a LibC: Implement wcslcpy 2021-10-17 17:09:58 +01:00
Daniel Bertalan
e6164d35fa LibC: Fix wcsrchr declaration to return a non-const wchar*
This is how the standard specifies it; similarly to the already
correctly declared wcschr function.
2021-10-17 17:09:58 +01:00
Daniel Bertalan
763a69d46d LibC: Stub out mbsnrtowcs 2021-10-17 17:09:58 +01:00
Daniel Bertalan
54eee525e6 LibC: Stub out wcsnrtombs 2021-10-17 17:09:58 +01:00
Daniel Bertalan
57f0c12b9a LibC: Implement wmemcmp 2021-10-17 17:09:58 +01:00
Daniel Bertalan
685045176b LibC: Add ELAST errno macro
The ELAST macro is used on many systems to refer to the largest possible
valid errno value. LLVM's libc++ uses errno values of ELAST+1 and
ELAST+2 internally, and defines an arbitrary fallback value for
platforms which don't have the macro. This means that it's possible for
their internal errno numbers could coincide with values we actually use,
which would be a very bad thing.
2021-10-17 17:09:58 +01:00
Daniel Bertalan
b5fcb10493 LibC: Forward-declare struct tm in wchar.h
The C standard specifies that this forward-declaration be present in
wchar.h, and is needed in order to build libstdc++.
2021-10-17 17:09:58 +01:00
Tim Schumacher
3336c382fb LibC: Implement wctob 2021-10-17 12:40:48 +01:00
Tim Schumacher
e58e50997c LibC: Implement mbstowcs 2021-10-17 12:40:48 +01:00
Tim Schumacher
4893e3ef47 LibC: Implement wctomb 2021-10-17 12:40:48 +01:00
Tim Schumacher
420bdccf0b LibC: Implement mbsrtowcs 2021-10-15 21:50:19 -07:00
Tim Schumacher
b0babd062e LibC: Implement wcsrtombs 2021-10-15 21:50:19 -07:00
Daniel Bertalan
c8367df746 LibC: Implement wcrtomb
This function converts a single wide character into its multibyte
representation (UTF-8 in our case). It is called from libc++'s
`std::basic_ostream<wchar_t>::flush`, which gets called at program exit
from a global destructor in order to flush `std::wcout`.
2021-10-15 21:50:19 -07:00
Tim Schumacher
9c29e6cde7 LibC: Partially implement wcwidth 2021-10-15 21:50:19 -07:00
Tim Schumacher
a66c358c52 LibC: Stub out tdelete 2021-10-15 21:50:19 -07:00
Tim Schumacher
4b423a5ec7 LibC: Implement twalk 2021-10-15 21:50:19 -07:00
Tim Schumacher
7448626bae LibC: Implement tfind and tsearch 2021-10-15 21:50:19 -07:00
Tim Schumacher
20fc93410c LibC: Mark termcap symbols as weak
Otherwise, we may end up preferring those over the more accurate
implementation in ncurses (if available).
2021-10-15 14:47:41 -07:00
Rodrigo Tobar
8ac1e6e73b LibC: Use the new pread syscall to implement pread
This new implementation of pread saves two lseek system calls and is
thread-safe thanks to it simply forwarding the call to the pread system
call.
2021-10-13 16:10:50 +02:00
David Isaksson
b2e57f555b Kernel: Add ioctl request for getting a storage device's block size 2021-10-09 12:06:47 +02:00
David Isaksson
3b089032f4 Kernel: Add STORAGE_DEVICE_GET_SIZE ioctl request
This ioctl request makes it possible to get the size of a storage device
that has not yet been mounted.
2021-10-09 12:06:47 +02:00
Ben Wiederhake
f9a4f4f7e6 LibC: Fix redeclaration in x86_64/regs.h
In QtCreator (and under weird configurations with gcc), this used to
fail with the error messages like: "error: member of anonymous union
redeclares '___'".

This patch gives each member a unique name.
2021-10-06 23:52:40 +01:00
Ben Wiederhake
8ba572d650 LibC: Make sure ARCH macro is available before use 2021-10-06 23:52:40 +01:00
Tim Schumacher
7af7fc8c16 Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
Tim Schumacher
4ef3ed4ba3 LibC: Implement mbrtowc closer to POSIX 2021-10-03 11:13:50 +00:00
Tim Schumacher
212f9308d4 LibC: Specifically clear only stored bytes after successful mbrtowc 2021-10-03 11:13:50 +00:00
Tim Schumacher
06f30943ef LibC: Manually count stored bytes in mbstate_t
This is probably a bit faster than constantly having to look through all
stored bytes. It also helps when we are trying to store actual null
bytes.
2021-10-03 11:13:50 +00:00
Tim Schumacher
3c807402b3 LibC: Remove the mbstate_reset helper
A zero-initialized mbstate_t struct has to be a valid initial state, so
we can just zero-initialize it whenever we need to reset.

Having a helper function for resetting the struct might imply that you
can add additional setup operations afterwards, which is not the case.
2021-10-03 11:13:50 +00:00
Tim Schumacher
c3b14588ec LibC: Stub out swprintf 2021-10-03 05:28:51 +00:00
Tim Schumacher
e82dc7c77a LibC: Stub out wcstold 2021-10-03 05:28:51 +00:00
Tim Schumacher
893d9e8741 LibC: Stub out wcstod 2021-10-03 05:28:51 +00:00
Tim Schumacher
e0548692ac LibC: Stub out wcstof 2021-10-03 05:28:51 +00:00
Tim Schumacher
783ddd261d LibC: Stub out wcstoull 2021-10-03 05:28:51 +00:00
Tim Schumacher
a65f52d8de LibC: Stub out wcstoul 2021-10-03 05:28:51 +00:00
Tim Schumacher
05b283f552 LibC: Implement wmemmove 2021-10-03 05:28:51 +00:00
Tim Schumacher
fa1208edfd LibC: Implement wmemset 2021-10-03 05:28:51 +00:00
Tim Schumacher
485c0ef691 LibC: Implement wmemcpy 2021-10-03 05:28:51 +00:00
Tim Schumacher
0ca1df4dc6 LibC: Implement wmemchr 2021-10-03 05:28:51 +00:00