31 Commits

Author SHA1 Message Date
Louis Dionne
bcfd9f81e1 [libc++] Fix stray usage of _LIBCPP_HAS_NO_WIDE_CHARACTERS on Windows 2025-02-05 08:37:09 -05:00
Louis Dionne
88cca8ea20
[libc++] Add more missing bits to the locale base API (#122531)
This patch adds the following pieces to the locale base API:
- __setlocale (for std::setlocale)
- __lconv_t (for std::lconv)
- _LIBCPP_FOO_MASK and _LIBCPP_LC_ALL

This should be sufficient to implement all of the platform-agnostic
localization support in libc++ without relying directly on any public
API names from the C library. This makes it possible to port libc++ to
platforms that don't provide the usual locale APIs.
2025-01-27 12:41:00 -05:00
Brad Smith
6bc68d0fe9
[libc++] Remove support for Android 4 and older (#124062) 2025-01-23 10:27:26 +01:00
Louis Dionne
b5ba4f06db
[libc++] Redefine Fuchsia locale base support on top of the new API (#122489)
This follows the same path we've been doing for all platforms so far,
moving away from the old definition of the locale base API.

Co-authored-by: Daniel Thornburgh <mysterymath@gmail.com>
2025-01-13 09:16:23 -05:00
Louis Dionne
c664a7f975
[libc++] Remove obsolete bsd_locale_defaults.h (#122276)
Supported platforms who used to need this header now go through the new
locale base API instead, so that header is not required anymore.
2025-01-10 11:03:50 -05:00
Louis Dionne
81ae6686ab
[libc++] Add __iswctype to the locale base API since it's required by <locale> (#122168) 2025-01-09 08:51:51 -05:00
Nikolas Klauser
f69585235e
[libc++] Put _LIBCPP_NODEBUG on all internal aliases (#118710)
This significantly reduces the amount of debug information generated
for codebases using libc++, without hurting the debugging experience.
2025-01-08 11:12:59 -05:00
Louis Dionne
34e0f9cd36
[libc++] Remove the need for uselocale() (#120158)
Instead of requiring `uselocale()` as part of the base locale API,
define __locale_guard in the few places that need it directly, without
making __locale_guard part of the base API.

In practice, most mainstream platforms never used __locale_guard, so
they also didn't need to define uselocale(), and after this patch they
actually don't define it anymore.
2024-12-19 16:06:08 -05:00
Louis Dionne
084309a0ef
[libc++] Refactor the Windows and MinGW implementation of the locale base API (#115752)
This patch reimplements the locale base support for Windows flavors in a
way that is more modules-friendly and without defining non-internal
names.

Since this changes the name of some types and entry points in the built
library, this is effectively an ABI break on Windows (which is
acceptable after checking with the Windows/libc++ maintainers).
2024-12-16 17:46:05 -05:00
A. Jiang
b5bc528c14
[libc++] Guard __pad_and_output with _LIBCPP_HAS_LOCALIZATION (#116580)
This fixes errors for no-localization builds (possibly introduced by
#116223).
2024-11-18 17:03:29 +08:00
Nikolas Klauser
811186764d [libc++] Fix a few problems found by clang-tidy 2024-11-17 11:07:41 +01:00
Nikolas Klauser
764834d63d
[libc++] Remove <istream> and <ostream> includes from <iomanip> (#116223)
This reduces the include time of `<filesystem>` by ~50ms.
2024-11-16 18:20:55 +01:00
Louis Dionne
9c3a7ad7fa
[libc++] Cleanly implement the base locale API for BSD-like platforms (#115176)
Instead of going through the old locale entry points, define the base
localization API for BSD-like platforms (Apple and FreeBSD) from
scratch, using <xlocale.h> as a basis. This doesn't actually change how
that functionality is implemented, it only avoids going through a maze
to do so.

This clean new support is implemented in a separate __locale_dir/support
directory, which mirrors what we do for the threading support API.
Eventually, everything under __locale_dir/locale_base_api will go away.

rdar://131476632
2024-11-11 13:11:23 -05:00
Louis Dionne
5d8be4c036
[libc++] Define an internal locale API as a shim on top of the current one (#114596)
Our current locale base API is a mix of non-reserved system names that
we incorrectly (re)define and internal functions and macros starting
with __libcpp. This patch introduces a function-based internal interface
to isolate the rest of the code base from that mess, so that we can work
on refactoring how each platform implements the base API in subsequent
patches. This makes it possible to refactor how each platform implements
the base localization API without impacting the rest of the code base.
2024-11-06 09:57:08 -05:00
Nikolas Klauser
c6f3b7bcd0
[libc++] Refactor the configuration macros to being always defined (#112094)
This is a follow-up to #89178. This updates the `<__config_site>`
macros.
2024-11-06 10:39:19 +01:00
Louis Dionne
1a187674a1
[libc++] Use proper functions instead of macros in bsd_locale_defaults.h (#113759)
We were using macros instead of functions, leading to the inability to
properly qualify calls to those symbols inside <locale>. This is also a
step towards making the locale API modules-correct.
2024-11-01 15:16:09 -04:00
Louis Dionne
e146c1867e
[libc++] Split Apple and Freebsd locale support into their own headers (#113737)
For now these headers don't provide much benefit, however as we refactor
the locale base API they will provide a location to specify the
localization interface on these platforms.
2024-10-26 09:03:04 -04:00
Louis Dionne
cfde4fbccf
[libc++] Remove obsolete Solaris and Newlib support for locales (#113721)
The solaris header file doesn't even exist, so that's definitely dead
code. The newlib header is empty, which means that localization can't
work on that platform. If someone is using libc++ with Newlib, they must
be providing LIBCXX_HAS_NO_LOCALIZATION today for anything to work, so
that header is basically dead code as well.
2024-10-25 16:46:38 -04:00
Louis Dionne
1f2b7ae6d7
[libc++] Refactor locale_guard (#113694)
Rename __libcpp_locale_guard to just __locale_guard, since there's no
reason for it to have __libcpp_ in its name -- it's just an internal
utility.

Also, define __locale_guard unconditionally of
_LIBCPP_LOCALE__L_EXTENSIONS, since that header is only used on Windows
(where it has a custom definition) or from bsd_locale_fallbacks.h, which
is only included when the L extensions are not provided.
2024-10-25 12:28:55 -04:00
Louis Dionne
800a47d6cd [libc++][NFC] Fix include guards inside locale_base_api 2024-10-25 10:17:59 -04:00
Louis Dionne
d0438d2d08
[libc++][NFC] Replace uses of NULL by nullptr (#108847)
Closes #108741
2024-09-17 08:10:41 -04:00
Nikolas Klauser
02c7be5094
[libc++] Remove dead code from the locale base API and support code (#89070) 2024-07-06 23:49:41 +02:00
Nikolas Klauser
bbe4a80605
[libc++] Enable modernize-use-equals-delete (#93293)
Differential Revision: https://reviews.llvm.org/D121213
2024-06-18 10:51:57 +02:00
Nikolas Klauser
5367b2c862
[libc++] Don't give functions C linkage (#94102)
There is no reason to give any of the functions C linkage. This makes
all of the libc++ functions have C++ linkage, removing the need for
`_LIBCPP_HIDE_FROM_ABI_C`.
2024-06-02 21:05:53 +02:00
Danny Mösch
00e80fbfb9
[NFC] Correct C++ standard names (#81421) 2024-02-11 19:43:34 +01:00
Nikolas Klauser
f87e3b61c8
[libc++] Move the locale support headers to __locale_dir/locale_base_api/ (#74522)
Differential Revision: https://reviews.llvm.org/D147869
2024-02-03 20:50:06 +01:00
Louis Dionne
9783f28cbb
[libc++] Format the code base (#74334)
This patch runs clang-format on all of libcxx/include and libcxx/src, in
accordance with the RFC discussed at [1]. Follow-up patches will format
the benchmarks, the test suite and remaining parts of the code. I'm
splitting this one into its own patch so the diff is a bit easier to
review.

This patch was generated with:

   find libcxx/include libcxx/src -type f \
      | grep -v 'module.modulemap.in' \
      | grep -v 'CMakeLists.txt' \
      | grep -v 'README.txt' \
      | grep -v 'libcxx.imp' \
      | grep -v '__config_site.in' \
      | xargs clang-format -i

A Git merge driver is available in libcxx/utils/clang-format-merge-driver.sh
to help resolve merge and rebase issues across these formatting changes.

[1]: https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
2023-12-18 14:01:33 -05:00
Louis Dionne
77a00c0d54
[libc++] Replace uses of _VSTD:: by std:: (#74331)
As part of the upcoming clang-formatting of libc++, this patch performs
the long desired removal of the _VSTD macro.

See https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
for the clang-format proposal.
2023-12-05 11:19:15 -05:00
Louis Dionne
4c19854222
[libc++] Rename _LIBCPP_INLINE_VISIBILITY to _LIBCPP_HIDE_FROM_ABI (#74095)
In preparation for running clang-format on the whole code base, we are
also removing mentions of the legacy _LIBCPP_INLINE_VISIBILITY macro in
favor of the newer _LIBCPP_HIDE_FROM_ABI.

We're still leaving the definition of _LIBCPP_INLINE_VISIBILITY to avoid
creating needless breakage in case some older patches are checked-in
with mentions of the old macro. After we branch for LLVM 18, we can do
another pass to clean up remaining uses of the macro that might have
gotten introduced by mistake (if any) and remove the macro itself at the
same time. This is just a minor convenience to smooth out the transition
as much as possible.

See
https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
for the clang-format proposal.
2023-12-04 10:25:14 -05:00
Ian Anderson
6021c78fe5 [libc++][Modules] locale fails to compile with clang modules when _LIBCPP_LOCALE__L_EXTENSIONS is undefined
When `__locale_dir/locale_base_api/locale_guard.h is` compiled independently, as it is when it's in its own clang module, it fails to compile due to `locale_t` being undefined. It needs to include `__locale` to get that, instead of just `clocale`.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D158669
2023-08-24 14:22:41 -07:00
Nikolas Klauser
c847b8e24c [libc++] Make bsd_locale_fallbacks.h modular and move it into __locale/locale_base_api/
This is a first step towards granularizing `<locale>`.

Reviewed By: ldionne, #libc

Spies: arichardson, libcxx-commits, mikhail.ramalho

Differential Revision: https://reviews.llvm.org/D146397
2023-04-21 05:36:41 +02:00