2016-06-29 13:47:03 +02:00
|
|
|
#ifndef QEMU_THREAD_POSIX_H
|
|
|
|
#define QEMU_THREAD_POSIX_H
|
2016-06-22 19:11:19 +02:00
|
|
|
|
|
|
|
#include <pthread.h>
|
2011-08-08 14:36:41 +02:00
|
|
|
#include <semaphore.h>
|
2011-03-12 17:43:52 +01:00
|
|
|
|
|
|
|
struct QemuMutex {
|
|
|
|
pthread_mutex_t lock;
|
2018-06-13 14:23:08 +02:00
|
|
|
#ifdef CONFIG_DEBUG_MUTEX
|
|
|
|
const char *file;
|
|
|
|
int line;
|
|
|
|
#endif
|
2017-07-04 14:23:25 +02:00
|
|
|
bool initialized;
|
2011-03-12 17:43:52 +01:00
|
|
|
};
|
|
|
|
|
2021-06-15 01:31:40 +02:00
|
|
|
/*
|
|
|
|
* QemuRecMutex cannot be a typedef of QemuMutex lest we have two
|
|
|
|
* compatible cases in _Generic. See qemu/lockable.h.
|
|
|
|
*/
|
|
|
|
typedef struct QemuRecMutex {
|
|
|
|
QemuMutex m;
|
|
|
|
} QemuRecMutex;
|
|
|
|
|
2011-03-12 17:43:52 +01:00
|
|
|
struct QemuCond {
|
|
|
|
pthread_cond_t cond;
|
2017-07-04 14:23:25 +02:00
|
|
|
bool initialized;
|
2011-03-12 17:43:52 +01:00
|
|
|
};
|
|
|
|
|
2011-08-08 14:36:41 +02:00
|
|
|
struct QemuSemaphore {
|
2022-02-22 10:05:06 +01:00
|
|
|
QemuMutex mutex;
|
|
|
|
QemuCond cond;
|
2013-07-03 10:58:14 +02:00
|
|
|
unsigned int count;
|
2011-08-08 14:36:41 +02:00
|
|
|
};
|
|
|
|
|
2013-09-25 08:20:59 +02:00
|
|
|
struct QemuEvent {
|
|
|
|
#ifndef __linux__
|
|
|
|
pthread_mutex_t lock;
|
|
|
|
pthread_cond_t cond;
|
|
|
|
#endif
|
|
|
|
unsigned value;
|
2017-07-04 14:23:25 +02:00
|
|
|
bool initialized;
|
2013-09-25 08:20:59 +02:00
|
|
|
};
|
|
|
|
|
2011-03-12 17:43:52 +01:00
|
|
|
struct QemuThread {
|
|
|
|
pthread_t thread;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|