[libcxx-commits] [libcxx] ea05555 - [libc++] Add implementations of `__get_locale_encoding(...)` to Fuschia and LLVM-Libc (#205716)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 25 00:31:28 PDT 2026
Author: William Tran-Viet
Date: 2026-06-25T15:31:23+08:00
New Revision: ea05555c54ab5d15628e2676cd17ca084a81901a
URL: https://github.com/llvm/llvm-project/commit/ea05555c54ab5d15628e2676cd17ca084a81901a
DIFF: https://github.com/llvm/llvm-project/commit/ea05555c54ab5d15628e2676cd17ca084a81901a.diff
LOG: [libc++] Add implementations of `__get_locale_encoding(...)` to Fuschia and LLVM-Libc (#205716)
- These were missed in #141312 and consequently broke the Fuschia and
AMDGPU llvm-libc build bots.
- Fuschia seems to have support for `nl_langinfo_l(...)`, so we can use
that.
- However, LLVM-libc does not implement it, so for now we can do a dummy
implementation and mark `environment()` and `encoding()` as unsupported
on LLVM libc.
Added:
Modified:
libcxx/include/__locale_dir/support/fuchsia.h
libcxx/include/__locale_dir/support/llvm_libc.h
libcxx/test/libcxx/text/text_encoding/environment.pass.cpp
libcxx/test/std/text/text_encoding/text_encoding.members/environment.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/include/__locale_dir/support/fuchsia.h b/libcxx/include/__locale_dir/support/fuchsia.h
index 528bfeb0cb6e1..1fe292a908a9c 100644
--- a/libcxx/include/__locale_dir/support/fuchsia.h
+++ b/libcxx/include/__locale_dir/support/fuchsia.h
@@ -15,6 +15,7 @@
#include <cstdio>
#include <cstdlib>
#include <cwchar>
+#include <langinfo.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -69,6 +70,10 @@ inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) {
return std::localeconv();
}
+inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc) {
+ return ::nl_langinfo_l(CODESET, __loc);
+}
+
//
// Other functions
//
diff --git a/libcxx/include/__locale_dir/support/llvm_libc.h b/libcxx/include/__locale_dir/support/llvm_libc.h
index 1ce1c443d87ed..c494f07f4f1f4 100644
--- a/libcxx/include/__locale_dir/support/llvm_libc.h
+++ b/libcxx/include/__locale_dir/support/llvm_libc.h
@@ -47,6 +47,8 @@ inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __loc
}
inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t&) { return std::localeconv(); }
+
+inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t) { return nullptr; }
#endif // _LIBCPP_BUILDING_LIBRARY
} // namespace __locale
diff --git a/libcxx/test/libcxx/text/text_encoding/environment.pass.cpp b/libcxx/test/libcxx/text/text_encoding/environment.pass.cpp
index b5c88c6e6d568..0bcabb235fc8b 100644
--- a/libcxx/test/libcxx/text/text_encoding/environment.pass.cpp
+++ b/libcxx/test/libcxx/text/text_encoding/environment.pass.cpp
@@ -14,6 +14,7 @@
// UNSUPPORTED: no-localization
// UNSUPPORTED: windows, android
// UNSUPPORTED: availability-te-environment-missing
+// UNSUPPORTED: LLVM-LIBC-FIXME
// std::text_encoding::environment()
diff --git a/libcxx/test/std/text/text_encoding/text_encoding.members/environment.pass.cpp b/libcxx/test/std/text/text_encoding/text_encoding.members/environment.pass.cpp
index 113b151765c81..8907f72b55140 100644
--- a/libcxx/test/std/text/text_encoding/text_encoding.members/environment.pass.cpp
+++ b/libcxx/test/std/text/text_encoding/text_encoding.members/environment.pass.cpp
@@ -11,6 +11,7 @@
// UNSUPPORTED: no-localization
// UNSUPPORTED: availability-te-environment-missing
+// UNSUPPORTED: LLVM-LIBC-FIXME
// <text_encoding>
More information about the libcxx-commits
mailing list