]>
Commit | Line | Data |
---|---|---|
e5d355d1 AL |
1 | #ifndef __QEMU_THREAD_H |
2 | #define __QEMU_THREAD_H 1 | |
e5d355d1 | 3 | |
65097429 | 4 | #include <inttypes.h> |
2d797b65 | 5 | #include <stdbool.h> |
65097429 | 6 | |
e5d355d1 AL |
7 | typedef struct QemuMutex QemuMutex; |
8 | typedef struct QemuCond QemuCond; | |
38b14db3 | 9 | typedef struct QemuSemaphore QemuSemaphore; |
c7c4d063 | 10 | typedef struct QemuEvent QemuEvent; |
e5d355d1 AL |
11 | typedef struct QemuThread QemuThread; |
12 | ||
9257d46d | 13 | #ifdef _WIN32 |
1de7afc9 | 14 | #include "qemu/thread-win32.h" |
9257d46d | 15 | #else |
1de7afc9 | 16 | #include "qemu/thread-posix.h" |
9257d46d PB |
17 | #endif |
18 | ||
cf218714 JK |
19 | #define QEMU_THREAD_JOINABLE 0 |
20 | #define QEMU_THREAD_DETACHED 1 | |
21 | ||
e5d355d1 | 22 | void qemu_mutex_init(QemuMutex *mutex); |
313b1d69 | 23 | void qemu_mutex_destroy(QemuMutex *mutex); |
e5d355d1 AL |
24 | void qemu_mutex_lock(QemuMutex *mutex); |
25 | int qemu_mutex_trylock(QemuMutex *mutex); | |
e5d355d1 AL |
26 | void qemu_mutex_unlock(QemuMutex *mutex); |
27 | ||
28 | void qemu_cond_init(QemuCond *cond); | |
313b1d69 | 29 | void qemu_cond_destroy(QemuCond *cond); |
9257d46d PB |
30 | |
31 | /* | |
32 | * IMPORTANT: The implementation does not guarantee that pthread_cond_signal | |
33 | * and pthread_cond_broadcast can be called except while the same mutex is | |
34 | * held as in the corresponding pthread_cond_wait calls! | |
35 | */ | |
e5d355d1 AL |
36 | void qemu_cond_signal(QemuCond *cond); |
37 | void qemu_cond_broadcast(QemuCond *cond); | |
38 | void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex); | |
e5d355d1 | 39 | |
38b14db3 PB |
40 | void qemu_sem_init(QemuSemaphore *sem, int init); |
41 | void qemu_sem_post(QemuSemaphore *sem); | |
42 | void qemu_sem_wait(QemuSemaphore *sem); | |
43 | int qemu_sem_timedwait(QemuSemaphore *sem, int ms); | |
44 | void qemu_sem_destroy(QemuSemaphore *sem); | |
45 | ||
c7c4d063 PB |
46 | void qemu_event_init(QemuEvent *ev, bool init); |
47 | void qemu_event_set(QemuEvent *ev); | |
48 | void qemu_event_reset(QemuEvent *ev); | |
49 | void qemu_event_wait(QemuEvent *ev); | |
50 | void qemu_event_destroy(QemuEvent *ev); | |
51 | ||
4900116e | 52 | void qemu_thread_create(QemuThread *thread, const char *name, |
cf218714 JK |
53 | void *(*start_routine)(void *), |
54 | void *arg, int mode); | |
55 | void *qemu_thread_join(QemuThread *thread); | |
b7680cb6 | 56 | void qemu_thread_get_self(QemuThread *thread); |
2d797b65 | 57 | bool qemu_thread_is_self(QemuThread *thread); |
313b1d69 | 58 | void qemu_thread_exit(void *retval); |
8f480de0 | 59 | void qemu_thread_naming(bool enable); |
313b1d69 | 60 | |
ef57137f PB |
61 | struct Notifier; |
62 | void qemu_thread_atexit_add(struct Notifier *notifier); | |
63 | void qemu_thread_atexit_remove(struct Notifier *notifier); | |
64 | ||
e5d355d1 | 65 | #endif |