diff options
| -rw-r--r-- | libcxx/include/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | libcxx/include/__locale | 22 | ||||
| -rw-r--r-- | libcxx/include/__locale_dir/locale_base_api.h | 112 | ||||
| -rw-r--r-- | libcxx/include/__locale_dir/locale_base_api/android.h (renamed from libcxx/include/__support/android/locale_bionic.h) | 6 | ||||
| -rw-r--r-- | libcxx/include/__locale_dir/locale_base_api/fuchsia.h (renamed from libcxx/include/__support/fuchsia/xlocale.h) | 6 | ||||
| -rw-r--r-- | libcxx/include/__locale_dir/locale_base_api/ibm.h (renamed from libcxx/include/__support/ibm/xlocale.h) | 8 | ||||
| -rw-r--r-- | libcxx/include/__locale_dir/locale_base_api/musl.h (renamed from libcxx/include/__support/musl/xlocale.h) | 6 | ||||
| -rw-r--r-- | libcxx/include/__locale_dir/locale_base_api/newlib.h (renamed from libcxx/include/__support/newlib/xlocale.h) | 6 | ||||
| -rw-r--r-- | libcxx/include/__locale_dir/locale_base_api/openbsd.h (renamed from libcxx/include/__support/openbsd/xlocale.h) | 6 | ||||
| -rw-r--r-- | libcxx/include/__locale_dir/locale_base_api/win32.h (renamed from libcxx/include/__support/win32/locale_win32.h) | 6 | ||||
| -rw-r--r-- | libcxx/include/libcxx.imp | 8 | ||||
| -rw-r--r-- | libcxx/include/module.modulemap.in | 16 | ||||
| -rw-r--r-- | libcxx/src/locale.cpp | 4 |
13 files changed, 168 insertions, 53 deletions
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 6a845c8..9fe23c51 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -487,9 +487,17 @@ set(files __iterator/unreachable_sentinel.h __iterator/wrap_iter.h __locale + __locale_dir/locale_base_api.h + __locale_dir/locale_base_api/android.h __locale_dir/locale_base_api/bsd_locale_defaults.h __locale_dir/locale_base_api/bsd_locale_fallbacks.h + __locale_dir/locale_base_api/fuchsia.h + __locale_dir/locale_base_api/ibm.h __locale_dir/locale_base_api/locale_guard.h + __locale_dir/locale_base_api/musl.h + __locale_dir/locale_base_api/newlib.h + __locale_dir/locale_base_api/openbsd.h + __locale_dir/locale_base_api/win32.h __math/abs.h __math/copysign.h __math/error_functions.h @@ -666,16 +674,9 @@ set(files __string/char_traits.h __string/constexpr_c_functions.h __string/extern_template_lists.h - __support/android/locale_bionic.h - __support/fuchsia/xlocale.h __support/ibm/gettod_zos.h __support/ibm/locale_mgmt_zos.h __support/ibm/nanosleep.h - __support/ibm/xlocale.h - __support/musl/xlocale.h - __support/newlib/xlocale.h - __support/openbsd/xlocale.h - __support/win32/locale_win32.h __support/xlocale/__nop_locale_mgmt.h __support/xlocale/__posix_l_fallback.h __support/xlocale/__strtonum_fallback.h diff --git a/libcxx/include/__locale b/libcxx/include/__locale index 3ba7ac1..2186db8 100644 --- a/libcxx/include/__locale +++ b/libcxx/include/__locale @@ -12,6 +12,7 @@ #include <__availability> #include <__config> +#include <__locale_dir/locale_base_api.h> #include <__memory/shared_ptr.h> // __shared_count #include <__mutex/once_flag.h> #include <__type_traits/make_unsigned.h> @@ -32,27 +33,6 @@ # include <__std_mbstate_t.h> #endif -#if defined(_LIBCPP_MSVCRT_LIKE) -# include <__support/win32/locale_win32.h> -#elif defined(_AIX) || defined(__MVS__) -# include <__support/ibm/xlocale.h> -#elif defined(__ANDROID__) -# include <__support/android/locale_bionic.h> -#elif defined(_NEWLIB_VERSION) -# include <__support/newlib/xlocale.h> -#elif defined(__OpenBSD__) -# include <__support/openbsd/xlocale.h> -#elif (defined(__APPLE__) || defined(__FreeBSD__)) -# include <xlocale.h> -#elif defined(__Fuchsia__) -# include <__support/fuchsia/xlocale.h> -#elif defined(__wasi__) -// WASI libc uses musl's locales support. -# include <__support/musl/xlocale.h> -#elif defined(_LIBCPP_HAS_MUSL_LIBC) -# include <__support/musl/xlocale.h> -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h new file mode 100644 index 0000000..2355b4a --- /dev/null +++ b/libcxx/include/__locale_dir/locale_base_api.h @@ -0,0 +1,112 @@ +//===-----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H +#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H + +#if defined(_LIBCPP_MSVCRT_LIKE) +# include <__locale_dir/locale_base_api/win32.h> +#elif defined(_AIX) || defined(__MVS__) +# include <__locale_dir/locale_base_api/ibm.h> +#elif defined(__ANDROID__) +# include <__locale_dir/locale_base_api/android.h> +#elif defined(__sun__) +# include <__locale_dir/locale_base_api/solaris.h> +#elif defined(_NEWLIB_VERSION) +# include <__locale_dir/locale_base_api/newlib.h> +#elif defined(__OpenBSD__) +# include <__locale_dir/locale_base_api/openbsd.h> +#elif defined(__Fuchsia__) +# include <__locale_dir/locale_base_api/fuchsia.h> +#elif defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) +# include <__locale_dir/locale_base_api/musl.h> +#elif defined(__APPLE__) || defined(__FreeBSD__) +# include <xlocale.h> +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +/* +The platform-specific headers have to provide the following interface: + +// TODO: rename this to __libcpp_locale_t +using locale_t = implementation-defined; + +implementation-defined __libcpp_mb_cur_max_l(locale_t); +wint_t __libcpp_btowc_l(int, locale_t); +int __libcpp_wctob_l(wint_t, locale_t); +size_t __libcpp_wcsnrtombs_l(char* dest, const wchar_t** src, size_t wide_char_count, size_t len, mbstate_t, locale_t); +size_t __libcpp_wcrtomb_l(char* str, wchar_t wide_char, mbstate_t*, locale_t); +size_t __libcpp_mbsnrtowcs_l(wchar_t* dest, const char** src, size_t max_out, size_t len, mbstate_t*, locale_t); +size_t __libcpp_mbrtowc_l(wchar_t* dest, cosnt char* src, size_t count, mbstate_t*, locale_t); +int __libcpp_mbtowc_l(wchar_t* dest, const char* src, size_t count, locale_t); +size_t __libcpp_mbrlen_l(const char* str, size_t count, mbstate_t*, locale_t); +lconv* __libcpp_localeconv_l(locale_t); +size_t __libcpp_mbsrtowcs_l(wchar_t* dest, const char** src, size_t len, mbstate_t*, locale_t); +int __libcpp_snprintf_l(char* dest, size_t buff_size, locale_t, const char* format, ...); +int __libcpp_asprintf_l(char** dest, locale_t, const char* format, ...); +int __libcpp_sscanf_l(const char* dest, locale_t, const char* format, ...); + +// TODO: change these to reserved names +float strtof_l(const char* str, char** str_end, locale_t); +double strtod_l(const char* str, char** str_end, locale_t); +long double strtold_l(const char* str, char** str_end, locale_t); +long long strtoll_l(const char* str, char** str_end, locale_t); +unsigned long long strtoull_l(const char* str, char** str_end, locale_t); + +locale_t newlocale(int category_mask, const char* locale, locale_t base); +void freelocale(locale_t); + +int islower_l(int ch, locale_t); +int isupper_l(int ch, locale_t); +int isdigit_l(int ch, locale_t); +int isxdigit_l(int ch, locale_t); +int strcoll_l(const char* lhs, const char* rhs, locale_t); +size_t strxfrm_l(char* dst, const char* src, size_t n, locale_t); +int wcscoll_l(const char* lhs, const char* rhs, locale_t); +size_t wcsxfrm_l(wchar_t* dst, const wchar_t* src, size_t n, locale_t); +int toupper_l(int ch, locale_t); +int tolower_l(int ch, locale_t); +int iswspace_l(wint_t ch, locale_t); +int iswprint_l(wint_t ch, locale_t); +int iswcntrl_l(wint_t ch, locale_t); +int iswupper_l(wint_t ch, locale_t); +int iswlower_l(wint_t ch, locale_t); +int iswalpha_l(wint_t ch, locale_t); +int iswblank_l(wint_t ch, locale_t); +int iswdigit_l(wint_t ch, locale_t); +int iswpunct_l(wint_t ch, locale_t); +int iswxdigit_l(wint_t ch, locale_t); +wint_t towupper_l(wint_t ch, locale_t); +wint_t towlower_l(wint_t ch, locale_t); +size_t strftime_l(char* str, size_t len, const char* format, const tm*, locale_t); + + +These functions are equivalent to their C counterparts, +except that locale_t is used instead of the current global locale. + +The variadic functions may be implemented as templates with a parameter pack instead of variadic functions. +*/ + +/* +// TODO: These symbols are never actually used, but defined by one or more implementations. They should be removed. +long strtol_l(const char* str, char** str_end, locale_t); +unsigned long strtoul_l(const char* str, char** str_end, locale_t); +long long wcstoll_l(const wchar_t* str, wchar_t** str_end, int base, locale_t); +unsigned long long wcstoull_l(const wchar_t* str, wchar_t** str_end, int base, locale_t); +long double wcstold_l(const wchar_t* str, wchar_t** str_end, int base, locale_t); +int sprintf_l(char* str, const char* format, locale_t, ...); +int vsprintf_l(char* str, const char* format, locale_t, va_list); +int vsnprintf_l(char* str, size_t size, const char* format, locale_t, va_list); +int isblank_l(int ch, locale_t); + +*/ + +#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H diff --git a/libcxx/include/__support/android/locale_bionic.h b/libcxx/include/__locale_dir/locale_base_api/android.h index fee2ba5..c2dea1e7 100644 --- a/libcxx/include/__support/android/locale_bionic.h +++ b/libcxx/include/__locale_dir/locale_base_api/android.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H -#define _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H +#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H +#define _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H #if defined(__BIONIC__) @@ -69,4 +69,4 @@ inline _LIBCPP_HIDE_FROM_ABI_C long strtol_l(const char* __nptr, char** __endptr # endif // defined(__ANDROID__) #endif // defined(__BIONIC__) -#endif // _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H +#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H diff --git a/libcxx/include/__support/fuchsia/xlocale.h b/libcxx/include/__locale_dir/locale_base_api/fuchsia.h index 957d5cb..f999bea 100644 --- a/libcxx/include/__support/fuchsia/xlocale.h +++ b/libcxx/include/__locale_dir/locale_base_api/fuchsia.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H -#define _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H +#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H +#define _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H #if defined(__Fuchsia__) @@ -19,4 +19,4 @@ #endif // defined(__Fuchsia__) -#endif // _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H +#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H diff --git a/libcxx/include/__support/ibm/xlocale.h b/libcxx/include/__locale_dir/locale_base_api/ibm.h index 52538e2..498ea1e 100644 --- a/libcxx/include/__support/ibm/xlocale.h +++ b/libcxx/include/__locale_dir/locale_base_api/ibm.h @@ -7,14 +7,16 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___SUPPORT_IBM_XLOCALE_H -#define _LIBCPP___SUPPORT_IBM_XLOCALE_H +#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H +#define _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H #if defined(__MVS__) # include <__support/ibm/locale_mgmt_zos.h> #endif // defined(__MVS__) +#include <locale.h> #include <stdarg.h> +#include <stdio.h> #include "cstdlib" @@ -119,4 +121,4 @@ inline _LIBCPP_HIDE_FROM_ABI int vasprintf(char** strp, const char* fmt, va_list #ifdef __cplusplus } #endif -#endif // _LIBCPP___SUPPORT_IBM_XLOCALE_H +#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H diff --git a/libcxx/include/__support/musl/xlocale.h b/libcxx/include/__locale_dir/locale_base_api/musl.h index 9b0a50b..e4121ec 100644 --- a/libcxx/include/__support/musl/xlocale.h +++ b/libcxx/include/__locale_dir/locale_base_api/musl.h @@ -14,8 +14,8 @@ // in Musl. //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___SUPPORT_MUSL_XLOCALE_H -#define _LIBCPP___SUPPORT_MUSL_XLOCALE_H +#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H +#define _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H #include <cstdlib> #include <cwchar> @@ -50,4 +50,4 @@ inline _LIBCPP_HIDE_FROM_ABI_C long double wcstold_l(const wchar_t* __nptr, wcha } #endif -#endif // _LIBCPP___SUPPORT_MUSL_XLOCALE_H +#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H diff --git a/libcxx/include/__support/newlib/xlocale.h b/libcxx/include/__locale_dir/locale_base_api/newlib.h index 9c57bf4..8d030cb 100644 --- a/libcxx/include/__support/newlib/xlocale.h +++ b/libcxx/include/__locale_dir/locale_base_api/newlib.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___SUPPORT_NEWLIB_XLOCALE_H -#define _LIBCPP___SUPPORT_NEWLIB_XLOCALE_H +#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H +#define _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H #if defined(_NEWLIB_VERSION) @@ -19,4 +19,4 @@ #endif // _NEWLIB_VERSION -#endif +#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H diff --git a/libcxx/include/__support/openbsd/xlocale.h b/libcxx/include/__locale_dir/locale_base_api/openbsd.h index b969ae9..623abdb 100644 --- a/libcxx/include/__support/openbsd/xlocale.h +++ b/libcxx/include/__locale_dir/locale_base_api/openbsd.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___SUPPORT_OPENBSD_XLOCALE_H -#define _LIBCPP___SUPPORT_OPENBSD_XLOCALE_H +#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H +#define _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H #include <__support/xlocale/__strtonum_fallback.h> #include <clocale> @@ -32,4 +32,4 @@ inline _LIBCPP_HIDE_FROM_ABI_C unsigned long strtoul_l(const char* __nptr, char* } #endif -#endif +#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H diff --git a/libcxx/include/__support/win32/locale_win32.h b/libcxx/include/__locale_dir/locale_base_api/win32.h index 55e818e..5dfacfb 100644 --- a/libcxx/include/__support/win32/locale_win32.h +++ b/libcxx/include/__locale_dir/locale_base_api/win32.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H -#define _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H +#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H +#define _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H #include <__config> #include <cstddef> @@ -236,4 +236,4 @@ _LIBCPP_EXPORTED_FROM_ABI int vasprintf_l(char** __ret, locale_t __loc, const ch inline int isblank_l(int __c, locale_t /*loc*/) { return (__c == ' ' || __c == '\t'); } inline int iswblank_l(wint_t __c, locale_t /*loc*/) { return (__c == L' ' || __c == L'\t'); } -#endif // _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H +#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H diff --git a/libcxx/include/libcxx.imp b/libcxx/include/libcxx.imp index 13c0dfeb..a9e3b8b 100644 --- a/libcxx/include/libcxx.imp +++ b/libcxx/include/libcxx.imp @@ -479,9 +479,17 @@ { include: [ "<__iterator/sortable.h>", "private", "<iterator>", "public" ] }, { include: [ "<__iterator/unreachable_sentinel.h>", "private", "<iterator>", "public" ] }, { include: [ "<__iterator/wrap_iter.h>", "private", "<iterator>", "public" ] }, + { include: [ "<__locale_dir/locale_base_api.h>", "private", "<locale>", "public" ] }, + { include: [ "<__locale_dir/locale_base_api/android.h>", "private", "<locale>", "public" ] }, { include: [ "<__locale_dir/locale_base_api/bsd_locale_defaults.h>", "private", "<locale>", "public" ] }, { include: [ "<__locale_dir/locale_base_api/bsd_locale_fallbacks.h>", "private", "<locale>", "public" ] }, + { include: [ "<__locale_dir/locale_base_api/fuchsia.h>", "private", "<locale>", "public" ] }, + { include: [ "<__locale_dir/locale_base_api/ibm.h>", "private", "<locale>", "public" ] }, { include: [ "<__locale_dir/locale_base_api/locale_guard.h>", "private", "<locale>", "public" ] }, + { include: [ "<__locale_dir/locale_base_api/musl.h>", "private", "<locale>", "public" ] }, + { include: [ "<__locale_dir/locale_base_api/newlib.h>", "private", "<locale>", "public" ] }, + { include: [ "<__locale_dir/locale_base_api/openbsd.h>", "private", "<locale>", "public" ] }, + { include: [ "<__locale_dir/locale_base_api/win32.h>", "private", "<locale>", "public" ] }, { include: [ "<__math/abs.h>", "private", "<cmath>", "public" ] }, { include: [ "<__math/copysign.h>", "private", "<cmath>", "public" ] }, { include: [ "<__math/error_functions.h>", "private", "<cmath>", "public" ] }, diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in index 03f7129..7acfe35 100644 --- a/libcxx/include/module.modulemap.in +++ b/libcxx/include/module.modulemap.in @@ -1454,9 +1454,20 @@ module std_private_iterator_sortable [system] { module std_private_iterator_unreachable_sentinel [system] { header "__iterator/unreachable_sentinel.h" } module std_private_iterator_wrap_iter [system] { header "__iterator/wrap_iter.h" } +module std_private_locale_locale_base_api_android [system] { textual header "__locale_dir/locale_base_api/android.h" } module std_private_locale_locale_base_api_bsd_locale_defaults [system] { textual header "__locale_dir/locale_base_api/bsd_locale_defaults.h" } module std_private_locale_locale_base_api_bsd_locale_fallbacks [system] { textual header "__locale_dir/locale_base_api/bsd_locale_fallbacks.h" } +module std_private_locale_locale_base_api_fuchsia [system] { textual header "__locale_dir/locale_base_api/fuchsia.h" } +module std_private_locale_locale_base_api_ibm [system] { textual header "__locale_dir/locale_base_api/ibm.h" } module std_private_locale_locale_base_api_locale_guard [system] { header "__locale_dir/locale_base_api/locale_guard.h" } +module std_private_locale_locale_base_api_musl [system] { textual header "__locale_dir/locale_base_api/musl.h" } +module std_private_locale_locale_base_api_newlib [system] { textual header "__locale_dir/locale_base_api/newlib.h" } +module std_private_locale_locale_base_api_openbsd [system] { textual header "__locale_dir/locale_base_api/openbsd.h" } +module std_private_locale_locale_base_api_win32 [system] { textual header "__locale_dir/locale_base_api/win32.h" } +module std_private_locale_locale_base_api [system] { + header "__locale_dir/locale_base_api.h" + export * +} module std_private_math_abs [system] { header "__math/abs.h" } module std_private_math_copysign [system] { header "__math/copysign.h" } @@ -1914,7 +1925,10 @@ module std_private_type_traits_is_nothrow_constructible [system module std_private_type_traits_is_nothrow_convertible [system] { header "__type_traits/is_nothrow_convertible.h" } module std_private_type_traits_is_nothrow_copy_assignable [system] { header "__type_traits/is_nothrow_copy_assignable.h" } module std_private_type_traits_is_nothrow_copy_constructible [system] { header "__type_traits/is_nothrow_copy_constructible.h" } -module std_private_type_traits_is_nothrow_default_constructible [system] { header "__type_traits/is_nothrow_default_constructible.h" } +module std_private_type_traits_is_nothrow_default_constructible [system] { + header "__type_traits/is_nothrow_default_constructible.h" + export std_private_type_traits_integral_constant +} module std_private_type_traits_is_nothrow_destructible [system] { header "__type_traits/is_nothrow_destructible.h" export std_private_type_traits_is_destructible diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp index 73b24db..7fdd5be 100644 --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -34,9 +34,7 @@ # define _CTYPE_DISABLE_MACROS #endif -#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) -# include "__support/win32/locale_win32.h" -#elif !defined(__BIONIC__) && !defined(__NuttX__) +#if !defined(_LIBCPP_MSVCRT) && !defined(__MINGW32__) && !defined(__BIONIC__) && !defined(__NuttX__) # include <langinfo.h> #endif |
