[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 6/7] replace void* uses with opaque CPUState*
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 6/7] replace void* uses with opaque CPUState* |
Date: |
Fri, 25 Jun 2010 14:52:21 +0200 |
Because we all love type safety, don't we?
Signed-off-by: Paolo Bonzini <address@hidden>
---
cpu-common.h | 1 -
cpus.c | 23 ++++++++---------------
hw/apic.c | 4 ++--
hw/pc.c | 4 ++--
qemu-common.h | 7 ++++---
5 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/cpu-common.h b/cpu-common.h
index f325e60..d905258 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -19,7 +19,6 @@
#include "qemu-queue.h"
struct CPUState;
-typedef struct CPUState CPUState;
#if !defined(CONFIG_USER_ONLY)
diff --git a/cpus.c b/cpus.c
index da6ec44..5b62e27 100644
--- a/cpus.c
+++ b/cpus.c
@@ -259,10 +259,8 @@ void qemu_main_loop_start(void)
{
}
-void qemu_init_vcpu(void *_env)
+void qemu_init_vcpu(CPUState *env)
{
- CPUState *env = _env;
-
env->nr_cores = smp_cores;
env->nr_threads = smp_threads;
if (kvm_enabled())
@@ -270,7 +268,7 @@ void qemu_init_vcpu(void *_env)
return;
}
-int qemu_cpu_self(void *env)
+int qemu_cpu_self(CPUState *env)
{
return 1;
}
@@ -288,7 +286,7 @@ void pause_all_vcpus(void)
{
}
-void qemu_cpu_kick(void *env)
+void qemu_cpu_kick(CPUState *env)
{
return;
}
@@ -524,16 +522,14 @@ static void *tcg_cpu_thread_fn(void *arg)
return NULL;
}
-void qemu_cpu_kick(void *_env)
+void qemu_cpu_kick(CPUState *env)
{
- CPUState *env = _env;
qemu_cond_broadcast(env->halt_cond);
qemu_thread_signal(env->thread, SIG_IPI);
}
-int qemu_cpu_self(void *_env)
+int qemu_cpu_self(CPUState *env)
{
- CPUState *env = _env;
QemuThread this;
qemu_thread_self(&this);
@@ -666,9 +662,8 @@ void resume_all_vcpus(void)
}
}
-static void tcg_init_vcpu(void *_env)
+static void tcg_init_vcpu(CPUState *env)
{
- CPUState *env = _env;
/* share a single thread for all cpus with TCG */
if (!tcg_cpu_thread) {
env->thread = qemu_mallocz(sizeof(QemuThread));
@@ -695,10 +690,8 @@ static void kvm_start_vcpu(CPUState *env)
qemu_cond_timedwait(&qemu_cpu_cond, &qemu_global_mutex, 100);
}
-void qemu_init_vcpu(void *_env)
+void qemu_init_vcpu(CPUState *env)
{
- CPUState *env = _env;
-
env->nr_cores = smp_cores;
env->nr_threads = smp_threads;
if (kvm_enabled())
@@ -840,7 +833,7 @@ void set_cpu_log(const char *optarg)
int64_t cpu_get_icount(void)
{
int64_t icount;
- CPUState *env = cpu_single_env;;
+ CPUState *env = cpu_single_env;
icount = qemu_icount;
if (env) {
diff --git a/hw/apic.c b/hw/apic.c
index d686b51..85737c4 100644
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -94,7 +94,7 @@ typedef struct APICState APICState;
struct APICState {
SysBusDevice busdev;
- void *cpu_env;
+ CPUState *cpu_env;
uint32_t apicbase;
uint8_t id;
uint8_t arb_id;
@@ -1006,7 +1006,7 @@ static SysBusDeviceInfo apic_info = {
.qdev.no_user = 1,
.qdev.props = (Property[]) {
DEFINE_PROP_UINT8("id", APICState, id, -1),
- DEFINE_PROP_PTR("cpu_env", APICState, cpu_env),
+ DEFINE_PROP_CPU("cpu_env", APICState, cpu_env),
DEFINE_PROP_END_OF_LIST(),
}
};
diff --git a/hw/pc.c b/hw/pc.c
index 1848151..0497260 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -766,7 +766,7 @@ DeviceState *cpu_get_current_apic(void)
}
}
-static DeviceState *apic_init(void *env, uint8_t apic_id)
+static DeviceState *apic_init(CPUState *env, uint8_t apic_id)
{
DeviceState *dev;
SysBusDevice *d;
@@ -774,7 +774,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)
dev = qdev_create(NULL, "apic");
qdev_prop_set_uint8(dev, "id", apic_id);
- qdev_prop_set_ptr(dev, "cpu_env", env);
+ qdev_prop_set_cpu(dev, "cpu_env", env);
qdev_init_nofail(dev);
d = sysbus_from_qdev(dev);
diff --git a/qemu-common.h b/qemu-common.h
index ac839aa..8339cb1 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -17,6 +17,7 @@ typedef struct QEMUTimer QEMUTimer;
typedef struct QEMUFile QEMUFile;
typedef struct QEMUBH QEMUBH;
typedef struct DeviceState DeviceState;
+typedef struct CPUState CPUState;
/* we put basic includes here to avoid repeating them in device drivers */
#include <stdlib.h>
@@ -239,8 +240,8 @@ void qemu_service_io(void);
void qemu_notify_event(void);
/* Unblock cpu */
-void qemu_cpu_kick(void *env);
-int qemu_cpu_self(void *env);
+void qemu_cpu_kick(CPUState *env);
+int qemu_cpu_self(CPUState *env);
/* work queue */
struct qemu_work_item {
@@ -253,7 +254,7 @@ struct qemu_work_item {
#ifdef CONFIG_USER_ONLY
#define qemu_init_vcpu(env) do { } while (0)
#else
-void qemu_init_vcpu(void *env);
+void qemu_init_vcpu(CPUState *env);
#endif
typedef struct QEMUIOVector {
--
1.7.0.1