Skip to content

Commit

Permalink
exec: Declare target_words_bigendian() in 'exec/tswap.h'
Browse files Browse the repository at this point in the history
We usually check target endianess before swapping values,
so target_words_bigendian() declaration makes sense in
"exec/tswap.h" with the target swapping helpers.

Remove "hw/core/cpu.h" when it was only included to get
the target_words_bigendian() declaration.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Anton Johansson <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
  • Loading branch information
philmd committed Apr 26, 2024
1 parent 77166c4 commit 4250826
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
1 change: 1 addition & 0 deletions cpu-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#endif
#include "sysemu/cpus.h"
#include "sysemu/tcg.h"
#include "exec/tswap.h"
#include "exec/replay-core.h"
#include "exec/cpu-common.h"
#include "exec/exec-all.h"
Expand Down
1 change: 1 addition & 0 deletions disas/disas.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "disas/disas.h"
#include "disas/capstone.h"
#include "hw/core/cpu.h"
#include "exec/tswap.h"
#include "exec/memory.h"

/* Filled in by elfload.c. Simplistic, but will do for now. */
Expand Down
2 changes: 1 addition & 1 deletion hw/audio/virtio-snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#include "qemu/log.h"
#include "qemu/error-report.h"
#include "include/qemu/lockable.h"
#include "exec/tswap.h"
#include "sysemu/runstate.h"
#include "trace.h"
#include "qapi/error.h"
#include "hw/audio/virtio-snd.h"
#include "hw/core/cpu.h"

#define VIRTIO_SOUND_VM_VERSION 1
#define VIRTIO_SOUND_JACK_DEFAULT 0
Expand Down
2 changes: 1 addition & 1 deletion hw/core/cpu-sysemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "qemu/osdep.h"
#include "qapi/error.h"
#include "hw/core/cpu.h"
#include "exec/tswap.h"
#include "hw/core/sysemu-cpu-ops.h"

bool cpu_paging_enabled(const CPUState *cpu)
Expand Down
2 changes: 1 addition & 1 deletion hw/core/generic-loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/

#include "qemu/osdep.h"
#include "hw/core/cpu.h"
#include "exec/tswap.h"
#include "sysemu/dma.h"
#include "sysemu/reset.h"
#include "hw/boards.h"
Expand Down
2 changes: 1 addition & 1 deletion hw/display/vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "qemu/units.h"
#include "sysemu/reset.h"
#include "qapi/error.h"
#include "hw/core/cpu.h"
#include "exec/tswap.h"
#include "hw/display/vga.h"
#include "hw/i386/x86.h"
#include "hw/pci/pci.h"
Expand Down
1 change: 1 addition & 0 deletions hw/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "qemu/module.h"
#include "exec/tswap.h"
#include "qom/object_interfaces.h"
#include "hw/core/cpu.h"
#include "hw/virtio/virtio.h"
Expand Down
12 changes: 11 additions & 1 deletion include/exec/tswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@
#ifndef TSWAP_H
#define TSWAP_H

#include "hw/core/cpu.h"
#include "qemu/bswap.h"

/**
* target_words_bigendian:
* Returns true if the (default) endianness of the target is big endian,
* false otherwise. Note that in target-specific code, you can use
* TARGET_BIG_ENDIAN directly instead. On the other hand, common
* code should normally never need to know about the endianness of the
* target, so please do *not* use this function unless you know very well
* what you are doing!
*/
bool target_words_bigendian(void);

/*
* If we're in target-specific code, we can hard-code the swapping
* condition, otherwise we have to do (slower) run-time checks.
Expand Down
11 changes: 0 additions & 11 deletions include/hw/core/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1168,17 +1168,6 @@ bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
void cpu_exec_unrealizefn(CPUState *cpu);
void cpu_exec_reset_hold(CPUState *cpu);

/**
* target_words_bigendian:
* Returns true if the (default) endianness of the target is big endian,
* false otherwise. Note that in target-specific code, you can use
* TARGET_BIG_ENDIAN directly instead. On the other hand, common
* code should normally never need to know about the endianness of the
* target, so please do *not* use this function unless you know very well
* what you are doing!
*/
bool target_words_bigendian(void);

const char *target_name(void);

#ifdef COMPILING_PER_TARGET
Expand Down

0 comments on commit 4250826

Please sign in to comment.