mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
28 lines
993 B
Diff
28 lines
993 B
Diff
From 63e46567fe7f9d3e48beaca7827125bfe06e1004 Mon Sep 17 00:00:00 2001
|
|
From: PJ Reiniger <pj.reiniger@gmail.com>
|
|
Date: Thu, 19 May 2022 01:12:41 -0400
|
|
Subject: [PATCH 31/31] constexpr endian byte swap
|
|
|
|
---
|
|
llvm/include/llvm/Support/Endian.h | 4 +++-
|
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/llvm/include/llvm/Support/Endian.h b/llvm/include/llvm/Support/Endian.h
|
|
index 5e7c1e961b9d..2e883ff05b7e 100644
|
|
--- a/llvm/include/llvm/Support/Endian.h
|
|
+++ b/llvm/include/llvm/Support/Endian.h
|
|
@@ -55,7 +55,9 @@ inline value_type byte_swap(value_type value, endianness endian) {
|
|
/// Swap the bytes of value to match the given endianness.
|
|
template<typename value_type, endianness endian>
|
|
inline value_type byte_swap(value_type value) {
|
|
- return byte_swap(value, endian);
|
|
+ if constexpr ((endian != native) && (endian != system_endianness()))
|
|
+ sys::swapByteOrder(value);
|
|
+ return value;
|
|
}
|
|
|
|
/// Read a value of a particular endianness from memory.
|
|
--
|
|
2.20.1.windows.1
|
|
|