[libcxx-commits] [libcxx] [libc++] Make _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE part of the locale base API (PR #219196)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 28 00:26:18 PDT 2026
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/219196
>From 556e32c03f5b1a36745ca1e58a3e220b540ab572 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 27 Aug 2026 14:18:10 +0200
Subject: [PATCH] [libc++] Make _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE part of the
locale base API
---
libcxx/include/__config | 5 -----
libcxx/include/__locale_dir/ctype_base.h | 3 ++-
libcxx/include/__locale_dir/support/bsd_like.h | 2 ++
libcxx/include/__locale_dir/support/fuchsia.h | 2 ++
libcxx/include/__locale_dir/support/linux.h | 6 ++++++
libcxx/include/__locale_dir/support/llvm_libc.h | 2 ++
libcxx/include/__locale_dir/support/newlib.h | 2 ++
libcxx/include/__locale_dir/support/openbsd.h | 2 ++
libcxx/include/__locale_dir/support/windows.h | 2 ++
libcxx/src/locale.cpp | 2 +-
10 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 31c573ba5dca3..29688e9de142b 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -286,11 +286,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/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