From 238bb6635ec1b947ae4be38148c4bc18e987fc71 Mon Sep 17 00:00:00 2001 From: Vitaly Zaitsev Date: Tue, 4 Jan 2022 14:28:40 +0100 Subject: [PATCH] Added proposed upstream patch with Big Endian fixes. --- fmt-big-endian-fixes.patch | 36 ++++++++++++++++++++++++++++++++++++ fmt.spec | 3 +++ 2 files changed, 39 insertions(+) create mode 100644 fmt-big-endian-fixes.patch diff --git a/fmt-big-endian-fixes.patch b/fmt-big-endian-fixes.patch new file mode 100644 index 0000000..94142d5 --- /dev/null +++ b/fmt-big-endian-fixes.patch @@ -0,0 +1,36 @@ +From 0273005bf5e92f1bbf230b654939489b01eb2eb3 Mon Sep 17 00:00:00 2001 +From: Vladislav Shchapov +Date: Tue, 4 Jan 2022 15:04:30 +0500 +Subject: [PATCH] Fix endianness bug in write_digit2_separated + +--- + include/fmt/chrono.h | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h +index 908999ab5f..c52be81ca6 100644 +--- a/include/fmt/chrono.h ++++ b/include/fmt/chrono.h +@@ -558,6 +558,22 @@ inline void write_digit2_separated(char* buf, unsigned a, unsigned b, + auto usep = static_cast(sep); + // Add ASCII '0' to each digit byte and insert separators. + digits |= 0x3030003030003030 | (usep << 16) | (usep << 40); ++#ifndef _WIN32 ++# if defined(__GNUC__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ++ digits = __builtin_bswap64(digits); ++# else ++ if (is_big_endian()) { ++ digits = ((digits & 0xff00000000000000ull) >> 56) | ++ ((digits & 0x00ff000000000000ull) >> 40) | ++ ((digits & 0x0000ff0000000000ull) >> 24) | ++ ((digits & 0x000000ff00000000ull) >> 8) | ++ ((digits & 0x00000000ff000000ull) << 8) | ++ ((digits & 0x0000000000ff0000ull) << 24) | ++ ((digits & 0x000000000000ff00ull) << 40) | ++ ((digits & 0x00000000000000ffull) << 56); ++ } ++# endif ++#endif + memcpy(buf, &digits, 8); + } + diff --git a/fmt.spec b/fmt.spec index bd44adf..ba30416 100644 --- a/fmt.spec +++ b/fmt.spec @@ -9,6 +9,9 @@ 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/pull/2699 +Patch100: %{name}-big-endian-fixes.patch + BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: ninja-build