[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v5 06/16] xen/decompressors: Remove use of *_to_cpup() helpers
From: Lin Liu <lin.liu@xxxxxxxxxx> These wrappers simply hide a deference, which adds to the cognitive complexity of reading the code. As such, they're not going to be included in the new byteswap infrastructure. No functional change. Signed-off-by: Lin Liu <lin.liu@xxxxxxxxxx> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Anthony PERARD <anthony.perard@xxxxxxxxxx> CC: Michal Orzel <michal.orzel@xxxxxxx> CC: Jan Beulich <jbeulich@xxxxxxxx> CC: Julien Grall <julien@xxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx> CC: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx> CC: Bertrand Marquis <bertrand.marquis@xxxxxxx> CC: Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx> CC: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx> CC: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx> CC: Lin Liu <lin.liu@xxxxxxxxxx> v5: * Rebase * Rearranged from other patches --- tools/libs/guest/xg_dom_decompress_unsafe_xz.c | 13 +++++++------ xen/common/lz4/defs.h | 6 +++++- xen/common/xz/private.h | 12 +++++++++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_xz.c b/tools/libs/guest/xg_dom_decompress_unsafe_xz.c index 80eed912dd68..7dbd2622c3b8 100644 --- a/tools/libs/guest/xg_dom_decompress_unsafe_xz.c +++ b/tools/libs/guest/xg_dom_decompress_unsafe_xz.c @@ -19,18 +19,19 @@ typedef uint32_t __le32; static inline u32 cpu_to_le32(const u32 v) { #if BYTE_ORDER == BIG_ENDIAN - return (((v & 0x000000ffUL) << 24) | - ((v & 0x0000ff00UL) << 8) | - ((v & 0x00ff0000UL) >> 8) | - ((v & 0xff000000UL) >> 24)); + return __builtin_bswap32(v); #else return v; #endif } -static inline u32 le32_to_cpup(const u32 *p) +static inline u32 le32_to_cpu(const u32 p) { - return cpu_to_le32(*p); +#if BYTE_ORDER == BIG_ENDIAN + return __builtin_bswap32(v); +#else + return v; +#endif } #define __force diff --git a/xen/common/lz4/defs.h b/xen/common/lz4/defs.h index ecfbf07f8323..e477806634c1 100644 --- a/xen/common/lz4/defs.h +++ b/xen/common/lz4/defs.h @@ -18,7 +18,11 @@ static inline u16 get_unaligned_le16(const void *p) { - return le16_to_cpup(p); + u16 v; + + memcpy(&v, p, sizeof(v)); + + return le16_to_cpu(v); } #endif diff --git a/xen/common/xz/private.h b/xen/common/xz/private.h index 2299705378ac..a63379994fd6 100644 --- a/xen/common/xz/private.h +++ b/xen/common/xz/private.h @@ -18,17 +18,23 @@ static inline u32 get_unaligned_le32(const void *p) { - return le32_to_cpup(p); + u32 v; + + memcpy(&v, p, sizeof(v)); + + return le32_to_cpu(v); } static inline void put_unaligned_le32(u32 val, void *p) { - *(__force __le32*)p = cpu_to_le32(val); + u32 v = cpu_to_le32(val); + + memcpy(p, &v, sizeof(v)); } #endif -#define get_le32(p) le32_to_cpup((const uint32_t *)(p)) +#define get_le32(p) le32_to_cpu(*(const uint32_t *)(p)) #define false 0 #define true 1 -- 2.39.5
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |