Guard the native endian APIs we want to remove by surrounding
them with TARGET_USE_LEGACY_NATIVE_ENDIAN_API #ifdef'ry.
Once a target gets cleaned we'll unset the definition in the
target config, then the target won't be able to use the legacy
API anymore.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/accel/tcg/cpu-ldst.h | 2 ++
include/exec/translator.h | 2 +-
include/qemu/bswap.h | 5 +++++
include/system/memory_cached.h | 2 ++
system/memory-internal.h | 2 ++
include/exec/memory_ldst.h.inc | 2 ++
include/exec/memory_ldst_phys.h.inc | 2 ++
system/memory_ldst.c.inc | 2 ++
8 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/include/accel/tcg/cpu-ldst.h b/include/accel/tcg/cpu-ldst.h
index 0de7f5eaa6b..91b618c2f41 100644
--- a/include/accel/tcg/cpu-ldst.h
+++ b/include/accel/tcg/cpu-ldst.h
@@ -428,6 +428,7 @@ cpu_stq_le_data(CPUArchState *env, abi_ptr addr, uint64_t val)
cpu_stq_le_data_ra(env, addr, val, 0);
}
+#ifdef TARGET_USE_LEGACY_NATIVE_ENDIAN_API
#if TARGET_BIG_ENDIAN
# define cpu_lduw_data cpu_lduw_be_data
# define cpu_ldsw_data cpu_ldsw_be_data
@@ -501,5 +502,6 @@ static inline uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr)
MemOpIdx oi = make_memop_idx(MO_TEUQ, cpu_mmu_index(cs, true));
return cpu_ldq_code_mmu(env, addr, oi, 0);
}
+#endif /* TARGET_USE_LEGACY_NATIVE_ENDIAN_API */
#endif /* ACCEL_TCG_CPU_LDST_H */
diff --git a/include/exec/translator.h b/include/exec/translator.h
index 3c326555696..30e6596c5d7 100644
--- a/include/exec/translator.h
+++ b/include/exec/translator.h
@@ -188,7 +188,7 @@ uint32_t translator_ldl_end(CPUArchState *env, DisasContextBase *db,
uint64_t translator_ldq_end(CPUArchState *env, DisasContextBase *db,
vaddr pc, MemOp endian);
-#ifdef COMPILING_PER_TARGET
+#if defined(TARGET_USE_LEGACY_NATIVE_ENDIAN_API) && defined(COMPILING_PER_TARGET)
static inline uint16_t
translator_lduw(CPUArchState *env, DisasContextBase *db, vaddr pc)
{
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 65a1b3634f4..8b0070d26a6 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -412,7 +412,9 @@ static inline void stq_be_p(void *ptr, uint64_t v)
} \
}
+#ifdef TARGET_USE_LEGACY_NATIVE_ENDIAN_API
DO_STN_LDN_P(he)
+#endif
DO_STN_LDN_P(le)
DO_STN_LDN_P(be)
@@ -423,6 +425,7 @@ DO_STN_LDN_P(be)
#undef le_bswaps
#undef be_bswaps
+#ifdef TARGET_USE_LEGACY_NATIVE_ENDIAN_API
/* Return ld{word}_{le,be}_p following target endianness. */
#define LOAD_IMPL(word, args...) \
@@ -494,4 +497,6 @@ static inline void stn_p(void *ptr, int sz, uint64_t v)
#undef STORE_IMPL
+#endif /* TARGET_USE_LEGACY_NATIVE_ENDIAN_API */
+
#endif /* BSWAP_H */
diff --git a/include/system/memory_cached.h b/include/system/memory_cached.h
index 1a07774b6ad..356023f5729 100644
--- a/include/system/memory_cached.h
+++ b/include/system/memory_cached.h
@@ -77,8 +77,10 @@ static inline void address_space_stb_cached(MemoryRegionCache *cache,
}
}
+#ifdef TARGET_USE_LEGACY_NATIVE_ENDIAN_API
#define ENDIANNESS
#include "exec/memory_ldst_cached.h.inc"
+#endif
#define ENDIANNESS _le
#include "exec/memory_ldst_cached.h.inc"
diff --git a/system/memory-internal.h b/system/memory-internal.h
index 46f758fa7e4..d781d437642 100644
--- a/system/memory-internal.h
+++ b/system/memory-internal.h
@@ -41,9 +41,11 @@ void mtree_print_dispatch(struct AddressSpaceDispatch *d,
/* returns true if end is big endian. */
static inline bool devend_big_endian(enum device_endian end)
{
+#ifdef TARGET_USE_LEGACY_NATIVE_ENDIAN_API
if (end == DEVICE_NATIVE_ENDIAN) {
return target_big_endian();
}
+#endif
return end == DEVICE_BIG_ENDIAN;
}
diff --git a/include/exec/memory_ldst.h.inc b/include/exec/memory_ldst.h.inc
index dd1fb482eac..8ff6e563310 100644
--- a/include/exec/memory_ldst.h.inc
+++ b/include/exec/memory_ldst.h.inc
@@ -25,8 +25,10 @@ uint8_t glue(address_space_ldub, SUFFIX)(ARG1_DECL,
void glue(address_space_stb, SUFFIX)(ARG1_DECL,
hwaddr addr, uint8_t val, MemTxAttrs attrs, MemTxResult *result);
+#ifdef TARGET_USE_LEGACY_NATIVE_ENDIAN_API
#define ENDIANNESS
#include "system/memory_ldst_endian.h.inc"
+#endif /* TARGET_USE_LEGACY_NATIVE_ENDIAN_API */
#define ENDIANNESS _le
#include "system/memory_ldst_endian.h.inc"
diff --git a/include/exec/memory_ldst_phys.h.inc b/include/exec/memory_ldst_phys.h.inc
index f4c91dc7a91..e0da6d19a5b 100644
--- a/include/exec/memory_ldst_phys.h.inc
+++ b/include/exec/memory_ldst_phys.h.inc
@@ -31,8 +31,10 @@ static inline void glue(stb_phys, SUFFIX)(ARG1_DECL, hwaddr addr, uint8_t val)
MEMTXATTRS_UNSPECIFIED, NULL);
}
+#ifdef TARGET_USE_LEGACY_NATIVE_ENDIAN_API
#define ENDIANNESS
#include "system/memory_ldst_phys_endian.h.inc"
+#endif /* TARGET_USE_LEGACY_NATIVE_ENDIAN_API */
#define ENDIANNESS _le
#include "system/memory_ldst_phys_endian.h.inc"
diff --git a/system/memory_ldst.c.inc b/system/memory_ldst.c.inc
index 5a979ea6ac3..2f707e5f5b4 100644
--- a/system/memory_ldst.c.inc
+++ b/system/memory_ldst.c.inc
@@ -181,9 +181,11 @@ void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL, MemOp mop,
attrs, result);
}
+#ifdef TARGET_USE_LEGACY_NATIVE_ENDIAN_API
#define ENDIANNESS
#define MO_ENDIAN (target_big_endian() ? MO_BE : MO_LE)
#include "memory_ldst_endian.c.inc"
+#endif /* TARGET_USE_LEGACY_NATIVE_ENDIAN_API */
#define ENDIANNESS _le
#define MO_ENDIAN MO_LE
--
2.52.0
On 12/19/25 08:28, Philippe Mathieu-Daudé wrote: > --- a/include/qemu/bswap.h > +++ b/include/qemu/bswap.h > @@ -412,7 +412,9 @@ static inline void stq_be_p(void *ptr, uint64_t v) > } \ > } > > +#ifdef TARGET_USE_LEGACY_NATIVE_ENDIAN_API > DO_STN_LDN_P(he) > +#endif This isn't target native endian. Why is this included? r~
© 2016 - 2026 Red Hat, Inc.