From bdc44640cb33c90809376a262df871a1144d339a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 24 Jun 2013 23:50:24 +0200 Subject: cpu: Use QTAILQ for CPU list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce CPU_FOREACH(), CPU_FOREACH_SAFE() and CPU_NEXT() shorthand macros. Signed-off-by: Andreas Färber --- include/qom/cpu.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include/qom') diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 3e4993661a..79f7c8709d 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -23,6 +23,7 @@ #include #include "hw/qdev-core.h" #include "exec/hwaddr.h" +#include "qemu/queue.h" #include "qemu/thread.h" #include "qemu/tls.h" #include "qemu/typedefs.h" @@ -190,7 +191,7 @@ struct CPUState { struct GDBRegisterState *gdb_regs; int gdb_num_regs; int gdb_num_g_regs; - CPUState *next_cpu; + QTAILQ_ENTRY(CPUState) node; int kvm_fd; bool kvm_vcpu_dirty; @@ -202,7 +203,13 @@ struct CPUState { uint32_t halted; /* used by alpha, cris, ppc TCG */ }; -extern CPUState *first_cpu; +QTAILQ_HEAD(CPUTailQ, CPUState); +extern struct CPUTailQ cpus; +#define CPU_NEXT(cpu) QTAILQ_NEXT(cpu, node) +#define CPU_FOREACH(cpu) QTAILQ_FOREACH(cpu, &cpus, node) +#define CPU_FOREACH_SAFE(cpu, next_cpu) \ + QTAILQ_FOREACH_SAFE(cpu, &cpus, node, next_cpu) +#define first_cpu QTAILQ_FIRST(&cpus) DECLARE_TLS(CPUState *, current_cpu); #define current_cpu tls_var(current_cpu) -- cgit v1.2.3 From 38fcbd3f08375eb2986b9b63ccd4f593e71aa99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 7 Jul 2013 19:50:23 +0200 Subject: cpu: Replace qemu_for_each_cpu() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was introduced to loop over CPUs from target-independent code, but since commit 182735efaf956ccab50b6d74a4fed163e0f35660 target-independent CPUState is used. A loop can be considered more efficient than function calls in a loop, and CPU_FOREACH() hides implementation details just as well, so use that instead. Suggested-by: Markus Armbruster Acked-by: Michael S. Tsirkin Signed-off-by: Andreas Färber --- include/qom/cpu.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'include/qom') diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 79f7c8709d..7739e00067 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -402,15 +402,6 @@ void run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data); */ void async_run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data); -/** - * qemu_for_each_cpu: - * @func: The function to be executed. - * @data: Data to pass to the function. - * - * Executes @func for each CPU. - */ -void qemu_for_each_cpu(void (*func)(CPUState *cpu, void *data), void *data); - /** * qemu_get_cpu: * @index: The CPUState@cpu_index value of the CPU to obtain. -- cgit v1.2.3