qemu-thread: Assert locks are initialized before using
[qemu.git] / include / qemu / thread-posix.h
blobe5e3a0ff979fdef9a160b825cb39b22e55223786
1 #ifndef QEMU_THREAD_POSIX_H
2 #define QEMU_THREAD_POSIX_H
4 #include <pthread.h>
5 #include <semaphore.h>
7 typedef QemuMutex QemuRecMutex;
8 #define qemu_rec_mutex_destroy qemu_mutex_destroy
9 #define qemu_rec_mutex_lock qemu_mutex_lock
10 #define qemu_rec_mutex_try_lock qemu_mutex_try_lock
11 #define qemu_rec_mutex_unlock qemu_mutex_unlock
13 struct QemuMutex {
14 pthread_mutex_t lock;
15 bool initialized;
18 struct QemuCond {
19 pthread_cond_t cond;
20 bool initialized;
23 struct QemuSemaphore {
24 #if defined(__APPLE__) || defined(__NetBSD__)
25 pthread_mutex_t lock;
26 pthread_cond_t cond;
27 unsigned int count;
28 #else
29 sem_t sem;
30 #endif
31 bool initialized;
34 struct QemuEvent {
35 #ifndef __linux__
36 pthread_mutex_t lock;
37 pthread_cond_t cond;
38 #endif
39 unsigned value;
40 bool initialized;
43 struct QemuThread {
44 pthread_t thread;
47 #endif