]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qemu: Declare all load/store helper in 'qemu/bswap.h'
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 8 Jul 2025 21:53:18 +0000 (23:53 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 15 Jul 2025 06:56:39 +0000 (02:56 -0400)
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>
34 files changed:
hw/acpi/bios-linker-loader.c
hw/arm/allwinner-r40.c
hw/arm/boot.c
hw/arm/npcm7xx.c
hw/block/hd-geometry.c
hw/char/riscv_htif.c
hw/cxl/cxl-events.c
hw/display/artist.c
hw/display/ati.c
hw/net/can/ctucan_core.c
hw/net/lan9118.c
hw/net/rtl8139.c
hw/net/vmxnet3.c
hw/pci-host/gt64120.c
hw/pci-host/pnv_phb3.c
hw/pci-host/pnv_phb4.c
hw/pci-host/ppce500.c
hw/pci-host/sh_pci.c
hw/s390x/s390-pci-inst.c
hw/sensor/lsm303dlhc_mag.c
hw/smbios/smbios.c
hw/vfio/migration-multifd.c
hw/virtio/virtio-pci.c
hw/vmapple/virtio-blk.c
include/exec/tswap.h
include/qemu/bswap.h
include/system/memory.h
include/user/abitypes.h
target/arm/cpu.c
target/i386/tcg/system/excp_helper.c
target/i386/xsave_helper.c
target/ppc/mmu-hash64.h
target/riscv/vector_helper.c
tests/tcg/plugins/mem.c

index 108061828b1cc491848d2e7ff8e344dd71c82dd7..c9ffe449aac9d6fce0a2d5e9791916c694d70d49 100644 (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
index 0bf700865c25e20026f3fccbe9a70cb1db8d77da..c8eda39957c406d3186bb05d664c4a804c36953f 100644 (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"
index becd827af130f132c1ecb043ea4b233c7fbaebf9..d391cd01bb1b92ff213e69b84e5a69413b36c4f8 100644 (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
index 2f30c49df55d450349674d89b790c6ded576d679..ecfae328a96a49c82beaa53a5d803469c8f02d91 100644 (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"
index f3939e73f42b0cc66035a6f93a04009fab30eaa3..db221901cf4b290b5090571503e623826c7a74cc 100644 (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"
 
index c884be5d7578a47eed5ec76b496683bf5be3bab7..a78ea9b01c054ab3da76fe066a64886a9c92a6e8 100644 (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"
index 12dee2e4675864fd87d73f0ec41b13999f6b2c2b..f90470930d6ce7fb7e5795d36c594eb77b235efe 100644 (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"
index 3fafc8a222be028474502f9fd82435110e5d4371..3c884c92437c97c21446a3c4a3486b5006ab32a5 100644 (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"
index 7de27732cdc9748f083919dc2f1f62121f30affe..f7c0006a879d5379ec2fdf30005066048c301878 100644 (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"
index 17131a4e18fa90a9c44ac4143c15ae66224ac398..6bd99c477b231ddb68a4a4c2de4a38079cd421f9 100644 (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"
index 6dda1e5c940d42ef7e1cc624b2520a5c2d477649..3017e129710da44e195cbbf93e48bf72f311f48e 100644 (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 */
index 654a087d80ad04a21eccf079bf213aa409a4377d..324fb932aaceeace2fcb18abfda61625f12d506e 100644 (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"
index 7c0ca56b7c0553d29a91d87e07b809ef7a3eb2fb..af73aa8ef285d7137355ef61ccb7eafe27a37a0b 100644 (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"
index b12a25696c44c45f7478dc0c107ed57f904a4fdd..b1d96f62fe94039b0b62a1de0d58f1d6e534b156 100644 (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"
index a4335f44f221e0ea78a0d81e2b5dc67dbd6b34f9..5d8383fac3041d4e7edc5a35a4ee02b9b1f11148 100644 (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"
index 77ea35299d37d504998e58467be033c0a2ca3eaa..18992054e831c3fbbb8f140722d85584e2b6a1df 100644 (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"
index 52269b05bb19e7147cd32f9c41e785add629d91e..975d191ccb8e467474470ad47e51d271f4799e29 100644 (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"
 
index de8f6a84aabedb357fb164046c1d0d7786f5f6d8..62fb945075f80920d12b268e440c5b30793e6789 100644 (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"
 
index b5dddb22b84d72daa03722cbfb2bfc318dc99f59..a3bb5aa22168f66ff83c2da0528d89547834b501 100644 (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"
index f9e501da84019b894cca553641658f2e7bb3d80b..cd5773ae64e8d3bba3f6b23eb6d716d168589c99 100644 (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,
index ad4cd6721e618973d2f8b15423257373ca0d81f8..1ac063cfb4ba89d5a25844ae21a76bc524b9a5b2 100644 (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"
index 55635486c8f185ec2e417c9403ea5dad82d10c18..9dc70fdf16bc083910bf34e2e33ec0b0b4241491 100644 (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"
index fba2372c93bfd648736b07e4bc83e7097baa58cb..767216d795998708f5716a23ae16c79cd90ff489 100644 (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"
index 532b5649ab70bba6048d09a567c2c190e9a9940a..9de9aaae0bfc743b25edb30e88f4ebe0c6fdbcfa 100644 (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"
index 55ffa6335986d08f39943bbcb29776e8123ab39f..72219e2c4317a0933ace2f1e6a3f252ac2c1a875 100644 (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 */
index 9a117645360650ea84fa70e6483374c563135b65..39ba64046a69c38307efdf397f4336b81817743d 100644 (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 */
index d6d069fd50c0d49b0a50cc6331fb6e2b3c445b80..e2cd6ed126144abaed6f3035e3ef091d747b4c34 100644 (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"
index 7528124b62f3e257925832037a2b240475078ae6..be7a8765238266e8044d36910f643372750c0751 100644 (file)
@@ -6,7 +6,6 @@
 #endif
 
 #include "exec/cpu-defs.h"
-#include "exec/tswap.h"
 #include "user/tswap-target.h"
 
 #ifdef TARGET_ABI32
index 08c43f674a2a3146398a22423452f2db06c5700b..e2b2337399cf5c86d74d91aaa89175d7d98d7780 100644 (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"
index c16262158774186a97285de76fa590a29ec1d3b5..50040f6fcafabfb77351a05baa580145402b7187 100644 (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 {
index 24ab7be8e9a2c9cd0ad6ebaac2f1b3cde58bee3c..996e9f3bfef53b14a55963db4ece3254bb33b470 100644 (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)
 {
index b8fb12a97054de6b9c373af5f96e350cc2c3ec63..ae8d4b37aed0b71a1c1fc7e0a227eb39d132d35d 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef MMU_HASH64_H
 #define MMU_HASH64_H
 
-#include "exec/tswap.h"
-
 #ifndef CONFIG_USER_ONLY
 
 #ifdef TARGET_PPC64
index b41c29da0be1fa869f745a3b9f753701850c59c5..7c67d67a13f6c427e4a45085b600f3db1f4b7981 100644 (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"
index ca4e8883dd2032a8e8c58976ef355c0527ef9098..9649bce99ca0645a3576bf060e28c6f9b9d8e92b 100644 (file)
@@ -20,6 +20,7 @@
  * few things provided by compiler.h.
  */
 #include <compiler.h>
+#include <stdbool.h>
 #include <bswap.h>
 #include <qemu-plugin.h>