diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2012-02-08 07:23:23 -0600 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-02-08 07:23:23 -0600 |
commit | a283b1b8eb121dcc086c4850c91b35fed13d2023 (patch) | |
tree | 599e347c3dddfaee874241c2c21f68f8549b7eba | |
parent | cf4dc461a4cfc3e056ee24edb26154f4d34a6278 (diff) | |
parent | edc1de97138af028bba216ef71d1d995834829df (diff) | |
download | qemu-a283b1b8eb121dcc086c4850c91b35fed13d2023.zip qemu-a283b1b8eb121dcc086c4850c91b35fed13d2023.tar.gz qemu-a283b1b8eb121dcc086c4850c91b35fed13d2023.tar.bz2 |
Merge remote-tracking branch 'sweil/w32' into staging
* sweil/w32:
w32: Initialise critical section before starting thread (fix #922131)
w32: Build windows and console executables
-rw-r--r-- | Makefile.target | 16 | ||||
-rw-r--r-- | qemu-thread-win32.c | 9 |
2 files changed, 22 insertions, 3 deletions
diff --git a/Makefile.target b/Makefile.target index 68481a3..7ed4979 100644 --- a/Makefile.target +++ b/Makefile.target @@ -29,10 +29,17 @@ ifdef CONFIG_USER_ONLY QEMU_PROG=qemu-$(TARGET_ARCH2) else # system emulator name +ifneq (,$(findstring -mwindows,$(LIBS))) +# Terminate program name with a 'w' because the linker builds a windows executable. +QEMU_PROGW=qemu-system-$(TARGET_ARCH2)w$(EXESUF) +endif # windows executable QEMU_PROG=qemu-system-$(TARGET_ARCH2)$(EXESUF) endif PROGS=$(QEMU_PROG) +ifdef QEMU_PROGW +PROGS+=$(QEMU_PROGW) +endif STPFILES= ifndef CONFIG_HAIKU @@ -407,9 +414,16 @@ endif # CONFIG_LINUX_USER obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o +ifdef QEMU_PROGW +# The linker builds a windows executable. Make also a console executable. +$(QEMU_PROGW): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) + $(call LINK,$^) +$(QEMU_PROG): $(QEMU_PROGW) + $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG)," GEN $(TARGET_DIR)$(QEMU_PROG)") +else $(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(call LINK,$^) - +endif gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@") diff --git a/qemu-thread-win32.c b/qemu-thread-win32.c index fe9b931..3524c8b 100644 --- a/qemu-thread-win32.c +++ b/qemu-thread-win32.c @@ -215,8 +215,6 @@ static unsigned __stdcall win32_start_routine(void *arg) if (data->mode == QEMU_THREAD_DETACHED) { g_free(data); data = NULL; - } else { - InitializeCriticalSection(&data->cs); } TlsSetValue(qemu_thread_tls_index, data); qemu_thread_exit(start_routine(thread_arg)); @@ -227,6 +225,7 @@ void qemu_thread_exit(void *arg) { QemuThreadData *data = TlsGetValue(qemu_thread_tls_index); if (data) { + assert(data->mode != QEMU_THREAD_DETACHED); data->ret = arg; EnterCriticalSection(&data->cs); data->exited = true; @@ -258,6 +257,7 @@ void *qemu_thread_join(QemuThread *thread) CloseHandle(handle); } ret = data->ret; + assert(data->mode != QEMU_THREAD_DETACHED); DeleteCriticalSection(&data->cs); g_free(data); return ret; @@ -288,6 +288,10 @@ void qemu_thread_create(QemuThread *thread, data->mode = mode; data->exited = false; + if (data->mode != QEMU_THREAD_DETACHED) { + InitializeCriticalSection(&data->cs); + } + hThread = (HANDLE) _beginthreadex(NULL, 0, win32_start_routine, data, 0, &thread->tid); if (!hThread) { @@ -314,6 +318,7 @@ HANDLE qemu_thread_get_handle(QemuThread *thread) return NULL; } + assert(data->mode != QEMU_THREAD_DETACHED); EnterCriticalSection(&data->cs); if (!data->exited) { handle = OpenThread(SYNCHRONIZE | THREAD_SUSPEND_RESUME, FALSE, |