c096358e74
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>
48 lines
884 B
C
48 lines
884 B
C
#ifndef QEMU_THREAD_WIN32_H
|
|
#define QEMU_THREAD_WIN32_H
|
|
|
|
#include <windows.h>
|
|
|
|
struct QemuMutex {
|
|
SRWLOCK lock;
|
|
bool initialized;
|
|
};
|
|
|
|
typedef struct QemuRecMutex QemuRecMutex;
|
|
struct QemuRecMutex {
|
|
CRITICAL_SECTION lock;
|
|
bool initialized;
|
|
};
|
|
|
|
void qemu_rec_mutex_destroy(QemuRecMutex *mutex);
|
|
void qemu_rec_mutex_lock(QemuRecMutex *mutex);
|
|
int qemu_rec_mutex_trylock(QemuRecMutex *mutex);
|
|
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;
|
|
struct QemuThread {
|
|
QemuThreadData *data;
|
|
unsigned tid;
|
|
};
|
|
|
|
/* Only valid for joinable threads. */
|
|
HANDLE qemu_thread_get_handle(QemuThread *thread);
|
|
|
|
#endif
|