Skip to contentSkip to conversation

RFC: avoid #ifdef for target cpu list

Qemu-devel J. Mayer 1 participant 1 message Oct 10, 2007

lore
Share & tools
lore

J. Mayer

author
#0 lore raw

This tiny patch unifies the -cpu ? option for all cpu that actually can handle it.
It changes the arm_cpu_list to use the same prototype as ppc, mips and sparc and add a new define cpu_list in target_xxx/cpu.h
As the cpu selection is not implemented for all targets, I had to protect the call to cpu_list with a #if defined(cpu_list) that will have to be suppressed once all target will implement this feature.

Please comment.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized

Index: vl.c
===================================================================
RCS file: /sources/qemu/qemu/vl.c,v
retrieving revision 1.347

vl.c +3 -8
diff -u -d -d -p -r1.347 vl.c
@@ -7690,14 +7693,9 @@ int main(int argc, char **argv)
             case QEMU_OPTION_cpu:
                 /* hw initialization will check this */
                 if (*optarg == '?') {
-#if defined(TARGET_PPC)
-                    ppc_cpu_list(stdout, &fprintf);
-#elif defined(TARGET_ARM)
-                    arm_cpu_list();
-#elif defined(TARGET_MIPS)
-                    mips_cpu_list(stdout, &fprintf);
-#elif defined(TARGET_SPARC)
-                    sparc_cpu_list(stdout, &fprintf);
+/* XXX: implement xxx_cpu_list for targets that still miss it */
+#if defined(cpu_list)
+                    cpu_list(stdout, &fprintf);
 #endif
                     exit(0);
                 } else {

Index: vl.h
===================================================================
RCS file: /sources/qemu/qemu/vl.h,v
retrieving revision 1.277

vl.h +0 -8
diff -u -d -d -p -r1.277 vl.h
@@ -741,14 +741,6 @@ int qemu_register_machine(QEMUMachine *m
 
 typedef void SetIRQFunc(void *opaque, int irq_num, int level);
 
-#if defined(TARGET_PPC)
-void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
-#endif
-
-#if defined(TARGET_MIPS)
-void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
-#endif
-
 #include "hw/irq.h"
 
 /* ISA bus */

Index: target-arm/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-arm/cpu.h,v
retrieving revision 1.34

cpu.h +1 -0
diff -u -d -d -p -r1.34 cpu.h
@@ -299,5 +299,6 @@ void cpu_arm_set_cp_io(CPUARMState *env,
 #define cpu_exec cpu_arm_exec
 #define cpu_gen_code cpu_arm_gen_code
 #define cpu_signal_handler cpu_arm_signal_handler
+#define cpu_list arm_cpu_list
 #include "cpu-all.h"
 

Index: target-arm/helper.c
===================================================================
RCS file: /sources/qemu/qemu/target-arm/helper.c,v retrieving revision 1.21

helper.c +3 -3
diff -u -d -d -p -r1.21 helper.c
@@ -126,13 +126,13 @@ static const struct arm_cpu_t arm_cpu_na
     { 0, NULL}
 };
 
-void arm_cpu_list(void)
+void arm_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
 {
     int i;
 
-    printf ("Available CPUs:\n");
+    (*cpu_fprintf)(f, "Available CPUs:\n");
     for (i = 0; arm_cpu_names[i].name; i++) {
-        printf("  %s\n", arm_cpu_names[i].name);
+        (*cpu_fprintf)(f, "  %s\n", arm_cpu_names[i].name);
     }
 }
 

Index: target-mips/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-mips/cpu.h,v
retrieving revision 1.47

cpu.h +1 -0
diff -u -d -d -p -r1.47 cpu.h
@@ -482,6 +482,7 @@ int cpu_mips_register (CPUMIPSState *env
 #define cpu_exec cpu_mips_exec
 #define cpu_gen_code cpu_mips_gen_code
 #define cpu_signal_handler cpu_mips_signal_handler
+#define cpu_list mips_cpu_list
 
 #include "cpu-all.h"
 

Index: target-ppc/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-ppc/cpu.h,v
retrieving revision 1.78

cpu.h +1 -0
diff -u -d -d -p -r1.78 cpu.h
@@ -697,6 +695,7 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, i
 #define cpu_exec cpu_ppc_exec
 #define cpu_gen_code cpu_ppc_gen_code
 #define cpu_signal_handler cpu_ppc_signal_handler
+#define cpu_list ppc_cpu_list
 
 #include "cpu-all.h"
 

Index: target-sparc/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-sparc/cpu.h,v
retrieving revision 1.52

cpu.h +1 -0
diff -u -d -d -p -r1.52 cpu.h
@@ -315,6 +315,7 @@ void cpu_check_irqs(CPUSPARCState *env);
 #define cpu_exec cpu_sparc_exec
 #define cpu_gen_code cpu_sparc_gen_code
 #define cpu_signal_handler cpu_sparc_signal_handler
+#define cpu_list sparc_cpu_list
 
 #include "cpu-all.h"