[libcxx-commits] [libcxx] c45192c - [libc++] Make _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE part of the locale base API (#219196)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 11 02:25:09 PDT 2026


Author: Nikolas Klauser
Date: 2026-09-11T11:25:03+02:00
New Revision: c45192cefe1cd3bf167d975f0f9949ba323845de

URL: https://github.com/llvm/llvm-project/commit/c45192cefe1cd3bf167d975f0f9949ba323845de
DIFF: https://github.com/llvm/llvm-project/commit/c45192cefe1cd3bf167d975f0f9949ba323845de.diff

LOG: [libc++] Make _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE part of the locale base API (#219196)

Whether libc++ has to provide a rune table is really part of the
localization of a platform. Move it there instead of `<__config>`.

Added: 
    

Modified: 
    libcxx/include/__config
    libcxx/include/__locale_dir/ctype_base.h
    libcxx/include/__locale_dir/locale_base_api.h
    libcxx/include/__locale_dir/support/aix.h
    libcxx/include/__locale_dir/support/bsd_like.h
    libcxx/include/__locale_dir/support/fuchsia.h
    libcxx/include/__locale_dir/support/linux.h
    libcxx/include/__locale_dir/support/llvm_libc.h
    libcxx/include/__locale_dir/support/newlib.h
    libcxx/include/__locale_dir/support/openbsd.h
    libcxx/include/__locale_dir/support/windows.h
    libcxx/src/locale.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__config b/libcxx/include/__config
index e98aea7be8531..8cbf9b15b6ab8 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -284,11 +284,6 @@ typedef __char32_t char32_t;
 #    define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 0
 #  endif
 
-#  if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) ||                        \
-      _LIBCPP_HAS_MUSL_LIBC || defined(__OpenBSD__) || _LIBCPP_LIBC_LLVM_LIBC
-#    define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
-#  endif
-
 // We often repeat things just for handling wide characters in the library.
 // When wide characters are disabled, it can be useful to have a quick way of
 // disabling it without having to resort to #if-#endif, which has a larger

diff  --git a/libcxx/include/__locale_dir/ctype_base.h b/libcxx/include/__locale_dir/ctype_base.h
index 1188928d78611..63eaa3c86b0ab 100644
--- a/libcxx/include/__locale_dir/ctype_base.h
+++ b/libcxx/include/__locale_dir/ctype_base.h
@@ -14,6 +14,7 @@
 #if _LIBCPP_HAS_LOCALIZATION
 
 #  include <__configuration/platform.h>
+#  include <__locale_dir/locale_base_api.h>
 #  include <__type_traits/make_unsigned.h>
 #  include <cctype>
 #  include <cstdint>
@@ -27,7 +28,7 @@ _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
 class _LIBCPP_EXPORTED_FROM_ABI ctype_base {
 public:
-#  if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE)
+#  if _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
   typedef unsigned long mask;
   static const mask space  = 1 << 0;
   static const mask print  = 1 << 1;

diff  --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h
index 017d971ec72ba..14ff9d8a45b56 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -104,6 +104,9 @@
 //  int     __asprintf(char**, __locale_t, const char*, ...);        // required by the headers
 //
 //  const char* __get_locale_encoding(__locale_t);
+//
+// #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE /* 0 or 1 depending on whether a rune table has to be provided */
+//
 // }
 
 #if _LIBCPP_HAS_LOCALIZATION

diff  --git a/libcxx/include/__locale_dir/support/aix.h b/libcxx/include/__locale_dir/support/aix.h
index 4ab52793ae3c1..ef2536338435b 100644
--- a/libcxx/include/__locale_dir/support/aix.h
+++ b/libcxx/include/__locale_dir/support/aix.h
@@ -298,4 +298,6 @@ _LIBCPP_DIAGNOSTIC_POP
 } // namespace __locale
 _LIBCPP_END_NAMESPACE_STD
 
+#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 0
+
 #endif // _LIBCPP___LOCALE_DIR_SUPPORT_AIX_H

diff  --git a/libcxx/include/__locale_dir/support/bsd_like.h b/libcxx/include/__locale_dir/support/bsd_like.h
index 6632ca51e1eaa..efc29da670f14 100644
--- a/libcxx/include/__locale_dir/support/bsd_like.h
+++ b/libcxx/include/__locale_dir/support/bsd_like.h
@@ -213,4 +213,6 @@ _LIBCPP_DIAGNOSTIC_POP
 } // namespace __locale
 _LIBCPP_END_NAMESPACE_STD
 
+#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 0
+
 #endif // _LIBCPP___LOCALE_DIR_SUPPORT_BSD_LIKE_H

diff  --git a/libcxx/include/__locale_dir/support/fuchsia.h b/libcxx/include/__locale_dir/support/fuchsia.h
index 1fe292a908a9c..46790b83290af 100644
--- a/libcxx/include/__locale_dir/support/fuchsia.h
+++ b/libcxx/include/__locale_dir/support/fuchsia.h
@@ -155,4 +155,6 @@ _LIBCPP_END_NAMESPACE_STD
 #include <__locale_dir/support/no_locale/characters.h>
 #include <__locale_dir/support/no_locale/strtonum.h>
 
+#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 1
+
 #endif // _LIBCPP___LOCALE_DIR_SUPPORT_FUCHSIA_H

diff  --git a/libcxx/include/__locale_dir/support/linux.h b/libcxx/include/__locale_dir/support/linux.h
index 6a91a001c239c..74abf5ab7c598 100644
--- a/libcxx/include/__locale_dir/support/linux.h
+++ b/libcxx/include/__locale_dir/support/linux.h
@@ -250,4 +250,10 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(
 } // namespace __locale
 _LIBCPP_END_NAMESPACE_STD
 
+#if defined(__BIONIC__) || _LIBCPP_HAS_MUSL_LIBC
+#  define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 1
+#else
+#  define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 0
+#endif
+
 #endif // _LIBCPP___LOCALE_DIR_SUPPORT_LINUX_H

diff  --git a/libcxx/include/__locale_dir/support/llvm_libc.h b/libcxx/include/__locale_dir/support/llvm_libc.h
index c494f07f4f1f4..fe9d3639ecf3f 100644
--- a/libcxx/include/__locale_dir/support/llvm_libc.h
+++ b/libcxx/include/__locale_dir/support/llvm_libc.h
@@ -59,4 +59,6 @@ _LIBCPP_END_NAMESPACE_STD
 #include <__locale_dir/support/no_locale/formatting.h>
 #include <__locale_dir/support/no_locale/strtonum.h>
 
+#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 1
+
 #endif // _LIBCPP___LOCALE_DIR_SUPPORT_LLVM_LIBC_H

diff  --git a/libcxx/include/__locale_dir/support/newlib.h b/libcxx/include/__locale_dir/support/newlib.h
index 7fe48572b4587..6e34de84a6c48 100644
--- a/libcxx/include/__locale_dir/support/newlib.h
+++ b/libcxx/include/__locale_dir/support/newlib.h
@@ -245,4 +245,6 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(
 } // namespace __locale
 _LIBCPP_END_NAMESPACE_STD
 
+#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 0
+
 #endif // _LIBCPP___LOCALE_DIR_SUPPORT_NEWLIB_H

diff  --git a/libcxx/include/__locale_dir/support/openbsd.h b/libcxx/include/__locale_dir/support/openbsd.h
index 0ec5b12f2ebdd..ac66d393ade7c 100644
--- a/libcxx/include/__locale_dir/support/openbsd.h
+++ b/libcxx/include/__locale_dir/support/openbsd.h
@@ -226,4 +226,6 @@ _LIBCPP_DIAGNOSTIC_POP
 } // namespace __locale
 _LIBCPP_END_NAMESPACE_STD
 
+#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 1
+
 #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H

diff  --git a/libcxx/include/__locale_dir/support/windows.h b/libcxx/include/__locale_dir/support/windows.h
index 6675cfb740b29..2c480d289c0e4 100644
--- a/libcxx/include/__locale_dir/support/windows.h
+++ b/libcxx/include/__locale_dir/support/windows.h
@@ -309,4 +309,6 @@ struct __locale_guard {
 _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
 _LIBCPP_END_NAMESPACE_STD
 
+#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 0
+
 #endif // _LIBCPP___LOCALE_DIR_SUPPORT_WINDOWS_H

diff  --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp
index f3f2905da320b..2228624901ac4 100644
--- a/libcxx/src/locale.cpp
+++ b/libcxx/src/locale.cpp
@@ -816,7 +816,7 @@ extern "C" const int** __ctype_tolower_loc();
 extern "C" const int** __ctype_toupper_loc();
 #endif
 
-#ifdef _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
+#if _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
 const ctype<char>::mask* ctype<char>::classic_table() noexcept {
   // clang-format off
     static constexpr const ctype<char>::mask builtin_table[table_size] = {


        


More information about the libcxx-commits mailing list