Added proposed upstream patch with Big Endian fixes.
This commit is contained in:
parent
d1027a01ed
commit
238bb6635e
36
fmt-big-endian-fixes.patch
Normal file
36
fmt-big-endian-fixes.patch
Normal file
@ -0,0 +1,36 @@
|
||||
From 0273005bf5e92f1bbf230b654939489b01eb2eb3 Mon Sep 17 00:00:00 2001
|
||||
From: Vladislav Shchapov <phprus@gmail.com>
|
||||
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<unsigned long long>(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);
|
||||
}
|
||||
|
3
fmt.spec
3
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
|
||||
|
Loading…
Reference in New Issue
Block a user