diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__locale_dir/locale_base_api.h @@ -0,0 +1,63 @@ +//===-----------------------------------------------------------------------===// +// +// 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 +#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, ...); + +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 pacj instead of variadic functions +*/ + +#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 rename from libcxx/include/__support/android/locale_bionic.h rename to libcxx/include/__locale_dir/locale_base_api/android.h --- 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 @@ #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 rename from libcxx/include/__support/fuchsia/xlocale.h rename to libcxx/include/__locale_dir/locale_base_api/fuchsia.h --- 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 rename from libcxx/include/__support/ibm/xlocale.h rename to libcxx/include/__locale_dir/locale_base_api/ibm.h --- a/libcxx/include/__support/ibm/xlocale.h +++ b/libcxx/include/__locale_dir/locale_base_api/ibm.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#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> @@ -126,4 +126,4 @@ #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 rename from libcxx/include/__support/musl/xlocale.h rename to libcxx/include/__locale_dir/locale_base_api/musl.h --- 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 #include @@ -49,4 +49,4 @@ } #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 rename from libcxx/include/__support/newlib/xlocale.h rename to libcxx/include/__locale_dir/locale_base_api/newlib.h --- 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) @@ -20,4 +20,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 rename from libcxx/include/__support/openbsd/xlocale.h rename to libcxx/include/__locale_dir/locale_base_api/openbsd.h --- 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 @@ -32,4 +32,4 @@ } #endif -#endif +#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H diff --git a/libcxx/include/__support/solaris/xlocale.h b/libcxx/include/__locale_dir/locale_base_api/solaris.h rename from libcxx/include/__support/solaris/xlocale.h rename to libcxx/include/__locale_dir/locale_base_api/solaris.h --- a/libcxx/include/__support/solaris/xlocale.h +++ b/libcxx/include/__locale_dir/locale_base_api/solaris.h @@ -10,8 +10,8 @@ // Minimal xlocale implementation for Solaris. This implements the subset of // the xlocale APIs that libc++ depends on. //////////////////////////////////////////////////////////////////////////////// -#ifndef __XLOCALE_H_INCLUDED -#define __XLOCALE_H_INCLUDED +#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_SOLARIS_H +#define _LIBCPP___LOCALE_LOCALE_BASE_API_SOLARIS_H #include @@ -72,4 +72,4 @@ } #endif -#endif +#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_SOLARIS_H diff --git a/libcxx/include/__support/win32/locale_win32.h b/libcxx/include/__locale_dir/locale_base_api/win32.h rename from libcxx/include/__support/win32/locale_win32.h rename to libcxx/include/__locale_dir/locale_base_api/win32.h --- 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 @@ -279,4 +279,4 @@ return ( __c == L' ' || __c == L'\t' ); } -#endif // _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H +#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H