[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
Thu Sep 17 22:56:28 PDT 2026
https://github.com/Himadhith updated https://github.com/llvm/llvm-project/pull/222081
>From c5ab0d0a0091260299a1cb1c03485d9376cf7863 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/2] [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 45bf724293fa5e4aface536c55fb1310533bbe09 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/2] fix format
---
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 ++++------
6 files changed, 29 insertions(+), 23 deletions(-)
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 <>
More information about the libcxx-commits
mailing list