From 1ecf47bf0a091700e45f1b7d1f5ad85abc0acd22 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 13 Dec 2011 13:43:52 +0100 Subject: fix win32 build On Windows, cpus.c needs access to the hThread. Add a Windows-specific function to grab it. This requires changing the CPU threads to joinable. There is no substantial change because the threads run in an infinite loop. Signed-off-by: Paolo Bonzini Signed-off-by: Anthony Liguori --- qemu-thread-win32.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'qemu-thread-win32.c') diff --git a/qemu-thread-win32.c b/qemu-thread-win32.c index a13ffcca69..fe9b931863 100644 --- a/qemu-thread-win32.c +++ b/qemu-thread-win32.c @@ -252,14 +252,10 @@ void *qemu_thread_join(QemuThread *thread) * discard the handle that _beginthreadex gives back, and * get another copy of the handle here. */ - EnterCriticalSection(&data->cs); - if (!data->exited) { - handle = OpenThread(SYNCHRONIZE, FALSE, thread->tid); - LeaveCriticalSection(&data->cs); + handle = qemu_thread_get_handle(thread); + if (handle) { WaitForSingleObject(handle, INFINITE); CloseHandle(handle); - } else { - LeaveCriticalSection(&data->cs); } ret = data->ret; DeleteCriticalSection(&data->cs); @@ -308,6 +304,27 @@ void qemu_thread_get_self(QemuThread *thread) thread->tid = GetCurrentThreadId(); } +HANDLE qemu_thread_get_handle(QemuThread *thread) +{ + QemuThreadData *data; + HANDLE handle; + + data = thread->data; + if (!data) { + return NULL; + } + + EnterCriticalSection(&data->cs); + if (!data->exited) { + handle = OpenThread(SYNCHRONIZE | THREAD_SUSPEND_RESUME, FALSE, + thread->tid); + } else { + handle = NULL; + } + LeaveCriticalSection(&data->cs); + return handle; +} + int qemu_thread_is_self(QemuThread *thread) { return GetCurrentThreadId() == thread->tid; -- cgit v1.2.3