cpu: Move CPU_COMMON_THREAD into CPUState

CPU_COMMON_THREAD was only used for Windows, adding an hThread field
to CPU_COMMON.

Move the field into QOM CPUState and change its type to HANDLE,
which it is assigned from. This requires Windows headers, pulled in
through qemu-thread.h.

Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Andreas Färber 2012-05-02 15:24:40 +02:00
parent 2d797b6520
commit bcba2a72ed
3 changed files with 12 additions and 12 deletions

View File

@ -151,14 +151,6 @@ typedef struct CPUWatchpoint {
QTAILQ_ENTRY(CPUWatchpoint) entry; QTAILQ_ENTRY(CPUWatchpoint) entry;
} CPUWatchpoint; } CPUWatchpoint;
#ifdef _WIN32
#define CPU_COMMON_THREAD \
void *hThread;
#else
#define CPU_COMMON_THREAD
#endif
#define CPU_TEMP_BUF_NLONGS 128 #define CPU_TEMP_BUF_NLONGS 128
#define CPU_COMMON \ #define CPU_COMMON \
struct TranslationBlock *current_tb; /* currently executing TB */ \ struct TranslationBlock *current_tb; /* currently executing TB */ \
@ -217,7 +209,6 @@ typedef struct CPUWatchpoint {
uint32_t stop; /* Stop request */ \ uint32_t stop; /* Stop request */ \
uint32_t stopped; /* Artificially stopped */ \ uint32_t stopped; /* Artificially stopped */ \
struct QemuThread *thread; \ struct QemuThread *thread; \
CPU_COMMON_THREAD \
struct QemuCond *halt_cond; \ struct QemuCond *halt_cond; \
int thread_kicked; \ int thread_kicked; \
struct qemu_work_item *queued_work_first, *queued_work_last; \ struct qemu_work_item *queued_work_first, *queued_work_last; \

10
cpus.c
View File

@ -852,9 +852,10 @@ static void qemu_cpu_kick_thread(CPUArchState *env)
} }
#else /* _WIN32 */ #else /* _WIN32 */
if (!qemu_cpu_is_self(env)) { if (!qemu_cpu_is_self(env)) {
SuspendThread(env->hThread); CPUState *cpu = ENV_GET_CPU(env);
SuspendThread(cpu->hThread);
cpu_signal(0); cpu_signal(0);
ResumeThread(env->hThread); ResumeThread(cpu->hThread);
} }
#endif #endif
} }
@ -974,6 +975,9 @@ void resume_all_vcpus(void)
static void qemu_tcg_init_vcpu(void *_env) static void qemu_tcg_init_vcpu(void *_env)
{ {
CPUArchState *env = _env; CPUArchState *env = _env;
#ifdef _WIN32
CPUState *cpu = ENV_GET_CPU(env);
#endif
/* share a single thread for all cpus with TCG */ /* share a single thread for all cpus with TCG */
if (!tcg_cpu_thread) { if (!tcg_cpu_thread) {
@ -984,7 +988,7 @@ static void qemu_tcg_init_vcpu(void *_env)
qemu_thread_create(env->thread, qemu_tcg_cpu_thread_fn, env, qemu_thread_create(env->thread, qemu_tcg_cpu_thread_fn, env,
QEMU_THREAD_JOINABLE); QEMU_THREAD_JOINABLE);
#ifdef _WIN32 #ifdef _WIN32
env->hThread = qemu_thread_get_handle(env->thread); cpu->hThread = qemu_thread_get_handle(env->thread);
#endif #endif
while (env->created == 0) { while (env->created == 0) {
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);

View File

@ -21,6 +21,7 @@
#define QEMU_CPU_H #define QEMU_CPU_H
#include "qemu/object.h" #include "qemu/object.h"
#include "qemu-thread.h"
/** /**
* SECTION:cpu * SECTION:cpu
@ -61,6 +62,10 @@ struct CPUState {
Object parent_obj; Object parent_obj;
/*< public >*/ /*< public >*/
#ifdef _WIN32
HANDLE hThread;
#endif
/* TODO Move common fields from CPUArchState here. */ /* TODO Move common fields from CPUArchState here. */
}; };