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 <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff --git a/qemu-thread-win32.c b/qemu-thread-win32.c
index a13ffcc..fe9b931 100644
--- a/qemu-thread-win32.c
+++ b/qemu-thread-win32.c
@@ -252,14 +252,10 @@
* 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 @@
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;