| 1 | #ifndef QEMU_THREAD_POSIX_H |
| 2 | #define QEMU_THREAD_POSIX_H |
| 3 | |
| 4 | #include <pthread.h> |
| 5 | #include <semaphore.h> |
| 6 | |
| 7 | struct QemuMutex { |
| 8 | pthread_mutex_t lock; |
| 9 | #ifdef CONFIG_DEBUG_MUTEX |
| 10 | const char *file; |
| 11 | int line; |
| 12 | #endif |
| 13 | bool initialized; |
| 14 | }; |
| 15 | |
| 16 | /* |
| 17 | * QemuRecMutex cannot be a typedef of QemuMutex lest we have two |
| 18 | * compatible cases in _Generic. See qemu/lockable.h. |
| 19 | */ |
| 20 | typedef struct QemuRecMutex { |
| 21 | QemuMutex m; |
| 22 | } QemuRecMutex; |
| 23 | |
| 24 | struct QemuCond { |
| 25 | pthread_cond_t cond; |
| 26 | bool initialized; |
| 27 | }; |
| 28 | |
| 29 | struct QemuSemaphore { |
| 30 | QemuMutex mutex; |
| 31 | QemuCond cond; |
| 32 | unsigned int count; |
| 33 | }; |
| 34 | |
| 35 | struct QemuThread { |
| 36 | pthread_t thread; |
| 37 | }; |
| 38 | |
| 39 | #endif |