diff mbox series

[3/3] softmmu: Make qtest.c target independent

Message ID 20230411183418.1640500-4-thuth@redhat.com
State Handled Elsewhere
Headers show
Series Make softmmu/qtest.c target independent | expand

Commit Message

Thomas Huth April 11, 2023, 6:34 p.m. UTC
The code in this file is not performance critical, so we can use
the target independent endianess functions to only compile this
file once for all targets.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 softmmu/qtest.c     | 12 ++++++------
 softmmu/meson.build |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

Comments

Cédric Le Goater April 12, 2023, 10:53 a.m. UTC | #1
On 4/11/23 20:34, Thomas Huth wrote:
> The code in this file is not performance critical, so we can use
> the target independent endianess functions to only compile this
> file once for all targets.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.

> ---
>   softmmu/qtest.c     | 12 ++++++------
>   softmmu/meson.build |  2 +-
>   2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/softmmu/qtest.c b/softmmu/qtest.c
> index 76cbb8bcee..9f2197fd6f 100644
> --- a/softmmu/qtest.c
> +++ b/softmmu/qtest.c
> @@ -13,12 +13,12 @@
>   
>   #include "qemu/osdep.h"
>   #include "qapi/error.h"
> -#include "cpu.h"
>   #include "sysemu/qtest.h"
>   #include "sysemu/runstate.h"
>   #include "chardev/char-fe.h"
>   #include "exec/ioport.h"
>   #include "exec/memory.h"
> +#include "exec/tswap.h"
>   #include "hw/qdev-core.h"
>   #include "hw/irq.h"
>   #include "qemu/accel.h"
> @@ -717,11 +717,11 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
>           qtest_send(chr, "OK\n");
>       } else if (strcmp(words[0], "endianness") == 0) {
>           qtest_send_prefix(chr);
> -#if TARGET_BIG_ENDIAN
> -        qtest_sendf(chr, "OK big\n");
> -#else
> -        qtest_sendf(chr, "OK little\n");
> -#endif
> +        if (target_words_bigendian()) {
> +            qtest_sendf(chr, "OK big\n");
> +        } else {
> +            qtest_sendf(chr, "OK little\n");
> +        }
>       } else if (qtest_enabled() && strcmp(words[0], "clock_step") == 0) {
>           int64_t ns;
>   
> diff --git a/softmmu/meson.build b/softmmu/meson.build
> index 1a7c7ac089..b392f0bd35 100644
> --- a/softmmu/meson.build
> +++ b/softmmu/meson.build
> @@ -3,7 +3,6 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files(
>     'ioport.c',
>     'memory.c',
>     'physmem.c',
> -  'qtest.c',
>     'dirtylimit.c',
>     'watchpoint.c',
>   )])
> @@ -23,6 +22,7 @@ softmmu_ss.add(files(
>     'globals.c',
>     'memory_mapping.c',
>     'qdev-monitor.c',
> +  'qtest.c',
>     'rtc.c',
>     'runstate-action.c',
>     'runstate-hmp-cmds.c',
diff mbox series

Patch

diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 76cbb8bcee..9f2197fd6f 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -13,12 +13,12 @@ 
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "cpu.h"
 #include "sysemu/qtest.h"
 #include "sysemu/runstate.h"
 #include "chardev/char-fe.h"
 #include "exec/ioport.h"
 #include "exec/memory.h"
+#include "exec/tswap.h"
 #include "hw/qdev-core.h"
 #include "hw/irq.h"
 #include "qemu/accel.h"
@@ -717,11 +717,11 @@  static void qtest_process_command(CharBackend *chr, gchar **words)
         qtest_send(chr, "OK\n");
     } else if (strcmp(words[0], "endianness") == 0) {
         qtest_send_prefix(chr);
-#if TARGET_BIG_ENDIAN
-        qtest_sendf(chr, "OK big\n");
-#else
-        qtest_sendf(chr, "OK little\n");
-#endif
+        if (target_words_bigendian()) {
+            qtest_sendf(chr, "OK big\n");
+        } else {
+            qtest_sendf(chr, "OK little\n");
+        }
     } else if (qtest_enabled() && strcmp(words[0], "clock_step") == 0) {
         int64_t ns;
 
diff --git a/softmmu/meson.build b/softmmu/meson.build
index 1a7c7ac089..b392f0bd35 100644
--- a/softmmu/meson.build
+++ b/softmmu/meson.build
@@ -3,7 +3,6 @@  specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files(
   'ioport.c',
   'memory.c',
   'physmem.c',
-  'qtest.c',
   'dirtylimit.c',
   'watchpoint.c',
 )])
@@ -23,6 +22,7 @@  softmmu_ss.add(files(
   'globals.c',
   'memory_mapping.c',
   'qdev-monitor.c',
+  'qtest.c',
   'rtc.c',
   'runstate-action.c',
   'runstate-hmp-cmds.c',