-
Notifications
You must be signed in to change notification settings - Fork 13.9k
[libc++] Disable isw*_l functions on old MSVCRT (< 0x800) #144273
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
Open
hpoussin
wants to merge
1
commit into
llvm:main
Choose a base branch
from
hpoussin:libcxx-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+84
−2
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This fixes linking on platforms older than Windows 10, which don't have these functions. In that case, implement char functions with specific locale by calling the same function without locale (which will use the ambiant one).
@llvm/pr-subscribers-libcxx Author: Hervé Poussineau (hpoussin) ChangesThis fixes linking on platforms older than Windows 10, which don't have these functions. In that case, implement char functions with specific locale by calling the same function without locale (which will use the ambiant one). Full diff: https://github.com/llvm/llvm-project/pull/144273.diff 3 Files Affected:
diff --git a/libcxx/include/__cxx03/__config b/libcxx/include/__cxx03/__config
index ef47327d96355..0839d19ad5ab4 100644
--- a/libcxx/include/__cxx03/__config
+++ b/libcxx/include/__cxx03/__config
@@ -595,7 +595,9 @@ typedef __char32_t char32_t;
// clang-format on
# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__)
-# define _LIBCPP_LOCALE__L_EXTENSIONS 1
+# if !defined(__MSVCRT_VERSION__) || __MSVCRT_VERSION__ >= 0x800
+# define _LIBCPP_LOCALE__L_EXTENSIONS 1
+# endif
# endif
# ifdef __FreeBSD__
diff --git a/libcxx/include/__locale_dir/support/windows.h b/libcxx/include/__locale_dir/support/windows.h
index 0d3089c150081..6a2ffd897bb7a 100644
--- a/libcxx/include/__locale_dir/support/windows.h
+++ b/libcxx/include/__locale_dir/support/windows.h
@@ -221,6 +221,23 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s
}
# if _LIBCPP_HAS_WIDE_CHARACTERS
+# if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
+_LIBCPP_EXPORTED_FROM_ABI int __iswctype(wint_t c, wctype_t __type, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI int __iswspace(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI int __iswprint(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI int __iswcntrl(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI int __iswupper(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI int __iswlower(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI int __iswalpha(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI int __iswblank(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI int __iswdigit(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI int __iswpunct(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI int __iswxdigit(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI wint_t __towupper(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI wint_t __towlower(wint_t c, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI int __wcscoll(const wchar_t* ws1, const wchar_t* ws2, __locale_t loc);
+_LIBCPP_EXPORTED_FROM_ABI size_t __wcsxfrm(wchar_t* dest, const wchar_t* src, size_t n, __locale_t loc);
+# else
inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) {
return ::_iswctype_l(__c, __type, __loc);
}
@@ -245,7 +262,8 @@ inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, 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);
}
-# endif // _LIBCPP_HAS_WIDE_CHARACTERS
+# endif // defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
+# endif // _LIBCPP_HAS_WIDE_CHARACTERS
# if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
_LIBCPP_EXPORTED_FROM_ABI size_t __strftime(char*, size_t, const char*, const struct tm*, __locale_t);
diff --git a/libcxx/src/support/win32/locale_win32.cpp b/libcxx/src/support/win32/locale_win32.cpp
index 24402e818d95d..f8a963faa572f 100644
--- a/libcxx/src/support/win32/locale_win32.cpp
+++ b/libcxx/src/support/win32/locale_win32.cpp
@@ -57,6 +57,68 @@ size_t __strftime(char* ret, size_t n, const char* format, const struct tm* tm,
__locale_guard __current(loc);
return std::strftime(ret, n, format, tm);
}
+# if _LIBCPP_HAS_WIDE_CHARACTERS
+int __iswctype(wint_t c, wctype_t type, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::iswctype(c, type);
+}
+int __iswspace(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::iswspace(c);
+}
+int __iswprint(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::iswprint(c);
+}
+int __iswcntrl(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::iswcntrl(c);
+}
+int __iswupper(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::iswupper(c);
+}
+int __iswlower(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::iswlower(c);
+}
+int __iswalpha(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::iswalpha(c);
+}
+int __iswblank(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::iswblank(c);
+}
+int __iswdigit(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::iswdigit(c);
+}
+int __iswpunct(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::iswpunct(c);
+}
+int __iswxdigit(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::iswxdigit(c);
+}
+wint_t __towupper(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::towupper(c);
+}
+wint_t __towlower(wint_t c, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::towlower(c);
+}
+int __wcscoll(const wchar_t* ws1, const wchar_t* ws2, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::wcscoll(ws1, ws2);
+}
+size_t __wcsxfrm(wchar_t* dest, const wchar_t* src, size_t n, __locale_t loc) {
+ __locale_guard __current(loc);
+ return ::wcsxfrm(dest, src, n);
+}
+# endif
#endif
//
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes linking on platforms older than Windows 10, which don't have these functions.
In that case, implement char functions with specific locale by calling the same function without locale (which will use the ambiant one).