2 * Macros for swapping a value if the endianness is different
3 * between the target and the host.
5 * SPDX-License-Identifier: LGPL-2.1-or-later
11 #include "hw/core/cpu.h"
12 #include "qemu/bswap.h"
15 * If we're in target-specific code, we can hard-code the swapping
16 * condition, otherwise we have to do (slower) run-time checks.
19 #define target_needs_bswap() (HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN)
21 #define target_needs_bswap() (target_words_bigendian() != HOST_BIG_ENDIAN)
24 static inline uint16_t tswap16(uint16_t s
)
26 if (target_needs_bswap()) {
33 static inline uint32_t tswap32(uint32_t s
)
35 if (target_needs_bswap()) {
42 static inline uint64_t tswap64(uint64_t s
)
44 if (target_needs_bswap()) {
51 static inline void tswap16s(uint16_t *s
)
53 if (target_needs_bswap()) {
58 static inline void tswap32s(uint32_t *s
)
60 if (target_needs_bswap()) {
65 static inline void tswap64s(uint64_t *s
)
67 if (target_needs_bswap()) {