root / qemu-thread.h @ 44e4c0ba
History | View | Annotate | Download (1.1 kB)
1 | e5d355d1 | aliguori | #ifndef __QEMU_THREAD_H
|
---|---|---|---|
2 | e5d355d1 | aliguori | #define __QEMU_THREAD_H 1 |
3 | e5d355d1 | aliguori | #include "semaphore.h" |
4 | e5d355d1 | aliguori | #include "pthread.h" |
5 | e5d355d1 | aliguori | |
6 | e5d355d1 | aliguori | struct QemuMutex {
|
7 | e5d355d1 | aliguori | pthread_mutex_t lock; |
8 | e5d355d1 | aliguori | }; |
9 | e5d355d1 | aliguori | |
10 | e5d355d1 | aliguori | struct QemuCond {
|
11 | e5d355d1 | aliguori | pthread_cond_t cond; |
12 | e5d355d1 | aliguori | }; |
13 | e5d355d1 | aliguori | |
14 | e5d355d1 | aliguori | struct QemuThread {
|
15 | e5d355d1 | aliguori | pthread_t thread; |
16 | e5d355d1 | aliguori | }; |
17 | e5d355d1 | aliguori | |
18 | e5d355d1 | aliguori | typedef struct QemuMutex QemuMutex; |
19 | e5d355d1 | aliguori | typedef struct QemuCond QemuCond; |
20 | e5d355d1 | aliguori | typedef struct QemuThread QemuThread; |
21 | e5d355d1 | aliguori | |
22 | e5d355d1 | aliguori | void qemu_mutex_init(QemuMutex *mutex);
|
23 | e5d355d1 | aliguori | void qemu_mutex_lock(QemuMutex *mutex);
|
24 | e5d355d1 | aliguori | int qemu_mutex_trylock(QemuMutex *mutex);
|
25 | e5d355d1 | aliguori | int qemu_mutex_timedlock(QemuMutex *mutex, uint64_t msecs);
|
26 | e5d355d1 | aliguori | void qemu_mutex_unlock(QemuMutex *mutex);
|
27 | e5d355d1 | aliguori | |
28 | e5d355d1 | aliguori | void qemu_cond_init(QemuCond *cond);
|
29 | e5d355d1 | aliguori | void qemu_cond_signal(QemuCond *cond);
|
30 | e5d355d1 | aliguori | void qemu_cond_broadcast(QemuCond *cond);
|
31 | e5d355d1 | aliguori | void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
|
32 | e5d355d1 | aliguori | int qemu_cond_timedwait(QemuCond *cond, QemuMutex *mutex, uint64_t msecs);
|
33 | e5d355d1 | aliguori | |
34 | e5d355d1 | aliguori | void qemu_thread_create(QemuThread *thread,
|
35 | e5d355d1 | aliguori | void *(*start_routine)(void*), |
36 | e5d355d1 | aliguori | void *arg);
|
37 | e5d355d1 | aliguori | void qemu_thread_signal(QemuThread *thread, int sig); |
38 | e5d355d1 | aliguori | void qemu_thread_self(QemuThread *thread);
|
39 | e5d355d1 | aliguori | int qemu_thread_equal(QemuThread *thread1, QemuThread *thread2);
|
40 | e5d355d1 | aliguori | #endif |