qemu: Declare all load/store helper in 'qemu/bswap.h'

Restrict "exec/tswap.h" to the tswap*() methods,
move the load/store helpers with the other ones
declared in "qemu/bswap.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20250708215320.70426-8-philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2025-07-08 23:53:18 +02:00 committed by Michael S. Tsirkin
parent 16c9cb7187
commit 0f64fb6743
34 changed files with 87 additions and 93 deletions

View file

@ -22,8 +22,6 @@
#include "hw/acpi/bios-linker-loader.h"
#include "hw/nvram/fw_cfg.h"
#include "qemu/bswap.h"
/*
* Linker/loader is a paravirtualized interface that passes commands to guest.
* The commands can be used to request guest to

View file

@ -20,7 +20,6 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/bswap.h"
#include "qemu/module.h"
#include "qemu/units.h"
#include "hw/boards.h"

View file

@ -15,6 +15,7 @@
#include "hw/arm/boot.h"
#include "hw/arm/linux-boot-if.h"
#include "cpu.h"
#include "exec/tswap.h"
#include "exec/target_page.h"
#include "system/kvm.h"
#include "system/tcg.h"
@ -29,6 +30,7 @@
#include "qemu/config-file.h"
#include "qemu/option.h"
#include "qemu/units.h"
#include "qemu/bswap.h"
/* Kernel boot protocol is specified in the kernel docs
* Documentation/arm/Booting and Documentation/arm64/booting.txt

View file

@ -24,7 +24,7 @@
#include "hw/qdev-clock.h"
#include "hw/qdev-properties.h"
#include "qapi/error.h"
#include "qemu/bswap.h"
#include "exec/tswap.h"
#include "qemu/units.h"
#include "system/system.h"
#include "target/arm/cpu-qom.h"

View file

@ -33,7 +33,6 @@
#include "qemu/osdep.h"
#include "system/block-backend.h"
#include "qapi/qapi-types-block.h"
#include "qemu/bswap.h"
#include "hw/block/block.h"
#include "trace.h"

View file

@ -29,7 +29,6 @@
#include "qemu/timer.h"
#include "qemu/error-report.h"
#include "system/address-spaces.h"
#include "exec/tswap.h"
#include "system/dma.h"
#include "system/runstate.h"
#include "trace.h"

View file

@ -8,8 +8,6 @@
*/
#include "qemu/osdep.h"
#include "qemu/bswap.h"
#include "qemu/error-report.h"
#include "hw/pci/msi.h"
#include "hw/pci/msix.h"

View file

@ -12,6 +12,7 @@
#include "qemu/log.h"
#include "qemu/module.h"
#include "qemu/units.h"
#include "qemu/bswap.h"
#include "qapi/error.h"
#include "hw/sysbus.h"
#include "hw/loader.h"

View file

@ -22,6 +22,7 @@
#include "vga-access.h"
#include "hw/qdev-properties.h"
#include "vga_regs.h"
#include "qemu/bswap.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "qemu/error-report.h"

View file

@ -28,7 +28,6 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/bswap.h"
#include "qemu/bitops.h"
#include "hw/irq.h"
#include "migration/vmstate.h"

View file

@ -21,6 +21,7 @@
#include "hw/ptimer.h"
#include "hw/qdev-properties.h"
#include "qapi/error.h"
#include "qemu/bswap.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include <zlib.h> /* for crc32 */

View file

@ -57,6 +57,7 @@
#include "system/dma.h"
#include "qemu/module.h"
#include "qemu/timer.h"
#include "qemu/bswap.h"
#include "net/net.h"
#include "net/eth.h"
#include "system/system.h"

View file

@ -22,7 +22,6 @@
#include "net/tap.h"
#include "net/checksum.h"
#include "system/system.h"
#include "qemu/bswap.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "hw/pci/msix.h"

View file

@ -28,6 +28,7 @@
#include "qapi/error.h"
#include "qemu/units.h"
#include "qemu/log.h"
#include "qemu/bswap.h"
#include "hw/qdev-properties.h"
#include "hw/registerfields.h"
#include "hw/pci/pci_device.h"

View file

@ -8,6 +8,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/bswap.h"
#include "qapi/visitor.h"
#include "qapi/error.h"
#include "hw/pci-host/pnv_phb3_regs.h"

View file

@ -8,6 +8,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/bswap.h"
#include "qapi/visitor.h"
#include "qapi/error.h"
#include "target/ppc/cpu.h"

View file

@ -20,7 +20,6 @@
#include "migration/vmstate.h"
#include "hw/pci/pci_device.h"
#include "hw/pci/pci_host.h"
#include "qemu/bswap.h"
#include "hw/pci-host/ppce500.h"
#include "qom/object.h"

View file

@ -28,7 +28,6 @@
#include "hw/irq.h"
#include "hw/pci/pci_device.h"
#include "hw/pci/pci_host.h"
#include "qemu/bswap.h"
#include "qemu/module.h"
#include "qom/object.h"

View file

@ -16,6 +16,7 @@
#include "exec/target_page.h"
#include "system/memory.h"
#include "qemu/error-report.h"
#include "qemu/bswap.h"
#include "system/hw_accel.h"
#include "hw/boards.h"
#include "hw/pci/pci_device.h"

View file

@ -28,7 +28,6 @@
#include "qapi/visitor.h"
#include "qemu/module.h"
#include "qemu/log.h"
#include "qemu/bswap.h"
enum LSM303DLHCMagReg {
LSM303DLHC_MAG_REG_CRA = 0x00,

View file

@ -17,6 +17,7 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
#include "qemu/bswap.h"
#include "qapi/error.h"
#include "qemu/config-file.h"
#include "qemu/module.h"

View file

@ -13,7 +13,6 @@
#include "hw/vfio/vfio-device.h"
#include "migration/misc.h"
#include "qapi/error.h"
#include "qemu/bswap.h"
#include "qemu/error-report.h"
#include "qemu/lockable.h"
#include "qemu/main-loop.h"

View file

@ -30,6 +30,7 @@
#include "qemu/error-report.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "qemu/bswap.h"
#include "hw/pci/msi.h"
#include "hw/pci/msix.h"
#include "hw/loader.h"

View file

@ -19,7 +19,6 @@
#include "hw/vmapple/vmapple.h"
#include "hw/virtio/virtio-blk.h"
#include "hw/virtio/virtio-pci.h"
#include "qemu/bswap.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "qapi/error.h"

View file

@ -69,74 +69,4 @@ static inline void tswap64s(uint64_t *s)
}
}
/* Return ld{word}_{le,be}_p following target endianness. */
#define LOAD_IMPL(word, args...) \
do { \
if (target_big_endian()) { \
return glue(glue(ld, word), _be_p)(args); \
} else { \
return glue(glue(ld, word), _le_p)(args); \
} \
} while (0)
static inline int lduw_p(const void *ptr)
{
LOAD_IMPL(uw, ptr);
}
static inline int ldsw_p(const void *ptr)
{
LOAD_IMPL(sw, ptr);
}
static inline int ldl_p(const void *ptr)
{
LOAD_IMPL(l, ptr);
}
static inline uint64_t ldq_p(const void *ptr)
{
LOAD_IMPL(q, ptr);
}
static inline uint64_t ldn_p(const void *ptr, int sz)
{
LOAD_IMPL(n, ptr, sz);
}
#undef LOAD_IMPL
/* Call st{word}_{le,be}_p following target endianness. */
#define STORE_IMPL(word, args...) \
do { \
if (target_big_endian()) { \
glue(glue(st, word), _be_p)(args); \
} else { \
glue(glue(st, word), _le_p)(args); \
} \
} while (0)
static inline void stw_p(void *ptr, uint16_t v)
{
STORE_IMPL(w, ptr, v);
}
static inline void stl_p(void *ptr, uint32_t v)
{
STORE_IMPL(l, ptr, v);
}
static inline void stq_p(void *ptr, uint64_t v)
{
STORE_IMPL(q, ptr, v);
}
static inline void stn_p(void *ptr, int sz, uint64_t v)
{
STORE_IMPL(n, ptr, sz, v);
}
#undef STORE_IMPL
#endif /* TSWAP_H */

View file

@ -1,6 +1,8 @@
#ifndef BSWAP_H
#define BSWAP_H
#include "qemu/target-info.h"
#undef bswap16
#define bswap16(_x) __builtin_bswap16(_x)
#undef bswap32
@ -432,4 +434,75 @@ DO_STN_LDN_P(be)
#undef le_bswaps
#undef be_bswaps
/* Return ld{word}_{le,be}_p following target endianness. */
#define LOAD_IMPL(word, args...) \
do { \
if (target_big_endian()) { \
return glue(glue(ld, word), _be_p)(args); \
} else { \
return glue(glue(ld, word), _le_p)(args); \
} \
} while (0)
static inline int lduw_p(const void *ptr)
{
LOAD_IMPL(uw, ptr);
}
static inline int ldsw_p(const void *ptr)
{
LOAD_IMPL(sw, ptr);
}
static inline int ldl_p(const void *ptr)
{
LOAD_IMPL(l, ptr);
}
static inline uint64_t ldq_p(const void *ptr)
{
LOAD_IMPL(q, ptr);
}
static inline uint64_t ldn_p(const void *ptr, int sz)
{
LOAD_IMPL(n, ptr, sz);
}
#undef LOAD_IMPL
/* Call st{word}_{le,be}_p following target endianness. */
#define STORE_IMPL(word, args...) \
do { \
if (target_big_endian()) { \
glue(glue(st, word), _be_p)(args); \
} else { \
glue(glue(st, word), _le_p)(args); \
} \
} while (0)
static inline void stw_p(void *ptr, uint16_t v)
{
STORE_IMPL(w, ptr, v);
}
static inline void stl_p(void *ptr, uint32_t v)
{
STORE_IMPL(l, ptr, v);
}
static inline void stq_p(void *ptr, uint64_t v)
{
STORE_IMPL(q, ptr, v);
}
static inline void stn_p(void *ptr, int sz, uint64_t v)
{
STORE_IMPL(n, ptr, sz, v);
}
#undef STORE_IMPL
#endif /* BSWAP_H */

View file

@ -19,7 +19,6 @@
#include "exec/memattrs.h"
#include "exec/memop.h"
#include "exec/ramlist.h"
#include "exec/tswap.h"
#include "qemu/bswap.h"
#include "qemu/queue.h"
#include "qemu/int128.h"

View file

@ -6,7 +6,6 @@
#endif
#include "exec/cpu-defs.h"
#include "exec/tswap.h"
#include "user/tswap-target.h"
#ifdef TARGET_ABI32

View file

@ -23,7 +23,6 @@
#include "qemu/timer.h"
#include "qemu/log.h"
#include "exec/page-vary.h"
#include "exec/tswap.h"
#include "target/arm/idau.h"
#include "qemu/module.h"
#include "qapi/error.h"

View file

@ -25,7 +25,6 @@
#include "exec/page-protection.h"
#include "exec/target_page.h"
#include "exec/tlb-flags.h"
#include "exec/tswap.h"
#include "tcg/helper-tcg.h"
typedef struct TranslateParams {

View file

@ -5,7 +5,6 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/tswap.h"
void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint32_t buflen)
{

View file

@ -1,8 +1,6 @@
#ifndef MMU_HASH64_H
#define MMU_HASH64_H
#include "exec/tswap.h"
#ifndef CONFIG_USER_ONLY
#ifdef TARGET_PPC64

View file

@ -27,7 +27,6 @@
#include "exec/helper-proto.h"
#include "exec/tlb-flags.h"
#include "exec/target_page.h"
#include "exec/tswap.h"
#include "fpu/softfloat.h"
#include "tcg/tcg-gvec-desc.h"
#include "internals.h"

View file

@ -20,6 +20,7 @@
* few things provided by compiler.h.
*/
#include <compiler.h>
#include <stdbool.h>
#include <bswap.h>
#include <qemu-plugin.h>