[libcxx-commits] [libcxx] [libc++] Rename locale_t to __libcpp_locale_t (PR #113615)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 24 13:14:14 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Louis Dionne (ldionne)
<details>
<summary>Changes</summary>
This is a step towards refactoring our amazingly complicated interface with the system's localization library. Instead of using locale_t and just assuming that the system provides it, use a proper libc++ internal name (and introduce that name properly).
---
Patch is 48.32 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/113615.diff
22 Files Affected:
- (modified) libcxx/include/CMakeLists.txt (+2)
- (modified) libcxx/include/__locale (+5-5)
- (modified) libcxx/include/__locale_dir/locale_base_api.h (+7-6)
- (modified) libcxx/include/__locale_dir/locale_base_api/android.h (+4-2)
- (added) libcxx/include/__locale_dir/locale_base_api/apple.h (+17)
- (modified) libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h (+19-16)
- (added) libcxx/include/__locale_dir/locale_base_api/freebsd.h (+17)
- (modified) libcxx/include/__locale_dir/locale_base_api/fuchsia.h (+2)
- (modified) libcxx/include/__locale_dir/locale_base_api/ibm.h (+13-10)
- (modified) libcxx/include/__locale_dir/locale_base_api/locale_guard.h (+4-4)
- (modified) libcxx/include/__locale_dir/locale_base_api/musl.h (+5-2)
- (modified) libcxx/include/__locale_dir/locale_base_api/openbsd.h (+2)
- (modified) libcxx/include/__locale_dir/locale_base_api/win32.h (+53-39)
- (modified) libcxx/include/__support/ibm/locale_mgmt_zos.h (+4-4)
- (modified) libcxx/include/__support/xlocale/__nop_locale_mgmt.h (+5-5)
- (modified) libcxx/include/__support/xlocale/__posix_l_fallback.h (+32-32)
- (modified) libcxx/include/__support/xlocale/__strtonum_fallback.h (+6-5)
- (modified) libcxx/include/locale (+3-3)
- (modified) libcxx/include/module.modulemap (+2)
- (modified) libcxx/src/locale.cpp (+6-6)
- (modified) libcxx/src/support/ibm/xlocale_zos.cpp (+9-9)
- (modified) libcxx/src/support/win32/locale_win32.cpp (+19-18)
``````````diff
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 86d2fc2c2c679d..fd7d796b8f7562 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -492,8 +492,10 @@ set(files
__locale
__locale_dir/locale_base_api.h
__locale_dir/locale_base_api/android.h
+ __locale_dir/locale_base_api/apple.h
__locale_dir/locale_base_api/bsd_locale_defaults.h
__locale_dir/locale_base_api/bsd_locale_fallbacks.h
+ __locale_dir/locale_base_api/freebsd.h
__locale_dir/locale_base_api/fuchsia.h
__locale_dir/locale_base_api/ibm.h
__locale_dir/locale_base_api/locale_guard.h
diff --git a/libcxx/include/__locale b/libcxx/include/__locale
index 5fb0c19903cd5b..ec9707af0524cc 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -247,7 +247,7 @@ class _LIBCPP_TEMPLATE_VIS collate_byname;
template <>
class _LIBCPP_EXPORTED_FROM_ABI collate_byname<char> : public collate<char> {
- locale_t __l_;
+ __libcpp_locale_t __l_;
public:
typedef char char_type;
@@ -266,7 +266,7 @@ protected:
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t> : public collate<wchar_t> {
- locale_t __l_;
+ __libcpp_locale_t __l_;
public:
typedef wchar_t char_type;
@@ -616,7 +616,7 @@ class _LIBCPP_TEMPLATE_VIS ctype_byname;
template <>
class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char> : public ctype<char> {
- locale_t __l_;
+ __libcpp_locale_t __l_;
public:
explicit ctype_byname(const char*, size_t = 0);
@@ -633,7 +633,7 @@ protected:
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t> : public ctype<wchar_t> {
- locale_t __l_;
+ __libcpp_locale_t __l_;
public:
explicit ctype_byname(const char*, size_t = 0);
@@ -824,7 +824,7 @@ protected:
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t> : public locale::facet, public codecvt_base {
- locale_t __l_;
+ __libcpp_locale_t __l_;
public:
typedef wchar_t intern_type;
diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h
index 8c000c558c5279..394b546b86d45d 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -9,14 +9,14 @@
#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
+#include <__config>
+
#if defined(_LIBCPP_MSVCRT_LIKE)
# include <__locale_dir/locale_base_api/win32.h>
#elif defined(_AIX) || defined(__MVS__)
# include <__locale_dir/locale_base_api/ibm.h>
#elif defined(__ANDROID__)
# include <__locale_dir/locale_base_api/android.h>
-#elif defined(__sun__)
-# include <__locale_dir/locale_base_api/solaris.h>
#elif defined(_NEWLIB_VERSION)
# include <__locale_dir/locale_base_api/newlib.h>
#elif defined(__OpenBSD__)
@@ -25,8 +25,10 @@
# include <__locale_dir/locale_base_api/fuchsia.h>
#elif defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
# include <__locale_dir/locale_base_api/musl.h>
-#elif defined(__APPLE__) || defined(__FreeBSD__)
-# include <xlocale.h>
+#elif defined(__APPLE__)
+# include <__locale_dir/locale_base_api/apple.h>
+#elif defined(__FreeBSD__)
+# include <__locale_dir/locale_base_api/freebsd.h>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -36,8 +38,7 @@
/*
The platform-specific headers have to provide the following interface:
-// TODO: rename this to __libcpp_locale_t
-using locale_t = implementation-defined;
+using __libcpp_locale_t = implementation-defined;
implementation-defined __libcpp_mb_cur_max_l(locale_t);
wint_t __libcpp_btowc_l(int, locale_t);
diff --git a/libcxx/include/__locale_dir/locale_base_api/android.h b/libcxx/include/__locale_dir/locale_base_api/android.h
index 9965d8bbf6a2ec..9d90bb4279098e 100644
--- a/libcxx/include/__locale_dir/locale_base_api/android.h
+++ b/libcxx/include/__locale_dir/locale_base_api/android.h
@@ -34,11 +34,11 @@ extern "C" {
# include <__support/xlocale/__strtonum_fallback.h>
# elif __ANDROID_API__ < 26
-inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, __libcpp_locale_t) {
return ::strtof(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, __libcpp_locale_t) {
return ::strtod(__nptr, __endptr);
}
@@ -47,4 +47,6 @@ inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr
# endif // __NDK_MAJOR__ <= 16
#endif // __has_include(<android/ndk-version.h>)
+using __libcpp_locale_t = ::locale_t;
+
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H
diff --git a/libcxx/include/__locale_dir/locale_base_api/apple.h b/libcxx/include/__locale_dir/locale_base_api/apple.h
new file mode 100644
index 00000000000000..a76e050c23224e
--- /dev/null
+++ b/libcxx/include/__locale_dir/locale_base_api/apple.h
@@ -0,0 +1,17 @@
+// -*- C++ -*-
+//===-----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_APPLE_H
+#define _LIBCPP___LOCALE_LOCALE_BASE_API_APPLE_H
+
+#include <xlocale.h>
+
+using __libcpp_locale_t = locale_t;
+
+#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_APPLE_H
diff --git a/libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h b/libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h
index 76b94287cd6cc8..dd52322018dcd7 100644
--- a/libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h
+++ b/libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h
@@ -28,71 +28,74 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l) {
+inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(__libcpp_locale_t __l) {
__libcpp_locale_guard __current(__l);
return MB_CUR_MAX;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-inline _LIBCPP_HIDE_FROM_ABI wint_t __libcpp_btowc_l(int __c, locale_t __l) {
+inline _LIBCPP_HIDE_FROM_ABI wint_t __libcpp_btowc_l(int __c, __libcpp_locale_t __l) {
__libcpp_locale_guard __current(__l);
return btowc(__c);
}
-inline _LIBCPP_HIDE_FROM_ABI int __libcpp_wctob_l(wint_t __c, locale_t __l) {
+inline _LIBCPP_HIDE_FROM_ABI int __libcpp_wctob_l(wint_t __c, __libcpp_locale_t __l) {
__libcpp_locale_guard __current(__l);
return wctob(__c);
}
-inline _LIBCPP_HIDE_FROM_ABI size_t
-__libcpp_wcsnrtombs_l(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, locale_t __l) {
+inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_wcsnrtombs_l(
+ char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __libcpp_locale_t __l) {
__libcpp_locale_guard __current(__l);
return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
}
-inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_wcrtomb_l(char* __s, wchar_t __wc, mbstate_t* __ps, locale_t __l) {
+inline _LIBCPP_HIDE_FROM_ABI size_t
+__libcpp_wcrtomb_l(char* __s, wchar_t __wc, mbstate_t* __ps, __libcpp_locale_t __l) {
__libcpp_locale_guard __current(__l);
return wcrtomb(__s, __wc, __ps);
}
-inline _LIBCPP_HIDE_FROM_ABI size_t
-__libcpp_mbsnrtowcs_l(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, locale_t __l) {
+inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_mbsnrtowcs_l(
+ wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __libcpp_locale_t __l) {
__libcpp_locale_guard __current(__l);
return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
}
inline _LIBCPP_HIDE_FROM_ABI size_t
-__libcpp_mbrtowc_l(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, locale_t __l) {
+__libcpp_mbrtowc_l(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __libcpp_locale_t __l) {
__libcpp_locale_guard __current(__l);
return mbrtowc(__pwc, __s, __n, __ps);
}
-inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mbtowc_l(wchar_t* __pwc, const char* __pmb, size_t __max, locale_t __l) {
+inline _LIBCPP_HIDE_FROM_ABI int
+__libcpp_mbtowc_l(wchar_t* __pwc, const char* __pmb, size_t __max, __libcpp_locale_t __l) {
__libcpp_locale_guard __current(__l);
return mbtowc(__pwc, __pmb, __max);
}
-inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_mbrlen_l(const char* __s, size_t __n, mbstate_t* __ps, locale_t __l) {
+inline _LIBCPP_HIDE_FROM_ABI size_t
+__libcpp_mbrlen_l(const char* __s, size_t __n, mbstate_t* __ps, __libcpp_locale_t __l) {
__libcpp_locale_guard __current(__l);
return mbrlen(__s, __n, __ps);
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
-inline _LIBCPP_HIDE_FROM_ABI lconv* __libcpp_localeconv_l(locale_t __l) {
+inline _LIBCPP_HIDE_FROM_ABI lconv* __libcpp_localeconv_l(__libcpp_locale_t __l) {
__libcpp_locale_guard __current(__l);
return localeconv();
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
inline _LIBCPP_HIDE_FROM_ABI size_t
-__libcpp_mbsrtowcs_l(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, locale_t __l) {
+__libcpp_mbsrtowcs_l(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __libcpp_locale_t __l) {
__libcpp_locale_guard __current(__l);
return mbsrtowcs(__dest, __src, __len, __ps);
}
#endif
inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __libcpp_snprintf_l(
- char* __s, size_t __n, locale_t __l, const char* __format, ...) {
+ char* __s, size_t __n, __libcpp_locale_t __l, const char* __format, ...) {
va_list __va;
va_start(__va, __format);
__libcpp_locale_guard __current(__l);
@@ -102,7 +105,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __libcpp_snprintf_l(
}
inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __libcpp_asprintf_l(
- char** __s, locale_t __l, const char* __format, ...) {
+ char** __s, __libcpp_locale_t __l, const char* __format, ...) {
va_list __va;
va_start(__va, __format);
__libcpp_locale_guard __current(__l);
@@ -112,7 +115,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __libcpp_asprintf_l(
}
inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __libcpp_sscanf_l(
- const char* __s, locale_t __l, const char* __format, ...) {
+ const char* __s, __libcpp_locale_t __l, const char* __format, ...) {
va_list __va;
va_start(__va, __format);
__libcpp_locale_guard __current(__l);
diff --git a/libcxx/include/__locale_dir/locale_base_api/freebsd.h b/libcxx/include/__locale_dir/locale_base_api/freebsd.h
new file mode 100644
index 00000000000000..2a1cf177212578
--- /dev/null
+++ b/libcxx/include/__locale_dir/locale_base_api/freebsd.h
@@ -0,0 +1,17 @@
+// -*- C++ -*-
+//===-----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_FREEBSD_H
+#define _LIBCPP___LOCALE_LOCALE_BASE_API_FREEBSD_H
+
+#include <xlocale.h>
+
+using __libcpp_locale_t = locale_t;
+
+#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_FREEBSD_H
diff --git a/libcxx/include/__locale_dir/locale_base_api/fuchsia.h b/libcxx/include/__locale_dir/locale_base_api/fuchsia.h
index 4c3440f981c6d0..bbb614ff1e0e78 100644
--- a/libcxx/include/__locale_dir/locale_base_api/fuchsia.h
+++ b/libcxx/include/__locale_dir/locale_base_api/fuchsia.h
@@ -15,4 +15,6 @@
#include <cstdlib>
#include <cwchar>
+using __libcpp_locale_t = locale_t;
+
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H
diff --git a/libcxx/include/__locale_dir/locale_base_api/ibm.h b/libcxx/include/__locale_dir/locale_base_api/ibm.h
index fa3bc1c3633f5d..8f8a688968c5c9 100644
--- a/libcxx/include/__locale_dir/locale_base_api/ibm.h
+++ b/libcxx/include/__locale_dir/locale_base_api/ibm.h
@@ -26,12 +26,14 @@
# include <__support/xlocale/__posix_l_fallback.h>
#endif // defined(__MVS__)
+using __libcpp_locale_t = locale_t;
+
namespace {
struct __setAndRestore {
- explicit __setAndRestore(locale_t locale) {
- if (locale == (locale_t)0) {
- __cloc = newlocale(LC_ALL_MASK, "C", /* base */ (locale_t)0);
+ explicit __setAndRestore(__libcpp_locale_t locale) {
+ if (locale == (__libcpp_locale_t)0) {
+ __cloc = newlocale(LC_ALL_MASK, "C", /* base */ (__libcpp_locale_t)0);
__stored = uselocale(__cloc);
} else {
__stored = uselocale(locale);
@@ -45,36 +47,37 @@ struct __setAndRestore {
}
private:
- locale_t __stored = (locale_t)0;
- locale_t __cloc = (locale_t)0;
+ __libcpp_locale_t __stored = (__libcpp_locale_t)0;
+ __libcpp_locale_t __cloc = (__libcpp_locale_t)0;
};
} // namespace
// The following are not POSIX routines. These are quick-and-dirty hacks
// to make things pretend to work
-inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
+inline _LIBCPP_HIDE_FROM_ABI long long
+strtoll_l(const char* __nptr, char** __endptr, int __base, __libcpp_locale_t locale) {
__setAndRestore __newloc(locale);
return ::strtoll(__nptr, __endptr, __base);
}
-inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t locale) {
+inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, __libcpp_locale_t locale) {
__setAndRestore __newloc(locale);
return ::strtod(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t locale) {
+inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, __libcpp_locale_t locale) {
__setAndRestore __newloc(locale);
return ::strtof(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __endptr, locale_t locale) {
+inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __endptr, __libcpp_locale_t locale) {
__setAndRestore __newloc(locale);
return ::strtold(__nptr, __endptr);
}
inline _LIBCPP_HIDE_FROM_ABI unsigned long long
-strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
+strtoull_l(const char* __nptr, char** __endptr, int __base, __libcpp_locale_t locale) {
__setAndRestore __newloc(locale);
return ::strtoull(__nptr, __endptr, __base);
}
diff --git a/libcxx/include/__locale_dir/locale_base_api/locale_guard.h b/libcxx/include/__locale_dir/locale_base_api/locale_guard.h
index 2baacb51cd0655..80736c3fd44155 100644
--- a/libcxx/include/__locale_dir/locale_base_api/locale_guard.h
+++ b/libcxx/include/__locale_dir/locale_base_api/locale_guard.h
@@ -10,7 +10,7 @@
#define _LIBCPP___LOCALE_LOCALE_BASE_API_LOCALE_GUARD_H
#include <__config>
-#include <__locale> // for locale_t
+#include <__locale> // for __libcpp_locale_t
#include <clocale>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -21,21 +21,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if !defined(_LIBCPP_LOCALE__L_EXTENSIONS)
struct __libcpp_locale_guard {
- _LIBCPP_HIDE_FROM_ABI __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {}
+ _LIBCPP_HIDE_FROM_ABI __libcpp_locale_guard(__libcpp_locale_t& __loc) : __old_loc_(uselocale(__loc)) {}
_LIBCPP_HIDE_FROM_ABI ~__libcpp_locale_guard() {
if (__old_loc_)
uselocale(__old_loc_);
}
- locale_t __old_loc_;
+ __libcpp_locale_t __old_loc_;
__libcpp_locale_guard(__libcpp_locale_guard const&) = delete;
__libcpp_locale_guard& operator=(__libcpp_locale_guard const&) = delete;
};
#elif defined(_LIBCPP_MSVCRT_LIKE)
struct __libcpp_locale_guard {
- __libcpp_locale_guard(locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) {
+ __libcpp_locale_guard(__libcpp_locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) {
// Setting the locale can be expensive even when the locale given is
// already the current locale, so do an explicit check to see if the
// current locale is already the one we want.
diff --git a/libcxx/include/__locale_dir/locale_base_api/musl.h b/libcxx/include/__locale_dir/locale_base_api/musl.h
index bf7b849d586342..e19e59177b452a 100644
--- a/libcxx/include/__locale_dir/locale_base_api/musl.h
+++ b/libcxx/include/__locale_dir/locale_base_api/musl.h
@@ -20,11 +20,14 @@
#include <cstdlib>
#include <cwchar>
-inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) {
+using __libcpp_locale_t = locale_t;
+
+inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, __libcpp_locale_t) {
return ::strtoll(__nptr, __endptr, __base);
}
-inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI unsigned long long
+strtoull_l(const char* __nptr, char** __endptr, int __base, __libcpp_locale_t) {
return ::strtoull(__nptr, __endptr, __base);
}
diff --git a/libcxx/include/__locale_dir/locale_base_api/openbsd.h b/libcxx/include/__locale_dir/locale_base_api/openbsd.h
index 0c05d6a0f78874..c4d8ac818649c1 100644
--- a/libcxx/include/__locale_dir/locale_base_api/openbsd.h
+++ b/libcxx/include/__locale_dir/locale_base_api/openbsd.h
@@ -16,4 +16,6 @@
#include <ctype.h>
#include <cwctype>
+using __libcpp_locale_t = locale_t;
+
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H
diff --git a/libcxx/include/__locale_dir/locale_base_api/win32.h b/libcxx/include/__locale_dir/locale_base_api/win32.h
index f66baffb692045..df978259878ece 100644
--- a/libcxx/include/__locale_dir/locale_base_api/win32.h
+++ b/libcxx/include/__locale_dir/locale_base_api/win32.h
@@ -88,50 +88,57 @@ class __lconv_storage {
std::string __negative_sign_;
};
-class locale_t {
+class __libcpp_locale_t {
public:
- locale_t() : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
- locale_t(std::nullptr_t) : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
- locale_t(_locale_t __xlocale, const char* __xlocale_str)
+ __libcpp_locale_t() : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
+ __libcpp_locale_t(std::nullptr_t) : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
+ __libcpp_locale_t(_locale_t __xlocale, const char* __xlocale_str)
: __locale_(__xlocale), __locale_str_(__xlocale_str), __lc_(nullptr) {}
- locale_t(const locale_t& __l) : __locale_(__l.__locale_), __locale_str_(__l.__locale_str_), __lc_(nullptr) {}
+ __libcpp_locale_t(const __libcpp_locale_t& __l)
+ : __locale_(__l.__locale_), __locale_str_(__l.__locale_str_), __lc_(nullptr) {}
- ~locale_t() { delete __lc_; }
+ ~__libcpp_locale_t() { delete __lc_; }
- locale_t& operator=(const locale_t& __l) {
+ __libcpp_locale_t& operator=(const __libcpp_locale_t& __l) {
__locale_ = __l.__locale_;
__locale_str_ = __l.__locale_str_;
// __lc_ not copied
return *this;
}
- friend bool operator==(const locale_t& __left, const locale_t& __right) {
+ friend bool operator==(const __libcpp_locale_t& __left, const __libcpp_locale_t& __right) {
return __left.__locale_ == __right.__locale_;
}
- friend bool operator==(const locale_t& __left, int __right) { return __left.__locale_ == nullptr && __right == 0; }
+ friend bool operator==(const __libcpp_locale_t& __left, int __right) {
+ return __left.__locale_ == nullptr && __right == 0;
+ }
- friend bool operator==(const locale_t& __left, long long __right) {
+ friend bool operator==(const __libcpp_locale_t& __left, long long __right) {
return __left.__locale_ == nullptr && __right == 0;
}
- friend bool operator==(const locale_t& __left, std::nullptr_t) { return __left.__locale_ == nullptr; }
+ friend ...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/113615
More information about the libcxx-commits
mailing list