[libcxx-commits] [libcxx] [libcxx][locale] Refactor strtonum functions using __str_to_float_c_locale<FloatT> (PR #222081)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 23 21:00:08 PDT 2026
https://github.com/Himadhith updated https://github.com/llvm/llvm-project/pull/222081
>From ca2c9414d069e26f7508941be676adf20c41ba72 Mon Sep 17 00:00:00 2001
From: himadhith <himadhith.v at ibm.com>
Date: Tue, 8 Sep 2026 22:51:57 +0530
Subject: [PATCH 1/8] [libcxx][locale] Refactor strtonum functions using
__str_to_float_c_locale<FloatT>
---
libcxx/include/__locale_dir/locale_base_api.h | 20 ++++++---
libcxx/include/__locale_dir/num.h | 6 +--
libcxx/include/__locale_dir/support/aix.h | 44 +++++++------------
.../include/__locale_dir/support/bsd_like.h | 12 +++--
libcxx/include/__locale_dir/support/linux.h | 12 +++--
libcxx/include/__locale_dir/support/newlib.h | 12 +++--
.../__locale_dir/support/no_locale/strtonum.h | 12 +++--
libcxx/include/__locale_dir/support/openbsd.h | 21 +++++++--
libcxx/include/__locale_dir/support/windows.h | 25 ++++++++---
libcxx/src/support/win32/locale_win32.cpp | 6 ++-
10 files changed, 110 insertions(+), 60 deletions(-)
diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h
index 14ff9d8a45b56..92ff3abbfc240 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -54,9 +54,8 @@
// ------------------
// namespace __locale {
// // required by the headers
-// float __strtof(const char*, char**, __locale_t);
-// double __strtod(const char*, char**, __locale_t);
-// long double __strtold(const char*, char**, __locale_t);
+// template <class FloatT>
+// FloatT __str_to_float_c_locale(const char*, char**, __locale_t);
// }
//
// Character manipulation functions
@@ -185,15 +184,24 @@ inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { return
//
// Strtonum functions
//
-inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <class _FloatT>
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
+
+template <>
+inline _LIBCPP_HIDE_FROM_ABI float
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
return strtof_l(__nptr, __endptr, __loc);
}
-inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI double
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return strtod_l(__nptr, __endptr, __loc);
}
-inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI long double
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return strtold_l(__nptr, __endptr, __loc);
}
diff --git a/libcxx/include/__locale_dir/num.h b/libcxx/include/__locale_dir/num.h
index e924c88d0955c..8cc0b544f25b0 100644
--- a/libcxx/include/__locale_dir/num.h
+++ b/libcxx/include/__locale_dir/num.h
@@ -306,17 +306,17 @@ _LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2);
template <>
inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) {
- return __locale::__strtof(__a, __p2, __locale::__get_c_locale());
+ return __locale::__str_to_float_c_locale<float>(__a, __p2, __locale::__get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) {
- return __locale::__strtod(__a, __p2, __locale::__get_c_locale());
+ return __locale::__str_to_float_c_locale<double>(__a, __p2, __locale::__get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) {
- return __locale::__strtold(__a, __p2, __locale::__get_c_locale());
+ return __locale::__str_to_float_c_locale<long double>(__a, __p2, __locale::__get_c_locale());
}
template <class _Tp>
diff --git a/libcxx/include/__locale_dir/support/aix.h b/libcxx/include/__locale_dir/support/aix.h
index d5c2b395b1a37..15de092b9cc6e 100644
--- a/libcxx/include/__locale_dir/support/aix.h
+++ b/libcxx/include/__locale_dir/support/aix.h
@@ -86,44 +86,30 @@ inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc)
}
#endif // _LIBCPP_BUILDING_LIBRARY
-// The following structure is a quick-and-dirty workaround for routines that AIX
-// does not provide in the "_l" (locale-aware) variants.
-struct __setAndRestore {
- explicit __setAndRestore(locale_t locale) {
- if (locale == (locale_t)0) {
- __cloc = newlocale(LC_ALL_MASK, "C", /* base */ (locale_t)0);
- __stored = uselocale(__cloc);
- } else {
- __stored = uselocale(locale);
- }
- }
-
- ~__setAndRestore() {
- uselocale(__stored);
- if (__cloc)
- freelocale(__cloc);
- }
-
-private:
- locale_t __stored = (locale_t)0;
- locale_t __cloc = (locale_t)0;
-};
-
//
// Strtonum functions
//
-inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
- __setAndRestore __newloc(__loc);
+template <class _FloatT>
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
+
+template <>
+inline _LIBCPP_HIDE_FROM_ABI float
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
+ __locale_guard __current(__loc);
return ::strtof(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) {
- __setAndRestore __newloc(__loc);
+template <>
+inline _LIBCPP_HIDE_FROM_ABI double
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
+ __locale_guard __current(__loc);
return ::strtod(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) {
- __setAndRestore __newloc(__loc);
+template <>
+inline _LIBCPP_HIDE_FROM_ABI long double
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
+ __locale_guard __current(__loc);
return ::strtold(__nptr, __endptr);
}
diff --git a/libcxx/include/__locale_dir/support/bsd_like.h b/libcxx/include/__locale_dir/support/bsd_like.h
index ebe3f726e34ff..1164fcc454d0a 100644
--- a/libcxx/include/__locale_dir/support/bsd_like.h
+++ b/libcxx/include/__locale_dir/support/bsd_like.h
@@ -78,15 +78,21 @@ inline __locale_t __get_c_locale() {
//
// Strtonum functions
//
-inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <class _FloatT>
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
+
+template <>
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtof_l(__nptr, __endptr, __loc);
}
-inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtod_l(__nptr, __endptr, __loc);
}
-inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtold_l(__nptr, __endptr, __loc);
}
diff --git a/libcxx/include/__locale_dir/support/linux.h b/libcxx/include/__locale_dir/support/linux.h
index 8d20bbe9180c4..48e5200c9f3ee 100644
--- a/libcxx/include/__locale_dir/support/linux.h
+++ b/libcxx/include/__locale_dir/support/linux.h
@@ -85,15 +85,21 @@ inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) {
//
// Strtonum functions
//
-inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <class _FloatT>
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
+
+template <>
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtof_l(__nptr, __endptr, __loc);
}
-inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtod_l(__nptr, __endptr, __loc);
}
-inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtold_l(__nptr, __endptr, __loc);
}
diff --git a/libcxx/include/__locale_dir/support/newlib.h b/libcxx/include/__locale_dir/support/newlib.h
index daf60e8a48ea2..87297401fce88 100644
--- a/libcxx/include/__locale_dir/support/newlib.h
+++ b/libcxx/include/__locale_dir/support/newlib.h
@@ -86,15 +86,21 @@ inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc)
//
// Strtonum functions
//
-inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <class _FloatT>
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
+
+template<>
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtof_l(__nptr, __endptr, __loc);
}
-inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) {
+template<>
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtod_l(__nptr, __endptr, __loc);
}
-inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) {
+template<>
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtold_l(__nptr, __endptr, __loc);
}
diff --git a/libcxx/include/__locale_dir/support/no_locale/strtonum.h b/libcxx/include/__locale_dir/support/no_locale/strtonum.h
index 59544e10e4a4c..af7801bf6ca0b 100644
--- a/libcxx/include/__locale_dir/support/no_locale/strtonum.h
+++ b/libcxx/include/__locale_dir/support/no_locale/strtonum.h
@@ -22,15 +22,21 @@ namespace __locale {
//
// Strtonum functions
//
-inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t) {
+template <class _FloatT>
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t);
+
+template <>
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t) {
return std::strtof(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t) {
return std::strtod(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t) {
return std::strtold(__nptr, __endptr);
}
diff --git a/libcxx/include/__locale_dir/support/openbsd.h b/libcxx/include/__locale_dir/support/openbsd.h
index 85f008f8a17f0..cd4d0d3d657cf 100644
--- a/libcxx/include/__locale_dir/support/openbsd.h
+++ b/libcxx/include/__locale_dir/support/openbsd.h
@@ -79,11 +79,26 @@ inline __lconv_t* __localeconv(__locale_t& __loc) {
//
// Strtonum functions
//
-inline float __strtof(const char* __nptr, char** __endptr, __locale_t) { return ::strtof(__nptr, __endptr); }
+template <class _FloatT>
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t);
-inline double __strtod(const char* __nptr, char** __endptr, __locale_t) { return ::strtod(__nptr, __endptr); }
+template <>
+inline _LIBCPP_HIDE_FROM_ABI float
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t) {
+ return ::strtof(__nptr, __endptr);
+}
+
+template <>
+inline _LIBCPP_HIDE_FROM_ABI double
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t) {
+ return ::strtod(__nptr, __endptr);
+}
-inline long double __strtold(const char* __nptr, char** __endptr, __locale_t) { return ::strtold(__nptr, __endptr); }
+template <>
+inline _LIBCPP_HIDE_FROM_ABI long double
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t) {
+ return ::strtold(__nptr, __endptr);
+}
//
// Character manipulation functions
diff --git a/libcxx/include/__locale_dir/support/windows.h b/libcxx/include/__locale_dir/support/windows.h
index 5f35d089ac1fc..e151709e65d03 100644
--- a/libcxx/include/__locale_dir/support/windows.h
+++ b/libcxx/include/__locale_dir/support/windows.h
@@ -172,19 +172,34 @@ _LIBCPP_EXPORTED_FROM_ABI const char* __get_locale_encoding(__locale_t __loc);
//
// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
+template <class _FloatT>
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
#if defined(_LIBCPP_MSVCRT)
-inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
+
+template <>
+inline _LIBCPP_HIDE_FROM_ABI float
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::_strtof_l(__nptr, __endptr, __loc);
}
-inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) {
+
+template <>
+inline _LIBCPP_HIDE_FROM_ABI long double
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::_strtold_l(__nptr, __endptr, __loc);
}
#else
-_LIBCPP_EXPORTED_FROM_ABI float __strtof(const char*, char**, __locale_t);
-_LIBCPP_EXPORTED_FROM_ABI long double __strtold(const char*, char**, __locale_t);
+template <>
+_LIBCPP_EXPORTED_FROM_ABI float
+__str_to_float_c_locale<float>(const char*, char**, __locale_t);
+
+template <>
+_LIBCPP_EXPORTED_FROM_ABI long double
+__str_to_float_c_locale<long double>(const char*, char**, __locale_t);
#endif
-inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI double
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::_strtod_l(__nptr, __endptr, __loc);
}
diff --git a/libcxx/src/support/win32/locale_win32.cpp b/libcxx/src/support/win32/locale_win32.cpp
index c5117564438a5..e9660d06ed920 100644
--- a/libcxx/src/support/win32/locale_win32.cpp
+++ b/libcxx/src/support/win32/locale_win32.cpp
@@ -299,12 +299,14 @@ const char* __get_locale_encoding(__locale_t loc) {
// Strtonum functions
//
#if !defined(_LIBCPP_MSVCRT)
-float __strtof(const char* nptr, char** endptr, __locale_t loc) {
+template <>
+float __locale::__str_to_float_c_locale<float>(const char* nptr, char** endptr, __locale_t loc) {
__locale_guard __current(loc);
return std::strtof(nptr, endptr);
}
-long double __strtold(const char* nptr, char** endptr, __locale_t loc) {
+template <>
+long double __locale::__str_to_float_c_locale<long double>(const char* nptr, char** endptr, __locale_t loc) {
__locale_guard __current(loc);
return std::strtold(nptr, endptr);
}
>From 1271be65c2c8045f0c66665b3ca4f6ae1779d51b Mon Sep 17 00:00:00 2001
From: himadhith <himadhith.v at ibm.com>
Date: Tue, 8 Sep 2026 14:05:47 -0400
Subject: [PATCH 2/8] fix format
---
libcxx/include/__locale_dir/num.h | 6 +++---
libcxx/include/__locale_dir/support/bsd_like.h | 9 ++++++---
libcxx/include/__locale_dir/support/linux.h | 9 ++++++---
libcxx/include/__locale_dir/support/newlib.h | 15 +++++++++------
.../__locale_dir/support/no_locale/strtonum.h | 3 ++-
libcxx/include/__locale_dir/support/openbsd.h | 6 ++----
libcxx/include/__locale_dir/support/windows.h | 10 ++++------
7 files changed, 32 insertions(+), 26 deletions(-)
diff --git a/libcxx/include/__locale_dir/num.h b/libcxx/include/__locale_dir/num.h
index 8cc0b544f25b0..6395c6b6417dd 100644
--- a/libcxx/include/__locale_dir/num.h
+++ b/libcxx/include/__locale_dir/num.h
@@ -306,17 +306,17 @@ _LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2);
template <>
inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) {
- return __locale::__str_to_float_c_locale<float>(__a, __p2, __locale::__get_c_locale());
+ return __locale::__str_to_float_c_locale<float>(__a, __p2, __locale::__get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) {
- return __locale::__str_to_float_c_locale<double>(__a, __p2, __locale::__get_c_locale());
+ return __locale::__str_to_float_c_locale<double>(__a, __p2, __locale::__get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) {
- return __locale::__str_to_float_c_locale<long double>(__a, __p2, __locale::__get_c_locale());
+ return __locale::__str_to_float_c_locale<long double>(__a, __p2, __locale::__get_c_locale());
}
template <class _Tp>
diff --git a/libcxx/include/__locale_dir/support/bsd_like.h b/libcxx/include/__locale_dir/support/bsd_like.h
index 1164fcc454d0a..070f3dc3ad6ec 100644
--- a/libcxx/include/__locale_dir/support/bsd_like.h
+++ b/libcxx/include/__locale_dir/support/bsd_like.h
@@ -82,17 +82,20 @@ template <class _FloatT>
_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
template <>
-inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
+inline _LIBCPP_HIDE_FROM_ABI float
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtof_l(__nptr, __endptr, __loc);
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
+inline _LIBCPP_HIDE_FROM_ABI double
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtod_l(__nptr, __endptr, __loc);
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
+inline _LIBCPP_HIDE_FROM_ABI long double
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtold_l(__nptr, __endptr, __loc);
}
diff --git a/libcxx/include/__locale_dir/support/linux.h b/libcxx/include/__locale_dir/support/linux.h
index 48e5200c9f3ee..307cbf75fcfe0 100644
--- a/libcxx/include/__locale_dir/support/linux.h
+++ b/libcxx/include/__locale_dir/support/linux.h
@@ -89,17 +89,20 @@ template <class _FloatT>
_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
template <>
-inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
+inline _LIBCPP_HIDE_FROM_ABI float
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtof_l(__nptr, __endptr, __loc);
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
+inline _LIBCPP_HIDE_FROM_ABI double
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtod_l(__nptr, __endptr, __loc);
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
+inline _LIBCPP_HIDE_FROM_ABI long double
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtold_l(__nptr, __endptr, __loc);
}
diff --git a/libcxx/include/__locale_dir/support/newlib.h b/libcxx/include/__locale_dir/support/newlib.h
index 87297401fce88..d64e1f0721c23 100644
--- a/libcxx/include/__locale_dir/support/newlib.h
+++ b/libcxx/include/__locale_dir/support/newlib.h
@@ -89,18 +89,21 @@ inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc)
template <class _FloatT>
_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
-template<>
-inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI float
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtof_l(__nptr, __endptr, __loc);
}
-template<>
-inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI double
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtod_l(__nptr, __endptr, __loc);
}
-template<>
-inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
+template <>
+inline _LIBCPP_HIDE_FROM_ABI long double
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::strtold_l(__nptr, __endptr, __loc);
}
diff --git a/libcxx/include/__locale_dir/support/no_locale/strtonum.h b/libcxx/include/__locale_dir/support/no_locale/strtonum.h
index af7801bf6ca0b..699eb3e6fa173 100644
--- a/libcxx/include/__locale_dir/support/no_locale/strtonum.h
+++ b/libcxx/include/__locale_dir/support/no_locale/strtonum.h
@@ -36,7 +36,8 @@ inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char*
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI long double
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t) {
return std::strtold(__nptr, __endptr);
}
diff --git a/libcxx/include/__locale_dir/support/openbsd.h b/libcxx/include/__locale_dir/support/openbsd.h
index cd4d0d3d657cf..8d3afe7c846da 100644
--- a/libcxx/include/__locale_dir/support/openbsd.h
+++ b/libcxx/include/__locale_dir/support/openbsd.h
@@ -83,14 +83,12 @@ template <class _FloatT>
_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t);
template <>
-inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t) {
return ::strtof(__nptr, __endptr);
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t) {
return ::strtod(__nptr, __endptr);
}
diff --git a/libcxx/include/__locale_dir/support/windows.h b/libcxx/include/__locale_dir/support/windows.h
index e151709e65d03..b404d1ca7ac08 100644
--- a/libcxx/include/__locale_dir/support/windows.h
+++ b/libcxx/include/__locale_dir/support/windows.h
@@ -177,8 +177,8 @@ _LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char**
#if defined(_LIBCPP_MSVCRT)
template <>
-inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
+inline
+ _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
return ::_strtof_l(__nptr, __endptr, __loc);
}
@@ -189,12 +189,10 @@ __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __loca
}
#else
template <>
-_LIBCPP_EXPORTED_FROM_ABI float
-__str_to_float_c_locale<float>(const char*, char**, __locale_t);
+_LIBCPP_EXPORTED_FROM_ABI float __str_to_float_c_locale<float>(const char*, char**, __locale_t);
template <>
-_LIBCPP_EXPORTED_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char*, char**, __locale_t);
+_LIBCPP_EXPORTED_FROM_ABI long double __str_to_float_c_locale<long double>(const char*, char**, __locale_t);
#endif
template <>
>From 6b846f5518f62625d219bc5bb86de9f6222037f7 Mon Sep 17 00:00:00 2001
From: himadhith <himadhith.v at ibm.com>
Date: Mon, 21 Sep 2026 08:25:06 -0400
Subject: [PATCH 3/8] forward-declare __get_c_locale() and take __locale_t by
value
---
libcxx/include/__locale_dir/locale_base_api.h | 21 ++++++++++++-------
.../locale_base_api/bsd_locale_fallbacks.h | 2 +-
libcxx/include/__locale_dir/num.h | 6 +++---
libcxx/include/__locale_dir/support/aix.h | 19 ++++++++++-------
.../include/__locale_dir/support/bsd_like.h | 14 ++++++-------
libcxx/include/__locale_dir/support/fuchsia.h | 2 +-
libcxx/include/__locale_dir/support/linux.h | 19 ++++++++++-------
libcxx/include/__locale_dir/support/newlib.h | 19 ++++++++++-------
.../__locale_dir/support/no_locale/strtonum.h | 8 +++----
libcxx/include/__locale_dir/support/openbsd.h | 10 ++++-----
libcxx/include/__locale_dir/support/windows.h | 21 +++++++++++--------
libcxx/src/support/win32/locale_win32.cpp | 8 +++----
12 files changed, 83 insertions(+), 66 deletions(-)
diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h
index 92ff3abbfc240..2e5e6d6011366 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -55,7 +55,7 @@
// namespace __locale {
// // required by the headers
// template <class FloatT>
-// FloatT __str_to_float_c_locale(const char*, char**, __locale_t);
+// FloatT __str_to_float_c_locale(const char*, char**);
// }
//
// Character manipulation functions
@@ -165,6 +165,9 @@ namespace __locale {
using __locale_t _LIBCPP_NODEBUG = locale_t;
+// Forward declared for use below.
+inline __locale_t __get_c_locale();
+
# if defined(_LIBCPP_BUILDING_LIBRARY)
using __lconv_t _LIBCPP_NODEBUG = lconv;
@@ -185,24 +188,24 @@ inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { return
// Strtonum functions
//
template <class _FloatT>
-_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return strtof_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+ return strtof_l(__nptr, __endptr, __get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return strtod_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+ return strtod_l(__nptr, __endptr, __get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return strtold_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+ return strtold_l(__nptr, __endptr, __get_c_locale());
}
//
@@ -314,6 +317,8 @@ _LIBCPP_DIAGNOSTIC_POP
} // namespace __locale
_LIBCPP_END_NAMESPACE_STD
+# include <__locale_dir/support/default/get_c_locale.h>
+
# endif // Compatibility definition of locale base APIs
#endif // _LIBCPP_HAS_LOCALIZATION
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 8cdbe0cd15051..973bbfd0f6ceb 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
@@ -29,7 +29,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
struct __locale_guard {
- _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {}
+ _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t __loc) : __old_loc_(::uselocale(__loc)) {}
_LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
if (__old_loc_)
diff --git a/libcxx/include/__locale_dir/num.h b/libcxx/include/__locale_dir/num.h
index 6395c6b6417dd..f73b5961bbc7a 100644
--- a/libcxx/include/__locale_dir/num.h
+++ b/libcxx/include/__locale_dir/num.h
@@ -306,17 +306,17 @@ _LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2);
template <>
inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) {
- return __locale::__str_to_float_c_locale<float>(__a, __p2, __locale::__get_c_locale());
+ return __locale::__str_to_float_c_locale<float>(__a, __p2);
}
template <>
inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) {
- return __locale::__str_to_float_c_locale<double>(__a, __p2, __locale::__get_c_locale());
+ return __locale::__str_to_float_c_locale<double>(__a, __p2);
}
template <>
inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) {
- return __locale::__str_to_float_c_locale<long double>(__a, __p2, __locale::__get_c_locale());
+ return __locale::__str_to_float_c_locale<long double>(__a, __p2);
}
template <class _Tp>
diff --git a/libcxx/include/__locale_dir/support/aix.h b/libcxx/include/__locale_dir/support/aix.h
index 15de092b9cc6e..78e9053c6e0a8 100644
--- a/libcxx/include/__locale_dir/support/aix.h
+++ b/libcxx/include/__locale_dir/support/aix.h
@@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace __locale {
struct __locale_guard {
- _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {}
+ _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t __loc) : __old_loc_(::uselocale(__loc)) {}
_LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
if (__old_loc_)
@@ -63,6 +63,9 @@ inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_cur_max() { return MB_CUR
using __locale_t _LIBCPP_NODEBUG = ::locale_t;
+// Forward declared for use below.
+inline __locale_t __get_c_locale();
+
#if defined(_LIBCPP_BUILDING_LIBRARY)
using __lconv_t _LIBCPP_NODEBUG = std::lconv;
@@ -90,26 +93,26 @@ inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc)
// Strtonum functions
//
template <class _FloatT>
-_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
- __locale_guard __current(__loc);
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+ __locale_guard __current(__get_c_locale());
return ::strtof(__nptr, __endptr);
}
template <>
inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- __locale_guard __current(__loc);
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+ __locale_guard __current(__get_c_locale());
return ::strtod(__nptr, __endptr);
}
template <>
inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- __locale_guard __current(__loc);
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+ __locale_guard __current(__get_c_locale());
return ::strtold(__nptr, __endptr);
}
diff --git a/libcxx/include/__locale_dir/support/bsd_like.h b/libcxx/include/__locale_dir/support/bsd_like.h
index 070f3dc3ad6ec..1b8f1726e0da1 100644
--- a/libcxx/include/__locale_dir/support/bsd_like.h
+++ b/libcxx/include/__locale_dir/support/bsd_like.h
@@ -79,24 +79,24 @@ inline __locale_t __get_c_locale() {
// Strtonum functions
//
template <class _FloatT>
-_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::strtof_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+ return ::strtof_l(__nptr, __endptr, __get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::strtod_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+ return ::strtod_l(__nptr, __endptr, __get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::strtold_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+ return ::strtold_l(__nptr, __endptr, __get_c_locale());
}
//
diff --git a/libcxx/include/__locale_dir/support/fuchsia.h b/libcxx/include/__locale_dir/support/fuchsia.h
index 0b4c268108032..f95ecbbb2e830 100644
--- a/libcxx/include/__locale_dir/support/fuchsia.h
+++ b/libcxx/include/__locale_dir/support/fuchsia.h
@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace __locale {
struct __locale_guard {
- _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {}
+ _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t __loc) : __old_loc_(::uselocale(__loc)) {}
_LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
if (__old_loc_)
diff --git a/libcxx/include/__locale_dir/support/linux.h b/libcxx/include/__locale_dir/support/linux.h
index 307cbf75fcfe0..8a616117b418e 100644
--- a/libcxx/include/__locale_dir/support/linux.h
+++ b/libcxx/include/__locale_dir/support/linux.h
@@ -36,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace __locale {
struct __locale_guard {
- _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {}
+ _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t __loc) : __old_loc_(::uselocale(__loc)) {}
_LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
if (__old_loc_)
@@ -63,6 +63,9 @@ struct __locale_guard {
using __locale_t _LIBCPP_NODEBUG = ::locale_t;
+// Forward declared for use below.
+inline __locale_t __get_c_locale();
+
#if defined(_LIBCPP_BUILDING_LIBRARY)
using __lconv_t _LIBCPP_NODEBUG = std::lconv;
@@ -86,24 +89,24 @@ inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) {
// Strtonum functions
//
template <class _FloatT>
-_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::strtof_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+ return ::strtof_l(__nptr, __endptr, __get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::strtod_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+ return ::strtod_l(__nptr, __endptr, __get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::strtold_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+ return ::strtold_l(__nptr, __endptr, __get_c_locale());
}
//
diff --git a/libcxx/include/__locale_dir/support/newlib.h b/libcxx/include/__locale_dir/support/newlib.h
index d64e1f0721c23..79f3db185fb70 100644
--- a/libcxx/include/__locale_dir/support/newlib.h
+++ b/libcxx/include/__locale_dir/support/newlib.h
@@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace __locale {
struct __locale_guard {
- _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {}
+ _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t __loc) : __old_loc_(::uselocale(__loc)) {}
_LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
if (__old_loc_)
@@ -60,6 +60,9 @@ struct __locale_guard {
using __locale_t _LIBCPP_NODEBUG = ::locale_t;
+// Forward declared for use below.
+inline __locale_t __get_c_locale();
+
#if defined(_LIBCPP_BUILDING_LIBRARY)
using __lconv_t _LIBCPP_NODEBUG = std::lconv;
@@ -87,24 +90,24 @@ inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc)
// Strtonum functions
//
template <class _FloatT>
-_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::strtof_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+ return ::strtof_l(__nptr, __endptr, __get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::strtod_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+ return ::strtod_l(__nptr, __endptr, __get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::strtold_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+ return ::strtold_l(__nptr, __endptr, __get_c_locale());
}
//
diff --git a/libcxx/include/__locale_dir/support/no_locale/strtonum.h b/libcxx/include/__locale_dir/support/no_locale/strtonum.h
index 699eb3e6fa173..2ad45f54ac4e6 100644
--- a/libcxx/include/__locale_dir/support/no_locale/strtonum.h
+++ b/libcxx/include/__locale_dir/support/no_locale/strtonum.h
@@ -23,21 +23,21 @@ namespace __locale {
// Strtonum functions
//
template <class _FloatT>
-_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t);
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
-inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
return std::strtof(__nptr, __endptr);
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
return std::strtod(__nptr, __endptr);
}
template <>
inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t) {
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
return std::strtold(__nptr, __endptr);
}
diff --git a/libcxx/include/__locale_dir/support/openbsd.h b/libcxx/include/__locale_dir/support/openbsd.h
index 8d3afe7c846da..91897d70d1bf0 100644
--- a/libcxx/include/__locale_dir/support/openbsd.h
+++ b/libcxx/include/__locale_dir/support/openbsd.h
@@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace __locale {
struct __locale_guard {
- __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {}
+ __locale_guard(locale_t __loc) : __old_loc_(::uselocale(__loc)) {}
~__locale_guard() {
if (__old_loc_)
@@ -80,21 +80,21 @@ inline __lconv_t* __localeconv(__locale_t& __loc) {
// Strtonum functions
//
template <class _FloatT>
-_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t);
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
-inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
return ::strtof(__nptr, __endptr);
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
return ::strtod(__nptr, __endptr);
}
template <>
inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t) {
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
return ::strtold(__nptr, __endptr);
}
diff --git a/libcxx/include/__locale_dir/support/windows.h b/libcxx/include/__locale_dir/support/windows.h
index b404d1ca7ac08..6620dd22eaf57 100644
--- a/libcxx/include/__locale_dir/support/windows.h
+++ b/libcxx/include/__locale_dir/support/windows.h
@@ -154,6 +154,9 @@ class __locale_t {
__lconv_storage* __lc_ = nullptr;
};
+// Forward declared for use below.
+inline __locale_t __get_c_locale();
+
#if defined(_LIBCPP_BUILDING_LIBRARY)
_LIBCPP_EXPORTED_FROM_ABI __locale_t __newlocale(int __mask, const char* __locale, __locale_t __base);
inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { ::_free_locale(__loc); }
@@ -173,32 +176,32 @@ _LIBCPP_EXPORTED_FROM_ABI const char* __get_locale_encoding(__locale_t __loc);
// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
template <class _FloatT>
-_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr, __locale_t __loc);
+_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
#if defined(_LIBCPP_MSVCRT)
template <>
inline
- _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::_strtof_l(__nptr, __endptr, __loc);
+ _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+ return ::_strtof_l(__nptr, __endptr, __get_c_locale());
}
template <>
inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::_strtold_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+ return ::_strtold_l(__nptr, __endptr, __get_c_locale());
}
#else
template <>
-_LIBCPP_EXPORTED_FROM_ABI float __str_to_float_c_locale<float>(const char*, char**, __locale_t);
+_LIBCPP_EXPORTED_FROM_ABI float __str_to_float_c_locale<float>(const char*, char**);
template <>
-_LIBCPP_EXPORTED_FROM_ABI long double __str_to_float_c_locale<long double>(const char*, char**, __locale_t);
+_LIBCPP_EXPORTED_FROM_ABI long double __str_to_float_c_locale<long double>(const char*, char**);
#endif
template <>
inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr, __locale_t __loc) {
- return ::_strtod_l(__nptr, __endptr, __loc);
+__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+ return ::_strtod_l(__nptr, __endptr, __get_c_locale());
}
//
diff --git a/libcxx/src/support/win32/locale_win32.cpp b/libcxx/src/support/win32/locale_win32.cpp
index e9660d06ed920..a9853020c1424 100644
--- a/libcxx/src/support/win32/locale_win32.cpp
+++ b/libcxx/src/support/win32/locale_win32.cpp
@@ -300,14 +300,14 @@ const char* __get_locale_encoding(__locale_t loc) {
//
#if !defined(_LIBCPP_MSVCRT)
template <>
-float __locale::__str_to_float_c_locale<float>(const char* nptr, char** endptr, __locale_t loc) {
- __locale_guard __current(loc);
+float __locale::__str_to_float_c_locale<float>(const char* nptr, char** endptr) {
+ __locale_guard __current(__get_c_locale());
return std::strtof(nptr, endptr);
}
template <>
-long double __locale::__str_to_float_c_locale<long double>(const char* nptr, char** endptr, __locale_t loc) {
- __locale_guard __current(loc);
+long double __locale::__str_to_float_c_locale<long double>(const char* nptr, char** endptr) {
+ __locale_guard __current(__get_c_locale());
return std::strtold(nptr, endptr);
}
#endif
>From 30aab2df9f732390eac8b8d22e4fd132be7d7bb7 Mon Sep 17 00:00:00 2001
From: himadhith <himadhith.v at ibm.com>
Date: Mon, 21 Sep 2026 08:32:06 -0400
Subject: [PATCH 4/8] fix format
---
libcxx/include/__locale_dir/locale_base_api.h | 9 +++------
libcxx/include/__locale_dir/support/aix.h | 9 +++------
libcxx/include/__locale_dir/support/bsd_like.h | 9 +++------
libcxx/include/__locale_dir/support/linux.h | 9 +++------
libcxx/include/__locale_dir/support/newlib.h | 9 +++------
libcxx/include/__locale_dir/support/no_locale/strtonum.h | 3 +--
libcxx/include/__locale_dir/support/openbsd.h | 3 +--
libcxx/include/__locale_dir/support/windows.h | 9 +++------
8 files changed, 20 insertions(+), 40 deletions(-)
diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h
index 2e5e6d6011366..91bd9cfd6d0b7 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -191,20 +191,17 @@ template <class _FloatT>
_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
-inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
return strtof_l(__nptr, __endptr, __get_c_locale());
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
return strtod_l(__nptr, __endptr, __get_c_locale());
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
return strtold_l(__nptr, __endptr, __get_c_locale());
}
diff --git a/libcxx/include/__locale_dir/support/aix.h b/libcxx/include/__locale_dir/support/aix.h
index 78e9053c6e0a8..17f095ac6ce42 100644
--- a/libcxx/include/__locale_dir/support/aix.h
+++ b/libcxx/include/__locale_dir/support/aix.h
@@ -96,22 +96,19 @@ template <class _FloatT>
_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
-inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
__locale_guard __current(__get_c_locale());
return ::strtof(__nptr, __endptr);
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
__locale_guard __current(__get_c_locale());
return ::strtod(__nptr, __endptr);
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
__locale_guard __current(__get_c_locale());
return ::strtold(__nptr, __endptr);
}
diff --git a/libcxx/include/__locale_dir/support/bsd_like.h b/libcxx/include/__locale_dir/support/bsd_like.h
index 1b8f1726e0da1..63a385dfdc008 100644
--- a/libcxx/include/__locale_dir/support/bsd_like.h
+++ b/libcxx/include/__locale_dir/support/bsd_like.h
@@ -82,20 +82,17 @@ template <class _FloatT>
_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
-inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
return ::strtof_l(__nptr, __endptr, __get_c_locale());
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
return ::strtod_l(__nptr, __endptr, __get_c_locale());
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
return ::strtold_l(__nptr, __endptr, __get_c_locale());
}
diff --git a/libcxx/include/__locale_dir/support/linux.h b/libcxx/include/__locale_dir/support/linux.h
index 8a616117b418e..01f184c56ebe5 100644
--- a/libcxx/include/__locale_dir/support/linux.h
+++ b/libcxx/include/__locale_dir/support/linux.h
@@ -92,20 +92,17 @@ template <class _FloatT>
_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
-inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
return ::strtof_l(__nptr, __endptr, __get_c_locale());
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
return ::strtod_l(__nptr, __endptr, __get_c_locale());
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
return ::strtold_l(__nptr, __endptr, __get_c_locale());
}
diff --git a/libcxx/include/__locale_dir/support/newlib.h b/libcxx/include/__locale_dir/support/newlib.h
index 79f3db185fb70..6b72454e79a54 100644
--- a/libcxx/include/__locale_dir/support/newlib.h
+++ b/libcxx/include/__locale_dir/support/newlib.h
@@ -93,20 +93,17 @@ template <class _FloatT>
_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
template <>
-inline _LIBCPP_HIDE_FROM_ABI float
-__str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
return ::strtof_l(__nptr, __endptr, __get_c_locale());
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
return ::strtod_l(__nptr, __endptr, __get_c_locale());
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
return ::strtold_l(__nptr, __endptr, __get_c_locale());
}
diff --git a/libcxx/include/__locale_dir/support/no_locale/strtonum.h b/libcxx/include/__locale_dir/support/no_locale/strtonum.h
index 2ad45f54ac4e6..9b8e1b3b10556 100644
--- a/libcxx/include/__locale_dir/support/no_locale/strtonum.h
+++ b/libcxx/include/__locale_dir/support/no_locale/strtonum.h
@@ -36,8 +36,7 @@ inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char*
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
return std::strtold(__nptr, __endptr);
}
diff --git a/libcxx/include/__locale_dir/support/openbsd.h b/libcxx/include/__locale_dir/support/openbsd.h
index 91897d70d1bf0..369b8e652689b 100644
--- a/libcxx/include/__locale_dir/support/openbsd.h
+++ b/libcxx/include/__locale_dir/support/openbsd.h
@@ -93,8 +93,7 @@ inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char*
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
return ::strtold(__nptr, __endptr);
}
diff --git a/libcxx/include/__locale_dir/support/windows.h b/libcxx/include/__locale_dir/support/windows.h
index 6620dd22eaf57..8e7f80191c50f 100644
--- a/libcxx/include/__locale_dir/support/windows.h
+++ b/libcxx/include/__locale_dir/support/windows.h
@@ -180,14 +180,12 @@ _LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char**
#if defined(_LIBCPP_MSVCRT)
template <>
-inline
- _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
return ::_strtof_l(__nptr, __endptr, __get_c_locale());
}
template <>
-inline _LIBCPP_HIDE_FROM_ABI long double
-__str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
return ::_strtold_l(__nptr, __endptr, __get_c_locale());
}
#else
@@ -199,8 +197,7 @@ _LIBCPP_EXPORTED_FROM_ABI long double __str_to_float_c_locale<long double>(const
#endif
template <>
-inline _LIBCPP_HIDE_FROM_ABI double
-__str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
return ::_strtod_l(__nptr, __endptr, __get_c_locale());
}
>From 34b5f7c0f1cd7abdfe1bbb85bcdf2d978ae8ce8d Mon Sep 17 00:00:00 2001
From: himadhith <himadhith.v at ibm.com>
Date: Mon, 21 Sep 2026 08:59:40 -0400
Subject: [PATCH 5/8] Remove __do_strtod from num.h and add
__str_to_float_c_locale<T>
---
libcxx/include/__locale_dir/num.h | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/libcxx/include/__locale_dir/num.h b/libcxx/include/__locale_dir/num.h
index f73b5961bbc7a..6774903aa0069 100644
--- a/libcxx/include/__locale_dir/num.h
+++ b/libcxx/include/__locale_dir/num.h
@@ -301,31 +301,13 @@ extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>;
extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>;
# endif
-template <class _Tp>
-_LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2);
-
-template <>
-inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) {
- return __locale::__str_to_float_c_locale<float>(__a, __p2);
-}
-
-template <>
-inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) {
- return __locale::__str_to_float_c_locale<double>(__a, __p2);
-}
-
-template <>
-inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) {
- return __locale::__str_to_float_c_locale<long double>(__a, __p2);
-}
-
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _Tp __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err) {
if (__a != __a_end) {
__libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
errno = 0;
char* __p2;
- _Tp __ld = std::__do_strtod<_Tp>(__a, &__p2);
+ _Tp __ld = __locale::__str_to_float_c_locale<_Tp>(__a, &__p2);
__libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
if (__current_errno == 0)
errno = __save_errno;
>From a28c83d76aba73541b8089788a45d9c25f053286 Mon Sep 17 00:00:00 2001
From: himadhith <himadhith.v at ibm.com>
Date: Tue, 22 Sep 2026 01:39:56 -0400
Subject: [PATCH 6/8] add _LIBCPP_HIDE_FROM_ABI to the __get_c_locale() forward
declaration on Windows
---
libcxx/include/__locale_dir/support/windows.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__locale_dir/support/windows.h b/libcxx/include/__locale_dir/support/windows.h
index 8e7f80191c50f..e4a030c72e701 100644
--- a/libcxx/include/__locale_dir/support/windows.h
+++ b/libcxx/include/__locale_dir/support/windows.h
@@ -155,7 +155,7 @@ class __locale_t {
};
// Forward declared for use below.
-inline __locale_t __get_c_locale();
+inline _LIBCPP_HIDE_FROM_ABI __locale_t __get_c_locale();
#if defined(_LIBCPP_BUILDING_LIBRARY)
_LIBCPP_EXPORTED_FROM_ABI __locale_t __newlocale(int __mask, const char* __locale, __locale_t __base);
>From 4bad916bc9141099e6b21e25c45e10d7cf8e59c0 Mon Sep 17 00:00:00 2001
From: himadhith <himadhith.v at ibm.com>
Date: Wed, 23 Sep 2026 07:58:20 -0400
Subject: [PATCH 7/8] remove locale:: qualification and remove & from
__locale_guard
---
libcxx/src/support/win32/locale_win32.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libcxx/src/support/win32/locale_win32.cpp b/libcxx/src/support/win32/locale_win32.cpp
index a9853020c1424..139b3b97e6e71 100644
--- a/libcxx/src/support/win32/locale_win32.cpp
+++ b/libcxx/src/support/win32/locale_win32.cpp
@@ -31,7 +31,7 @@ __locale_t __newlocale(int /*mask*/, const char* locale, __locale_t /*base*/) {
return {::_create_locale(LC_ALL, locale), locale};
}
-__lconv_t* __localeconv(__locale_t& loc) {
+__lconv_t* __localeconv(__locale_t loc) {
__locale_guard __current(loc);
lconv* lc = std::localeconv();
if (!lc)
@@ -300,13 +300,13 @@ const char* __get_locale_encoding(__locale_t loc) {
//
#if !defined(_LIBCPP_MSVCRT)
template <>
-float __locale::__str_to_float_c_locale<float>(const char* nptr, char** endptr) {
+float __str_to_float_c_locale<float>(const char* nptr, char** endptr) {
__locale_guard __current(__get_c_locale());
return std::strtof(nptr, endptr);
}
template <>
-long double __locale::__str_to_float_c_locale<long double>(const char* nptr, char** endptr) {
+long double __str_to_float_c_locale<long double>(const char* nptr, char** endptr) {
__locale_guard __current(__get_c_locale());
return std::strtold(nptr, endptr);
}
>From 8fa2aa33a31ea292f27e498699bc850a30909a9a Mon Sep 17 00:00:00 2001
From: himadhith <himadhith.v at ibm.com>
Date: Wed, 23 Sep 2026 23:59:40 -0400
Subject: [PATCH 8/8] update __localeonv in windows.h
---
libcxx/include/__locale_dir/support/windows.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/__locale_dir/support/windows.h b/libcxx/include/__locale_dir/support/windows.h
index e4a030c72e701..e056c2739a49c 100644
--- a/libcxx/include/__locale_dir/support/windows.h
+++ b/libcxx/include/__locale_dir/support/windows.h
@@ -166,7 +166,7 @@ inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, const char* __loc
std::__throw_bad_alloc();
return __new_locale;
}
-_LIBCPP_EXPORTED_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc);
+_LIBCPP_EXPORTED_FROM_ABI __lconv_t* __localeconv(__locale_t __loc);
_LIBCPP_EXPORTED_FROM_ABI const char* __get_locale_encoding(__locale_t __loc);
#endif // _LIBCPP_BUILDING_LIBRARY
More information about the libcxx-commits
mailing list