[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/8] qemu/bswap: Add const_le64()
From: |
Ira Weiny |
Subject: |
[PATCH v2 1/8] qemu/bswap: Add const_le64() |
Date: |
Wed, 21 Dec 2022 20:24:31 -0800 |
Gcc requires constant versions of cpu_to_le* calls.
Add a 64 bit version.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
Changes from RFC:
Peter
Change order of the definitions, 64-32-16
---
include/qemu/bswap.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 346d05f2aab3..e1eca22f2548 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -187,6 +187,15 @@ CPU_CONVERT(le, 64, uint64_t)
* used to initialize static variables.
*/
#if HOST_BIG_ENDIAN
+# define const_le64(_x) \
+ ((((_x) & 0x00000000000000ffU) << 56) | \
+ (((_x) & 0x000000000000ff00U) << 40) | \
+ (((_x) & 0x0000000000ff0000U) << 24) | \
+ (((_x) & 0x00000000ff000000U) << 8) | \
+ (((_x) & 0x000000ff00000000U) >> 8) | \
+ (((_x) & 0x0000ff0000000000U) >> 24) | \
+ (((_x) & 0x00ff000000000000U) >> 40) | \
+ (((_x) & 0xff00000000000000U) >> 56))
# define const_le32(_x) \
((((_x) & 0x000000ffU) << 24) | \
(((_x) & 0x0000ff00U) << 8) | \
@@ -196,6 +205,7 @@ CPU_CONVERT(le, 64, uint64_t)
((((_x) & 0x00ff) << 8) | \
(((_x) & 0xff00) >> 8))
#else
+# define const_le64(_x) (_x)
# define const_le32(_x) (_x)
# define const_le16(_x) (_x)
#endif
--
2.38.1
- [PATCH v2 0/8] QEMU CXL Provide mock CXL events and irq support, Ira Weiny, 2022/12/21
- [PATCH v2 1/8] qemu/bswap: Add const_le64(),
Ira Weiny <=
- [PATCH v2 3/8] hw/cxl/mailbox: Use new UUID network order define for cel_uuid, Ira Weiny, 2022/12/21
- [PATCH v2 6/8] hw/cxl/events: Add event interrupt support, Ira Weiny, 2022/12/21
- [PATCH v2 2/8] qemu/uuid: Add UUID static initializer, Ira Weiny, 2022/12/21
- [PATCH v2 4/8] hw/cxl/events: Add event status register, Ira Weiny, 2022/12/21
- [PATCH v2 5/8] hw/cxl/events: Wire up get/clear event mailbox commands, Ira Weiny, 2022/12/21
- [PATCH v2 7/8] bswap: Add the ability to store to an unaligned 24 bit field, Ira Weiny, 2022/12/21
- [PATCH v2 8/8] hw/cxl/events: Add in inject general media event, Ira Weiny, 2022/12/21