From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Amit Shah <amit.shah@redhat.com>,
Isaku Yamahata <yamahata@valinux.co.jp>
Subject: [Qemu-devel] [PATCH 6/7] replace void* uses with opaque CPUState*
Date: Fri, 25 Jun 2010 14:52:21 +0200 [thread overview]
Message-ID: <1277470342-5861-7-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1277470342-5861-1-git-send-email-pbonzini@redhat.com>
Because we all love type safety, don't we?
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
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
next prev parent reply other threads:[~2010-06-25 17:50 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-25 12:52 [Qemu-devel] [PATCH 0/7] poison TARGET_xxx for compile once object and header file cleanups Paolo Bonzini
2010-06-25 12:52 ` [Qemu-devel] [PATCH 1/7] rtc: Remove TARGET_I386 from qemu-config.c, enables driftfix Paolo Bonzini
2010-06-25 12:52 ` [Qemu-devel] [PATCH 2/7] include qemu-common.h when needed by the next patches Paolo Bonzini
2010-06-25 12:52 ` [Qemu-devel] [PATCH 3/7] include stdio.h freely, remove dyngen-exec.h hacks Paolo Bonzini
2010-06-25 12:52 ` [Qemu-devel] [PATCH 4/7] provide opaque CPUState to files that are compiled once Paolo Bonzini
2010-06-27 19:17 ` Blue Swirl
2010-06-28 8:04 ` Paolo Bonzini
2010-06-28 14:21 ` Blue Swirl
2010-06-25 12:52 ` [Qemu-devel] [PATCH 5/7] add qdev property type "cpu" Paolo Bonzini
2010-06-26 7:46 ` Markus Armbruster
2010-06-27 12:48 ` [Qemu-devel] " Paolo Bonzini
2010-06-29 11:42 ` Markus Armbruster
2010-06-29 13:52 ` Paolo Bonzini
2010-06-27 18:45 ` [Qemu-devel] " Blue Swirl
2010-06-25 12:52 ` Paolo Bonzini [this message]
2010-06-26 7:49 ` [Qemu-devel] [PATCH 6/7] replace void* uses with opaque CPUState* Markus Armbruster
2010-06-25 12:52 ` [Qemu-devel] [PATCH 7/7] poison TARGET_xxx for compile once object Paolo Bonzini
2010-06-25 22:47 ` [Qemu-devel] [PATCH 0/7] poison TARGET_xxx for compile once object and header file cleanups Richard Henderson
2010-06-27 12:39 ` [Qemu-devel] " Paolo Bonzini
2010-06-27 19:32 ` [Qemu-devel] " Blue Swirl
2010-06-28 8:20 ` Paolo Bonzini
2010-06-28 15:11 ` Blue Swirl
2010-06-28 16:21 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1277470342-5861-7-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=amit.shah@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yamahata@valinux.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).