From d1026fa5d203324112be69cb70945756cb4d19b9 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 29 May 2022 12:37:09 -0700 Subject: [PATCH] Remove extern format_float --- include/fmt/format-inl.h | 26 -------------------------- include/fmt/format.h | 32 +++++++++++++++++++++++++------- src/format.cc | 5 ----- 3 files changed, 25 insertions(+), 38 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 7412f0dd..5e4950e2 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -132,32 +132,6 @@ template inline bool operator==(basic_fp x, basic_fp y) { return x.f == y.f && x.e == y.e; } -inline FMT_CONSTEXPR20 uint128_fallback& uint128_fallback::operator+=( - uint64_t n) noexcept { - if (is_constant_evaluated()) { - lo_ += n; - hi_ += (lo_ < n ? 1 : 0); - return *this; - } -#if FMT_HAS_BUILTIN(__builtin_addcll) - unsigned long long carry; - lo_ = __builtin_addcll(lo_, n, 0, &carry); - hi_ += carry; -#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) - unsigned long long result; - auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result); - lo_ = result; - hi_ += carry; -#elif defined(_MSC_VER) && defined(_M_X64) - auto carry = _addcarry_u64(0, lo_, n, &lo_); - _addcarry_u64(carry, hi_, 0, &hi_); -#else - lo_ += n; - hi_ += (lo_ < n ? 1 : 0); -#endif - return *this; -} - // Compilers should be able to optimize this into the ror instruction. FMT_CONSTEXPR inline uint32_t rotr(uint32_t n, uint32_t r) noexcept { r &= 31; diff --git a/include/fmt/format.h b/include/fmt/format.h index dd0df5d9..f9a678b5 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -401,7 +401,31 @@ class uint128_fallback { lo_ = new_lo; hi_ = new_hi; } - FMT_CONSTEXPR20 uint128_fallback& operator+=(uint64_t n) noexcept; + + FMT_CONSTEXPR20 uint128_fallback& operator+=(uint64_t n) noexcept { + if (is_constant_evaluated()) { + lo_ += n; + hi_ += (lo_ < n ? 1 : 0); + return *this; + } +#if FMT_HAS_BUILTIN(__builtin_addcll) + unsigned long long carry; + lo_ = __builtin_addcll(lo_, n, 0, &carry); + hi_ += carry; +#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) + unsigned long long result; + auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result); + lo_ = result; + hi_ += carry; +#elif defined(_MSC_VER) && defined(_M_X64) + auto carry = _addcarry_u64(0, lo_, n, &lo_); + _addcarry_u64(carry, hi_, 0, &hi_); +#else + lo_ += n; + hi_ += (lo_ < n ? 1 : 0); +#endif + return *this; + } }; using uint128_t = conditional_t; @@ -4113,12 +4137,6 @@ extern template FMT_API auto thousands_sep_impl(locale_ref) -> thousands_sep_result; extern template FMT_API auto decimal_point_impl(locale_ref) -> char; extern template FMT_API auto decimal_point_impl(locale_ref) -> wchar_t; -extern template auto format_float(double value, int precision, - float_specs specs, buffer& buf) - -> int; -extern template auto format_float(long double value, int precision, - float_specs specs, - buffer& buf) -> int; #endif // FMT_HEADER_ONLY FMT_END_DETAIL_NAMESPACE diff --git a/src/format.cc b/src/format.cc index 548d392e..99b7e9dd 100644 --- a/src/format.cc +++ b/src/format.cc @@ -35,11 +35,6 @@ template FMT_API void vformat_to(buffer&, string_view, basic_format_args, locale_ref); -template FMT_API auto format_float(double, int, float_specs, buffer&) - -> int; -template FMT_API auto format_float(long double, int, detail::float_specs, - buffer&) -> int; - // Explicit instantiations for wchar_t. template FMT_API auto thousands_sep_impl(locale_ref)