[libcxx-commits] [libcxx] fd5a2bf - [libc++] Add missing includes to xlocale helpers

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 25 11:06:29 PDT 2022


Author: Louis Dionne
Date: 2022-10-25T14:06:17-04:00
New Revision: fd5a2bfaadb5336c2f115a875c12c26e9daa96df

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

LOG: [libc++] Add missing includes to xlocale helpers

Also, make sure those are compatible with _LIBCPP_HAS_NO_WIDE_CHARACTERS.

Differential Revision: https://reviews.llvm.org/D136682

Added: 
    

Modified: 
    libcxx/include/__support/xlocale/__nop_locale_mgmt.h
    libcxx/include/__support/xlocale/__posix_l_fallback.h
    libcxx/include/__support/xlocale/__strtonum_fallback.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__support/xlocale/__nop_locale_mgmt.h b/libcxx/include/__support/xlocale/__nop_locale_mgmt.h
index 3d26183fafedf..e005d8a0748d8 100644
--- a/libcxx/include/__support/xlocale/__nop_locale_mgmt.h
+++ b/libcxx/include/__support/xlocale/__nop_locale_mgmt.h
@@ -10,6 +10,8 @@
 #ifndef _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
 #define _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
 
+#include <__config>
+
 #ifdef __cplusplus
 extern "C" {
 #endif

diff  --git a/libcxx/include/__support/xlocale/__posix_l_fallback.h b/libcxx/include/__support/xlocale/__posix_l_fallback.h
index 294149eb8ff9c..36d5adceaa918 100644
--- a/libcxx/include/__support/xlocale/__posix_l_fallback.h
+++ b/libcxx/include/__support/xlocale/__posix_l_fallback.h
@@ -15,6 +15,14 @@
 #ifndef _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
 #define _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
 
+#include <__config>
+#include <ctype.h>
+#include <time.h>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#  include <wctype.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -67,6 +75,15 @@ inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) {
   return ::isxdigit(__c);
 }
 
+inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) {
+  return ::toupper(__c);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) {
+  return ::tolower(__c);
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
 inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) {
   return ::iswalnum(__c);
 }
@@ -115,14 +132,6 @@ inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) {
   return ::iswxdigit(__c);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) {
-  return ::toupper(__c);
-}
-
-inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) {
-  return ::tolower(__c);
-}
-
 inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {
   return ::towupper(__c);
 }
@@ -130,6 +139,7 @@ inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {
 inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) {
   return ::towlower(__c);
 }
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
 
 inline _LIBCPP_HIDE_FROM_ABI int
 strcoll_l(const char *__s1, const char *__s2, locale_t) {
@@ -147,6 +157,7 @@ strftime_l(char *__s, size_t __max, const char *__format, const struct tm *__tm,
   return ::strftime(__s, __max, __format, __tm);
 }
 
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
 inline _LIBCPP_HIDE_FROM_ABI int
 wcscoll_l(const wchar_t *__ws1, const wchar_t *__ws2, locale_t) {
   return ::wcscoll(__ws1, __ws2);
@@ -156,6 +167,7 @@ inline _LIBCPP_HIDE_FROM_ABI size_t
 wcsxfrm_l(wchar_t *__dest, const wchar_t *__src, size_t __n, locale_t) {
   return ::wcsxfrm(__dest, __src, __n);
 }
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
 
 #ifdef __cplusplus
 }

diff  --git a/libcxx/include/__support/xlocale/__strtonum_fallback.h b/libcxx/include/__support/xlocale/__strtonum_fallback.h
index 19780909b2c5b..28a0dbf40611f 100644
--- a/libcxx/include/__support/xlocale/__strtonum_fallback.h
+++ b/libcxx/include/__support/xlocale/__strtonum_fallback.h
@@ -15,6 +15,13 @@
 #ifndef _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
 #define _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
 
+#include <__config>
+#include <stdlib.h>
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#  include <wchar.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -44,6 +51,7 @@ strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {
   return ::strtoull(__nptr, __endptr, __base);
 }
 
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
 inline _LIBCPP_HIDE_FROM_ABI long long
 wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
   return ::wcstoll(__nptr, __endptr, __base);
@@ -58,6 +66,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double
 wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
   return ::wcstold(__nptr, __endptr);
 }
+#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
 
 #ifdef __cplusplus
 }


        


More information about the libcxx-commits mailing list