Commit graph

52 commits

Author SHA1 Message Date
Tim Schumacher
aae106e37b LibC: Add most of the "header may make visible" dependencies from POSIX 2023-07-19 00:19:35 -06:00
implicitfield
5dfe2eb389 Everywhere: Resolve conflicts with LibC and libc++
Since https://reviews.llvm.org/D131441, libc++ must be included before
LibC. As clang includes libc++ as one of the system includes, LibC
must be included after those, and the only correct way to do that is
to install LibC's headers into the sysroot.

Targets that don't link with LibC yet require its headers for one
reason or another must add install_libc_headers as a dependency to
ensure that the correct headers have been (re)installed into the
sysroot.

LibC/stddef.h has been dropped since the built-in stddef.h receives
a higher include priority.

In addition, string.h and wchar.h must
define __CORRECT_ISO_CPP_STRING_H_PROTO and
_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS respectively in order to tell
libc++ to not try to define methods implemented by LibC.
2023-06-27 12:40:38 +02:00
Tim Schumacher
6d4d6c3e2a LibC: Implement wcswidth 2022-06-30 11:57:49 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Tim Schumacher
cdca6fc113 LibC: Make wchar size definitions available from stdint.h
POSIX describes WCHAR_MIN and WCHAR_MAX in stdint.h(0P), while
wchar.h(0P) only says "as described in stdint.h".

As there isn't a trivial path of "may make visible", just move it to a
shared header and include it from both files.
2022-03-29 15:19:39 +02:00
Tim Schumacher
aa9d6f17b6 Revert "LibC: Make WEOF a signed value on clang"
We have fixed Clang to define `wint_t` as an unsigned value.

This reverts commit ccb9cae8e9.
2022-03-19 00:11:45 +00:00
Ali Mohammad Pur
ccb9cae8e9 LibC: Make WEOF a signed value on clang
The actual value is unchanged, but the previous `0xffffffff` was an
unsigned value, which lead to clang getting mad at `foowc() == WEOF`.
This commit makes it a signed int on clang, which *should* serve
the same purpose and not lead to clang getting mad at us.
2021-12-21 21:24:36 +03:30
Ali Mohammad Pur
0fdf52f6dd LibC: Define WCHAR_{MIN,MAX} 2021-12-21 21:24:36 +03:30
Ali Mohammad Pur
687a3351c2 LibC: Stub out wcsftime() 2021-12-21 21:24:36 +03:30
Ali Mohammad Pur
e717ca32d1 LibC: Implement ungetwc() 2021-12-21 21:24:36 +03:30
Ali Mohammad Pur
14b91a3fe9 LibC: Stub out some wscanf variants 2021-12-21 21:24:36 +03:30
Ali Mohammad Pur
f0709c7a24 LibC+AK: Implement all sorts of wprintf variants 2021-12-21 21:24:36 +03:30
Ali Mohammad Pur
db7a6d6e74 LibC: Implement f{get,put}ws() 2021-12-21 21:24:36 +03:30
Ali Mohammad Pur
bd9a22e7e7 LibC: Stub out fwide()
This is a mess, and I'd rather not perform checks on every single stdio
operation, so just make it a noop.
2021-12-21 21:24:36 +03:30
Ali Mohammad Pur
cb90856756 LibC: Implement {f,}putwc() 2021-12-21 21:24:36 +03:30
Ali Mohammad Pur
a4e8a09188 LibC: Implement getwchar() 2021-12-21 21:24:36 +03:30
Ali Mohammad Pur
cf17677206 LibC: Implement {f,}getwc() 2021-12-21 21:24:36 +03:30
Ali Mohammad Pur
3b281baf75 LibC: Implement wcs{,c}spn() 2021-12-21 21:24:36 +03:30
Tim Schumacher
8eca395e4c LibC: Implement wcsdup 2021-12-19 18:22:41 -08: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
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
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
Tim Schumacher
9c29e6cde7 LibC: Partially implement wcwidth 2021-10-15 21:50:19 -07: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
Tim Schumacher
5ac2e84264 LibC: Implement wcsstr 2021-10-03 05:28:51 +00:00
Tim Schumacher
1b078f87b7 LibC: Implement wcspbrk 2021-10-03 05:28:51 +00:00
Tim Schumacher
a1617faf44 LibC: Implement mbsinit and mbrtowc 2021-09-16 16:42:40 +02:00
Tim Schumacher
e4fa9c917e LibC: Stub out a bunch of wchar functions 2021-09-16 16:42:40 +02:00
Tim Schumacher
328818af97 LibC: Provide a dummy mbstate_t in wchar.h
POSIX just says that mbstate_t should be an "object type other than an
array type" that can hold the conversion state for converting between
(multi-byte) characters and wide characters.

Since no other information regarding the contents is given, this
apparently means that we should add whatever we need once we start
implementing that conversion.
2021-09-16 16:42:40 +02:00
Tim Schumacher
c2b47c0676 LibC: Add stubs for wctype and iswctype 2021-05-30 14:56:50 +01:00
Tim Schumacher
d364abe4d5 LibC: Stub out btowc
wint_t is also not supposed to be defined by sys/types.h, but should
be defined in wchar.h instead. Since we require it for our definition of
btowc, let's move it to the correct place.
2021-05-30 14:56:50 +01: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
Linus Groh
3c68f557a9 LibC: Add wcstol() and wcstoll() stubs 2021-01-18 22:28:56 +01:00