Added upstream fixes for 32-bit architectures.
This commit is contained in:
parent
b1a074e783
commit
87b328c834
49
fmt-float-fixes-on-32-bit-arches.patch
Normal file
49
fmt-float-fixes-on-32-bit-arches.patch
Normal file
@ -0,0 +1,49 @@
|
||||
From 2a1b3ac629bfec51ce70d3c0ebaf28e706754e19 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Zverovich <viz@fb.com>
|
||||
Date: Sun, 10 Jul 2022 08:14:18 -0700
|
||||
Subject: [PATCH] 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 0bd2fdb182..6516975e2f 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 45a92624fb..8c1c305f78 100644
|
||||
--- a/test/format-test.cc
|
||||
+++ b/test/format-test.cc
|
||||
@@ -59,6 +59,8 @@ TEST(uint128_test, shift) {
|
||||
EXPECT_EQ(static_cast<uint64_t>(n), 0x8000000000000000);
|
||||
n = n >> 62;
|
||||
EXPECT_EQ(static_cast<uint64_t>(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;
|
||||
}
|
||||
}
|
31
fmt-use-float128-definition.patch
Normal file
31
fmt-use-float128-definition.patch
Normal file
@ -0,0 +1,31 @@
|
||||
From 05be7a0764f8fbfbdf9c9750ec54d49fe3d2419f Mon Sep 17 00:00:00 2001
|
||||
From: Victor Zverovich <viz@fb.com>
|
||||
Date: Sun, 10 Jul 2022 08:47:16 -0700
|
||||
Subject: [PATCH] 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 8c1c305f78..4ec7c838b7 100644
|
||||
--- a/test/format-test.cc
|
||||
+++ b/test/format-test.cc
|
||||
@@ -101,7 +101,7 @@ template <typename Float> void check_isfinite() {
|
||||
|
||||
TEST(float_test, isfinite) {
|
||||
check_isfinite<double>();
|
||||
-#ifdef __SIZEOF_FLOAT128__
|
||||
+#if FMT_USE_FLOAT128
|
||||
check_isfinite<fmt::detail::float128>();
|
||||
#endif
|
||||
}
|
||||
@@ -122,7 +122,7 @@ template <typename Float> void check_isnan() {
|
||||
|
||||
TEST(float_test, isnan) {
|
||||
check_isnan<double>();
|
||||
-#ifdef __SIZEOF_FLOAT128__
|
||||
+#if FMT_USE_FLOAT128
|
||||
check_isnan<fmt::detail::float128>();
|
||||
#endif
|
||||
}
|
5
fmt.spec
5
fmt.spec
@ -7,6 +7,11 @@ Summary: Small, safe and fast formatting library for C++
|
||||
URL: https://github.com/fmtlib/%{name}
|
||||
Source0: %{url}/archive/%{version}.tar.gz
|
||||
|
||||
# https://github.com/fmtlib/fmt/commit/2a1b3ac629bfec51ce70d3c0ebaf28e706754e19
|
||||
Patch100: %{name}-float-fixes-on-32-bit-arches.patch
|
||||
# https://github.com/fmtlib/fmt/commit/05be7a0764f8fbfbdf9c9750ec54d49fe3d2419f
|
||||
Patch101: %{name}-use-float128-definition.patch
|
||||
|
||||
BuildRequires: cmake
|
||||
BuildRequires: gcc
|
||||
BuildRequires: gcc-c++
|
||||
|
Loading…
Reference in New Issue
Block a user