mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-03-26 18:22:55 -07:00
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:
committed by
Michael S. Tsirkin
parent
16c9cb7187
commit
0f64fb6743
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user