Merge commit '5a4d701acde890a5ca134236424ece45545f70c7' into upstream-merge
[qemu-kvm.git] / qemu-thread.h
blob05fdaaf50e4209ad62ea216a6c1e39ab86f0fdb6
1 #ifndef __QEMU_THREAD_H
2 #define __QEMU_THREAD_H 1
4 #include <inttypes.h>
5 #include <stdbool.h>
7 typedef struct QemuMutex QemuMutex;
8 typedef struct QemuCond QemuCond;
9 typedef struct QemuThread QemuThread;
11 #ifdef _WIN32
12 #include "qemu-thread-win32.h"
13 #else
14 #include "qemu-thread-posix.h"
15 #endif
17 #define QEMU_THREAD_JOINABLE 0
18 #define QEMU_THREAD_DETACHED 1
20 void qemu_mutex_init(QemuMutex *mutex);
21 void qemu_mutex_destroy(QemuMutex *mutex);
22 void qemu_mutex_lock(QemuMutex *mutex);
23 int qemu_mutex_trylock(QemuMutex *mutex);
24 void qemu_mutex_unlock(QemuMutex *mutex);
26 #define rcu_read_lock() do { } while (0)
27 #define rcu_read_unlock() do { } while (0)
29 void qemu_cond_init(QemuCond *cond);
30 void qemu_cond_destroy(QemuCond *cond);
33 * IMPORTANT: The implementation does not guarantee that pthread_cond_signal
34 * and pthread_cond_broadcast can be called except while the same mutex is
35 * held as in the corresponding pthread_cond_wait calls!
37 void qemu_cond_signal(QemuCond *cond);
38 void qemu_cond_broadcast(QemuCond *cond);
39 void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
41 void qemu_thread_create(QemuThread *thread,
42 void *(*start_routine)(void *),
43 void *arg, int mode);
44 void *qemu_thread_join(QemuThread *thread);
45 void qemu_thread_get_self(QemuThread *thread);
46 bool qemu_thread_is_self(QemuThread *thread);
47 void qemu_thread_exit(void *retval);
49 #endif