summary refs log tree commit diff stats
path: root/include/qemu/thread-win32.h
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2017-07-04 20:23:25 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2017-07-04 14:39:28 +0200
commitc096358e747e88fc7364e40e3c354ee0bb683960 (patch)
tree241c11c021450913505a090cf2cf5629c1488a41 /include/qemu/thread-win32.h
parent025bdeab3c163aee9604a60b2332a5fcbcc00f8d (diff)
downloadfocaccia-qemu-c096358e747e88fc7364e40e3c354ee0bb683960.tar.gz
focaccia-qemu-c096358e747e88fc7364e40e3c354ee0bb683960.zip
qemu-thread: Assert locks are initialized before using
Not all platforms check whether a lock is initialized before used.  In
particular Linux seems to be more permissive than OSX.

Check initialization state explicitly in our code to catch such bugs
earlier.

Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170704122325.25634-1-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qemu/thread-win32.h')
-rw-r--r--include/qemu/thread-win32.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h
index 4c4a261cf4..3a05e3b3aa 100644
--- a/include/qemu/thread-win32.h
+++ b/include/qemu/thread-win32.h
@@ -5,11 +5,13 @@
 
 struct QemuMutex {
     SRWLOCK lock;
+    bool initialized;
 };
 
 typedef struct QemuRecMutex QemuRecMutex;
 struct QemuRecMutex {
     CRITICAL_SECTION lock;
+    bool initialized;
 };
 
 void qemu_rec_mutex_destroy(QemuRecMutex *mutex);
@@ -19,15 +21,18 @@ void qemu_rec_mutex_unlock(QemuRecMutex *mutex);
 
 struct QemuCond {
     CONDITION_VARIABLE var;
+    bool initialized;
 };
 
 struct QemuSemaphore {
     HANDLE sema;
+    bool initialized;
 };
 
 struct QemuEvent {
     int value;
     HANDLE event;
+    bool initialized;
 };
 
 typedef struct QemuThreadData QemuThreadData;