From 422272881a06b89c6ba3760c8b271c91166433c0cafb615e63f20f3dad0e5a09 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 13 Jul 2022 22:13:51 +0000 Subject: [PATCH] - Add 0001-Fix-large-shift-in-uint128_fallback.patch 0002-Use-FMT_USE_FLOAT128-instead-of-__SIZEOF_FLOAT128__.patch 0001-Make-sure-the-correct-fmod-overload-is-called.patch OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/fmt?expand=0&rev=47 --- ...-Fix-large-shift-in-uint128_fallback.patch | 52 +++++++++++++++++++ ...-the-correct-fmod-overload-is-called.patch | 25 +++++++++ ...AT128-instead-of-__SIZEOF_FLOAT128__.patch | 34 ++++++++++++ fmt.changes | 3 ++ fmt.spec | 3 ++ 5 files changed, 117 insertions(+) create mode 100644 0001-Fix-large-shift-in-uint128_fallback.patch create mode 100644 0001-Make-sure-the-correct-fmod-overload-is-called.patch create mode 100644 0002-Use-FMT_USE_FLOAT128-instead-of-__SIZEOF_FLOAT128__.patch diff --git a/0001-Fix-large-shift-in-uint128_fallback.patch b/0001-Fix-large-shift-in-uint128_fallback.patch new file mode 100644 index 0000000..6486213 --- /dev/null +++ b/0001-Fix-large-shift-in-uint128_fallback.patch @@ -0,0 +1,52 @@ +From 2a1b3ac629bfec51ce70d3c0ebaf28e706754e19 Mon Sep 17 00:00:00 2001 +From: Victor Zverovich +Date: Sun, 10 Jul 2022 08:14:18 -0700 +Subject: [PATCH 1/2] Fix large shift in uint128_fallback + +--- + include/fmt/format.h | 2 ++ + test/format-test.cc | 4 +++- + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/include/fmt/format.h b/include/fmt/format.h +index 0bd2fdb1..6516975e 100644 +--- a/include/fmt/format.h ++++ b/include/fmt/format.h +@@ -366,10 +366,12 @@ class uint128_fallback { + } + FMT_CONSTEXPR auto operator>>(int shift) const -> uint128_fallback { + if (shift == 64) return {0, hi_}; ++ if (shift > 64) return uint128_fallback(0, hi_) >> (shift - 64); + return {hi_ >> shift, (hi_ << (64 - shift)) | (lo_ >> shift)}; + } + FMT_CONSTEXPR auto operator<<(int shift) const -> uint128_fallback { + if (shift == 64) return {lo_, 0}; ++ if (shift > 64) return uint128_fallback(lo_, 0) << (shift - 64); + return {hi_ << shift | (lo_ >> (64 - shift)), (lo_ << shift)}; + } + FMT_CONSTEXPR auto operator>>=(int shift) -> uint128_fallback& { +diff --git a/test/format-test.cc b/test/format-test.cc +index 45a92624..8c1c305f 100644 +--- a/test/format-test.cc ++++ b/test/format-test.cc +@@ -59,6 +59,8 @@ TEST(uint128_test, shift) { + EXPECT_EQ(static_cast(n), 0x8000000000000000); + n = n >> 62; + EXPECT_EQ(static_cast(n), 42); ++ EXPECT_EQ(uint128_fallback(1) << 112, uint128_fallback(0x1000000000000, 0)); ++ EXPECT_EQ(uint128_fallback(0x1000000000000, 0) >> 112, uint128_fallback(1)); + } + + TEST(uint128_test, minus) { +@@ -234,7 +236,7 @@ TEST(util_test, format_system_error) { + throws_on_alloc = true; + } + if (!throws_on_alloc) { +- fmt::print("warning: std::allocator allocates {} chars", max_size); ++ fmt::print("warning: std::allocator allocates {} chars\n", max_size); + return; + } + } +-- +2.36.1 + diff --git a/0001-Make-sure-the-correct-fmod-overload-is-called.patch b/0001-Make-sure-the-correct-fmod-overload-is-called.patch new file mode 100644 index 0000000..0c7804b --- /dev/null +++ b/0001-Make-sure-the-correct-fmod-overload-is-called.patch @@ -0,0 +1,25 @@ +From d82e1a108d3b3e3e7b8b019b47df9c4ed127723b Mon Sep 17 00:00:00 2001 +From: Victor Zverovich +Date: Wed, 13 Jul 2022 12:33:57 -0700 +Subject: [PATCH] Make sure the correct fmod overload is called + +--- + include/fmt/chrono.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h +index 9b2aa74d..4a2c3a3d 100644 +--- a/include/fmt/chrono.h ++++ b/include/fmt/chrono.h +@@ -1777,7 +1777,7 @@ struct chrono_formatter { + format_to(std::back_inserter(buf), runtime("{:.{}f}"), + std::fmod(val * static_cast(Period::num) / + static_cast(Period::den), +- 60), ++ static_cast(60)), + num_fractional_digits); + if (negative) *out++ = '-'; + if (buf.size() < 2 || buf[1] == '.') *out++ = '0'; +-- +2.36.1 + diff --git a/0002-Use-FMT_USE_FLOAT128-instead-of-__SIZEOF_FLOAT128__.patch b/0002-Use-FMT_USE_FLOAT128-instead-of-__SIZEOF_FLOAT128__.patch new file mode 100644 index 0000000..7c79f94 --- /dev/null +++ b/0002-Use-FMT_USE_FLOAT128-instead-of-__SIZEOF_FLOAT128__.patch @@ -0,0 +1,34 @@ +From 05be7a0764f8fbfbdf9c9750ec54d49fe3d2419f Mon Sep 17 00:00:00 2001 +From: Victor Zverovich +Date: Sun, 10 Jul 2022 08:47:16 -0700 +Subject: [PATCH 2/2] Use FMT_USE_FLOAT128 instead of __SIZEOF_FLOAT128__ + +--- + test/format-test.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/test/format-test.cc b/test/format-test.cc +index 8c1c305f..4ec7c838 100644 +--- a/test/format-test.cc ++++ b/test/format-test.cc +@@ -101,7 +101,7 @@ template void check_isfinite() { + + TEST(float_test, isfinite) { + check_isfinite(); +-#ifdef __SIZEOF_FLOAT128__ ++#if FMT_USE_FLOAT128 + check_isfinite(); + #endif + } +@@ -122,7 +122,7 @@ template void check_isnan() { + + TEST(float_test, isnan) { + check_isnan(); +-#ifdef __SIZEOF_FLOAT128__ ++#if FMT_USE_FLOAT128 + check_isnan(); + #endif + } +-- +2.36.1 + diff --git a/fmt.changes b/fmt.changes index d005c94..7aeed75 100644 --- a/fmt.changes +++ b/fmt.changes @@ -21,6 +21,9 @@ Tue Jul 5 14:16:23 UTC 2022 - Jan Engelhardt * Added experimental std::filesystem::path formatting support. * Added a std::thread::id formatter to fmt/std.h. * Added support for nested specifiers to range formatting. +- Add 0001-Fix-large-shift-in-uint128_fallback.patch + 0002-Use-FMT_USE_FLOAT128-instead-of-__SIZEOF_FLOAT128__.patch + 0001-Make-sure-the-correct-fmod-overload-is-called.patch ------------------------------------------------------------------- Sat Apr 30 12:01:50 UTC 2022 - Jan Engelhardt diff --git a/fmt.spec b/fmt.spec index 2367e2c..b439157 100644 --- a/fmt.spec +++ b/fmt.spec @@ -25,6 +25,9 @@ License: MIT URL: http://fmtlib.net/ Source0: https://github.com/fmtlib/fmt/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz Source1: baselibs.conf +Patch1: 0001-Fix-large-shift-in-uint128_fallback.patch +Patch2: 0002-Use-FMT_USE_FLOAT128-instead-of-__SIZEOF_FLOAT128__.patch +Patch3: 0001-Make-sure-the-correct-fmod-overload-is-called.patch BuildRequires: c++_compiler BuildRequires: cmake BuildRequires: pkg-config