[libcxx-commits] [libcxx] [libc++] Move the locale support headers to __locale_dir/locale_base_api/ (PR #74522)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 21 09:16:29 PST 2023


================
@@ -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 <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, ...);
----------------
ldionne wrote:

Can we also document functions like `strtoull_l` that we expect those headers to define? And we should have a TODO to move them to reserved identifiers instead.

https://github.com/llvm/llvm-project/pull/74522


More information about the libcxx-commits mailing list