qemu-patch-raspberry4/include/qemu/thread-win32.h
Paolo Bonzini ba59fb778e QemuMutex: support --enable-debug-mutex
We have had some tracing tools for mutex but it's not easy to use them
for e.g. dead locks.  Let's provide "--enable-debug-mutex" parameter
when configure to allow QemuMutex to store the last owner that took
specific lock.  It will be easy to use this tool to debug deadlocks
since we can directly know who took the lock then as long as we can have
a debugger attached to the process.

Reviewed-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20180425025459.5258-4-peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-06-28 19:05:32 +02:00

52 lines
953 B
C

#ifndef QEMU_THREAD_WIN32_H
#define QEMU_THREAD_WIN32_H
#include <windows.h>
struct QemuMutex {
SRWLOCK lock;
#ifdef CONFIG_DEBUG_MUTEX
const char *file;
int line;
#endif
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