aboutsummaryrefslogtreecommitdiff
path: root/qemu-thread-win32.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2011-12-13 13:43:52 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2011-12-15 09:20:50 -0600
commit1ecf47bf0a091700e45f1b7d1f5ad85abc0acd22 (patch)
tree879b0b0ebaba1097b246fe60f590fa8028d12bea /qemu-thread-win32.c
parentcd34d667d448bec91c81f4e46f9e7eb4e4857f6f (diff)
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>
Diffstat (limited to 'qemu-thread-win32.c')
-rw-r--r--qemu-thread-win32.c29
1 files changed, 23 insertions, 6 deletions
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;