Skip to content

Commit fec5f34

Browse files
committed
[libc++] Refactor the Windows and MinGW implementation of the locale base API
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 since we don't promise ABI stability on that platform).
1 parent b21fa18 commit fec5f34

File tree

9 files changed

+426
-341
lines changed

9 files changed

+426
-341
lines changed

libcxx/docs/ReleaseNotes/20.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ ABI Affecting Changes
152152
- When using the MSVC ABI, this change results in some classes having a completely different memory layout, so this is
153153
a genuine ABI break. However, the library does not currently guarantee ABI stability on MSVC platforms.
154154

155+
- The localization support base API has been reimplemented, leading to different functions being exported from the
156+
libc++ built library on Windows and Windows-like platforms.
157+
155158
Build System Changes
156159
--------------------
157160

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,12 @@ set(files
503503
__locale_dir/locale_base_api/ibm.h
504504
__locale_dir/locale_base_api/musl.h
505505
__locale_dir/locale_base_api/openbsd.h
506-
__locale_dir/locale_base_api/win32.h
507506
__locale_dir/locale_guard.h
508507
__locale_dir/pad_and_output.h
509508
__locale_dir/support/apple.h
510509
__locale_dir/support/bsd_like.h
511510
__locale_dir/support/freebsd.h
511+
__locale_dir/support/windows.h
512512
__math/abs.h
513513
__math/copysign.h
514514
__math/error_functions.h

libcxx/include/__locale_dir/locale_base_api.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@
9898
# include <__locale_dir/support/apple.h>
9999
#elif defined(__FreeBSD__)
100100
# include <__locale_dir/support/freebsd.h>
101+
#elif defined(_LIBCPP_MSVCRT_LIKE)
102+
# include <__locale_dir/support/windows.h>
101103
#else
102104

103105
// TODO: This is a temporary definition to bridge between the old way we defined the locale base API
104106
// (by providing global non-reserved names) and the new API. As we move individual platforms
105107
// towards the new way of defining the locale base API, this should disappear since each platform
106108
// will define those directly.
107-
# if defined(_LIBCPP_MSVCRT_LIKE)
108-
# include <__locale_dir/locale_base_api/win32.h>
109-
# elif defined(_AIX) || defined(__MVS__)
109+
# if defined(_AIX) || defined(__MVS__)
110110
# include <__locale_dir/locale_base_api/ibm.h>
111111
# elif defined(__ANDROID__)
112112
# include <__locale_dir/locale_base_api/android.h>

libcxx/include/__locale_dir/locale_base_api/win32.h

Lines changed: 0 additions & 235 deletions
This file was deleted.

libcxx/include/__locale_dir/locale_guard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121

2222
#if defined(_LIBCPP_MSVCRT_LIKE)
2323
struct __locale_guard {
24-
__locale_guard(locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) {
24+
__locale_guard(__locale::__locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) {
2525
// Setting the locale can be expensive even when the locale given is
2626
// already the current locale, so do an explicit check to see if the
2727
// current locale is already the one we want.

0 commit comments

Comments
 (0)