[libcxx-commits] [libcxx] [libc++] Remove obsolete bsd_locale_defaults.h (PR #122276)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 9 06:04:37 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Louis Dionne (ldionne)
<details>
<summary>Changes</summary>
Supported platforms who used to need this header now go through the new locale base API instead, so that header is not required anymore.
---
Full diff: https://github.com/llvm/llvm-project/pull/122276.diff
6 Files Affected:
- (modified) libcxx/include/CMakeLists.txt (-1)
- (modified) libcxx/include/__config (-4)
- (modified) libcxx/include/__locale_dir/locale_base_api.h (+1-5)
- (removed) libcxx/include/__locale_dir/locale_base_api/bsd_locale_defaults.h (-116)
- (modified) libcxx/include/locale (+1-1)
- (modified) libcxx/include/module.modulemap (-1)
``````````diff
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 0b484ebe5e87c8..80c1acb09bc07f 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -497,7 +497,6 @@ set(files
__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
diff --git a/libcxx/include/__config b/libcxx/include/__config
index ace6e1cd73e3e0..5d5c90d7b87a7b 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -629,10 +629,6 @@ typedef __char32_t char32_t;
# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
# endif // _LIBCPP_CXX03_LANG
-# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__)
-# define _LIBCPP_LOCALE__L_EXTENSIONS 1
-# endif
-
# ifdef __FreeBSD__
# define _DECLARE_C99_LDBL_MATH 1
# endif
diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h
index cda6033b03db78..bb0da889f4c845 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -117,11 +117,7 @@
# include <__locale_dir/locale_base_api/musl.h>
# endif
-# ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-# include <__locale_dir/locale_base_api/bsd_locale_defaults.h>
-# else
-# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h>
-# endif
+# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h>
# include <__cstddef/size_t.h>
# include <__utility/forward.h>
diff --git a/libcxx/include/__locale_dir/locale_base_api/bsd_locale_defaults.h b/libcxx/include/__locale_dir/locale_base_api/bsd_locale_defaults.h
deleted file mode 100644
index 73ab635d287859..00000000000000
--- a/libcxx/include/__locale_dir/locale_base_api/bsd_locale_defaults.h
+++ /dev/null
@@ -1,116 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-// The BSDs have lots of *_l functions. We don't want to define those symbols
-// on other platforms though, for fear of conflicts with user code. So here,
-// we will define the mapping from an internal macro to the real BSD symbol.
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_DEFAULTS_H
-#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_DEFAULTS_H
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <wchar.h>
-#endif
-
-// <xlocale.h> must come after the includes above since the functions it includes depend on
-// what headers have been included up to that point.
-#if defined(__APPLE__) || defined(__FreeBSD__)
-# include <xlocale.h>
-#endif
-
-#include <__config>
-#include <__cstddef/size_t.h>
-#include <__std_mbstate_t.h>
-#include <__utility/forward.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __loc) { return MB_CUR_MAX_L(__loc); }
-
-#if _LIBCPP_HAS_WIDE_CHARACTERS
-inline _LIBCPP_HIDE_FROM_ABI wint_t __libcpp_btowc_l(int __c, locale_t __loc) { return ::btowc_l(__c, __loc); }
-
-inline _LIBCPP_HIDE_FROM_ABI int __libcpp_wctob_l(wint_t __c, locale_t __loc) { return ::wctob_l(__c, __loc); }
-
-inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_wcsnrtombs_l(
- char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, locale_t __loc) {
- return ::wcsnrtombs_l(__dest, __src, __nwc, __len, __ps, __loc);
-}
-
-inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_wcrtomb_l(char* __s, wchar_t __wc, mbstate_t* __ps, locale_t __loc) {
- return ::wcrtomb_l(__s, __wc, __ps, __loc);
-}
-
-inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_mbsnrtowcs_l(
- wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, locale_t __loc) {
- return ::mbsnrtowcs_l(__dest, __src, __nms, __len, __ps, __loc);
-}
-
-inline _LIBCPP_HIDE_FROM_ABI size_t
-__libcpp_mbrtowc_l(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, locale_t __loc) {
- return ::mbrtowc_l(__pwc, __s, __n, __ps, __loc);
-}
-
-inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mbtowc_l(wchar_t* __pwc, const char* __pmb, size_t __max, locale_t __loc) {
- return ::mbtowc_l(__pwc, __pmb, __max, __loc);
-}
-
-inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_mbrlen_l(const char* __s, size_t __n, mbstate_t* __ps, locale_t __loc) {
- return ::mbrlen_l(__s, __n, __ps, __loc);
-}
-#endif // _LIBCPP_HAS_WIDE_CHARACTERS
-
-inline _LIBCPP_HIDE_FROM_ABI lconv* __libcpp_localeconv_l(locale_t& __loc) { return ::localeconv_l(__loc); }
-
-#if _LIBCPP_HAS_WIDE_CHARACTERS
-inline _LIBCPP_HIDE_FROM_ABI size_t
-__libcpp_mbsrtowcs_l(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, locale_t __loc) {
- return ::mbsrtowcs_l(__dest, __src, __len, __ps, __loc);
-}
-#endif
-
-_LIBCPP_DIAGNOSTIC_PUSH
-_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
-_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates
-#ifdef _LIBCPP_COMPILER_CLANG_BASED
-# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)
-#else
-# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
-#endif
-
-template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __libcpp_snprintf_l(
- char* __s, size_t __n, locale_t __loc, const char* __format, _Args&&... __args) {
- return ::snprintf_l(__s, __n, __loc, __format, std::forward<_Args>(__args)...);
-}
-
-template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __libcpp_asprintf_l(
- char** __s, locale_t __loc, const char* __format, _Args&&... __args) {
- return ::asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...);
-}
-
-template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __libcpp_sscanf_l(
- const char* __s, locale_t __loc, const char* __format, _Args&&... __args) {
- return ::sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...);
-}
-_LIBCPP_DIAGNOSTIC_POP
-#undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_DEFAULTS_H
diff --git a/libcxx/include/locale b/libcxx/include/locale
index 981f25ed1e98cf..5af674d19414b4 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -219,7 +219,7 @@ template <class charT> class messages_byname;
# include <streambuf>
# include <version>
-// TODO: Properly qualify calls now that __bsd_locale_defaults.h defines functions instead of macros
+// TODO: Properly qualify calls now that the locale base API defines functions instead of macros
// NOLINTBEGIN(libcpp-robust-against-adl)
# if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 86efbd36b20d1d..5c2150a1e81e26 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -1482,7 +1482,6 @@ module std [system] {
module locale_base_api {
textual header "__locale_dir/locale_base_api/android.h"
- textual header "__locale_dir/locale_base_api/bsd_locale_defaults.h"
textual header "__locale_dir/locale_base_api/bsd_locale_fallbacks.h"
textual header "__locale_dir/locale_base_api/fuchsia.h"
textual header "__locale_dir/locale_base_api/ibm.h"
``````````
</details>
https://github.com/llvm/llvm-project/pull/122276
More information about the libcxx-commits
mailing list