Skip to content

Commit

Permalink
[libc++] Refactor the Windows and MinGW implementation of the locale …
Browse files Browse the repository at this point in the history
…base API (llvm#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).
  • Loading branch information
ldionne authored Dec 16, 2024
1 parent 8c16323 commit 084309a
Show file tree
Hide file tree
Showing 9 changed files with 426 additions and 341 deletions.
3 changes: 3 additions & 0 deletions libcxx/docs/ReleaseNotes/20.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ ABI Affecting Changes
- When using the MSVC ABI, this change results in some classes having a completely different memory layout, so this is
a genuine ABI break. However, the library does not currently guarantee ABI stability on MSVC platforms.

- The localization support base API has been reimplemented, leading to different functions being exported from the
libc++ built library on Windows and Windows-like platforms.

Build System Changes
--------------------

Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,12 @@ set(files
__locale_dir/locale_base_api/ibm.h
__locale_dir/locale_base_api/musl.h
__locale_dir/locale_base_api/openbsd.h
__locale_dir/locale_base_api/win32.h
__locale_dir/locale_guard.h
__locale_dir/pad_and_output.h
__locale_dir/support/apple.h
__locale_dir/support/bsd_like.h
__locale_dir/support/freebsd.h
__locale_dir/support/windows.h
__math/abs.h
__math/copysign.h
__math/error_functions.h
Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/__locale_dir/locale_base_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@
# include <__locale_dir/support/apple.h>
#elif defined(__FreeBSD__)
# include <__locale_dir/support/freebsd.h>
#elif defined(_LIBCPP_MSVCRT_LIKE)
# include <__locale_dir/support/windows.h>
#else

// TODO: This is a temporary definition to bridge between the old way we defined the locale base API
// (by providing global non-reserved names) and the new API. As we move individual platforms
// towards the new way of defining the locale base API, this should disappear since each platform
// will define those directly.
# if defined(_LIBCPP_MSVCRT_LIKE)
# include <__locale_dir/locale_base_api/win32.h>
# elif defined(_AIX) || defined(__MVS__)
# if defined(_AIX) || defined(__MVS__)
# include <__locale_dir/locale_base_api/ibm.h>
# elif defined(__ANDROID__)
# include <__locale_dir/locale_base_api/android.h>
Expand Down
235 changes: 0 additions & 235 deletions libcxx/include/__locale_dir/locale_base_api/win32.h

This file was deleted.

2 changes: 1 addition & 1 deletion libcxx/include/__locale_dir/locale_guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD

#if defined(_LIBCPP_MSVCRT_LIKE)
struct __locale_guard {
__locale_guard(locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) {
__locale_guard(__locale::__locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) {
// Setting the locale can be expensive even when the locale given is
// already the current locale, so do an explicit check to see if the
// current locale is already the one we want.
Expand Down
Loading

0 comments on commit 084309a

Please sign in to comment.