-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc++] Add __iswctype to the locale base API since it's required by <locale> #122168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-libcxx Author: Louis Dionne (ldionne) ChangesFull diff: https://github.com/llvm/llvm-project/pull/122168.diff 4 Files Affected:
diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h
index c8097beb9052df..6e3392e2dce8b8 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -56,6 +56,7 @@
// int __strcoll(const char*, const char*, __locale_t);
// size_t __strxfrm(char*, const char*, size_t, __locale_t);
//
+// int __iswctype(wint_t, wctype_t, __locale_t);
// int __iswspace(wint_t, __locale_t);
// int __iswprint(wint_t, __locale_t);
// int __iswcntrl(wint_t, __locale_t);
@@ -192,6 +193,9 @@ inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __s1, const wchar_t* _
inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) {
return wcsxfrm_l(__dest, __src, __n, __loc);
}
+inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __ch, wctype_t __type, __locale_t __loc) {
+ return iswctype_l(__ch, __type, __loc);
+}
inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __ch, __locale_t __loc) { return iswspace_l(__ch, __loc); }
inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __ch, __locale_t __loc) { return iswprint_l(__ch, __loc); }
inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __ch, __locale_t __loc) { return iswcntrl_l(__ch, __loc); }
diff --git a/libcxx/include/__locale_dir/support/bsd_like.h b/libcxx/include/__locale_dir/support/bsd_like.h
index da31aeaf3c58e3..b3933c71c6b26d 100644
--- a/libcxx/include/__locale_dir/support/bsd_like.h
+++ b/libcxx/include/__locale_dir/support/bsd_like.h
@@ -94,6 +94,10 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s
}
#if _LIBCPP_HAS_WIDE_CHARACTERS
+inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) {
+ return ::iswctype_l(__c, __type, __loc);
+}
+
inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return ::iswspace_l(__c, __loc); }
inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return ::iswprint_l(__c, __loc); }
diff --git a/libcxx/include/__locale_dir/support/windows.h b/libcxx/include/__locale_dir/support/windows.h
index 03d05a410fdc3b..eca0e17d94c85a 100644
--- a/libcxx/include/__locale_dir/support/windows.h
+++ b/libcxx/include/__locale_dir/support/windows.h
@@ -206,6 +206,9 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) {
+ return ::_iswctype_l(__c, __type, __loc);
+}
inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return ::_iswspace_l(__c, __loc); }
inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return ::_iswprint_l(__c, __loc); }
inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t __loc) { return ::_iswcntrl_l(__c, __loc); }
diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp
index a1e10401f0b299..599c61ca7a36da 100644
--- a/libcxx/src/locale.cpp
+++ b/libcxx/src/locale.cpp
@@ -1109,11 +1109,11 @@ ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
ctype_byname<wchar_t>::~ctype_byname() { __locale::__freelocale(__l_); }
bool ctype_byname<wchar_t>::do_is(mask m, char_type c) const {
+ wint_t ch = static_cast<wint_t>(c);
# ifdef _LIBCPP_WCTYPE_IS_MASK
- return static_cast<bool>(iswctype_l(c, m, __l_));
+ return static_cast<bool>(__locale::__iswctype(ch, m, __l_));
# else
bool result = false;
- wint_t ch = static_cast<wint_t>(c);
if ((m & space) == space)
result |= (__locale::__iswspace(ch, __l_) != 0);
if ((m & print) == print)
@@ -1179,7 +1179,7 @@ const wchar_t* ctype_byname<wchar_t>::do_is(const char_type* low, const char_typ
const wchar_t* ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const {
for (; low != high; ++low) {
# ifdef _LIBCPP_WCTYPE_IS_MASK
- if (iswctype_l(*low, m, __l_))
+ if (__locale::__iswctype(static_cast<wint_t>(*low), m, __l_))
break;
# else
wint_t ch = static_cast<wint_t>(*low);
@@ -1210,11 +1210,11 @@ const wchar_t* ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, c
const wchar_t* ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const {
for (; low != high; ++low) {
+ wint_t ch = static_cast<wint_t>(*low);
# ifdef _LIBCPP_WCTYPE_IS_MASK
- if (!iswctype_l(*low, m, __l_))
+ if (!__locale::__iswctype(ch, m, __l_))
break;
# else
- wint_t ch = static_cast<wint_t>(*low);
if ((m & space) == space && __locale::__iswspace(ch, __l_))
continue;
if ((m & print) == print && __locale::__iswprint(ch, __l_))
|
beb54d7
to
7abe9b3
Compare
This patch broke the build of the Fuchsia toolchain; would you mind reverting or quickly fixing forward?
|
@mysterymath How does Fuchsia define @petrhosek We've talked about pre-commit CI for Fuchsia more times than I can remember and for years (literally). The way Fuchsia currently interacts with libc++ for these issues is very disruptive, since errors like this are brought up at random moments and after they've been landed. To be clear, I know there's no ill intent from anyone here and it's just a result of the lack of pre-commit CI, but it's still disruptive. Fuchsia is the only platform that (for some reason) we've tolerated this for. We made a hard request for pre-commit CI to all other officially supported platforms, which they've done. Please consider this an official "hard request" to provide pre-commit CI. I can work with you on setting it up, and once that's done we'll be happy to list Fuchsia as supported on https://libcxx.llvm.org and address issues before they hit |
We get ours from |
(The Fuchsia problem also blocks updating libc++ in Chromium.) |
What issue are you running into? I'd expect the usual Linux path doesn't suffer from the problem reported by Fuchsia or we would have seen it in our CI? |
Does that fix your build? Edit: See also #122489 for the long-term way we want to define the locale base API for Fuchsia. |
We build Chromium for Fuchsia. https://ci.chromium.org/ui/p/chromium/builders/try/fuchsia-x64-cast-receiver-rel/892111/overview
I'll try restarting the autoroller now that #122484 is in. |
Looks like our Fuchsia bots are happy again, thanks! |
No description provided.