]> git.proxmox.com Git - qemu.git/blame - qemu-thread.h
fix live migration
[qemu.git] / qemu-thread.h
CommitLineData
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
7typedef struct QemuMutex QemuMutex;
8typedef struct QemuCond QemuCond;
38b14db3 9typedef struct QemuSemaphore QemuSemaphore;
e5d355d1
AL
10typedef struct QemuThread QemuThread;
11
9257d46d
PB
12#ifdef _WIN32
13#include "qemu-thread-win32.h"
14#else
15#include "qemu-thread-posix.h"
16#endif
17
cf218714
JK
18#define QEMU_THREAD_JOINABLE 0
19#define QEMU_THREAD_DETACHED 1
20
e5d355d1 21void qemu_mutex_init(QemuMutex *mutex);
313b1d69 22void qemu_mutex_destroy(QemuMutex *mutex);
e5d355d1
AL
23void qemu_mutex_lock(QemuMutex *mutex);
24int qemu_mutex_trylock(QemuMutex *mutex);
e5d355d1
AL
25void qemu_mutex_unlock(QemuMutex *mutex);
26
5f7d05ec
HPB
27#define rcu_read_lock() do { } while (0)
28#define rcu_read_unlock() do { } while (0)
29
e5d355d1 30void qemu_cond_init(QemuCond *cond);
313b1d69 31void qemu_cond_destroy(QemuCond *cond);
9257d46d
PB
32
33/*
34 * IMPORTANT: The implementation does not guarantee that pthread_cond_signal
35 * and pthread_cond_broadcast can be called except while the same mutex is
36 * held as in the corresponding pthread_cond_wait calls!
37 */
e5d355d1
AL
38void qemu_cond_signal(QemuCond *cond);
39void qemu_cond_broadcast(QemuCond *cond);
40void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
e5d355d1 41
38b14db3
PB
42void qemu_sem_init(QemuSemaphore *sem, int init);
43void qemu_sem_post(QemuSemaphore *sem);
44void qemu_sem_wait(QemuSemaphore *sem);
45int qemu_sem_timedwait(QemuSemaphore *sem, int ms);
46void qemu_sem_destroy(QemuSemaphore *sem);
47
e5d355d1 48void qemu_thread_create(QemuThread *thread,
cf218714
JK
49 void *(*start_routine)(void *),
50 void *arg, int mode);
51void *qemu_thread_join(QemuThread *thread);
b7680cb6 52void qemu_thread_get_self(QemuThread *thread);
2d797b65 53bool qemu_thread_is_self(QemuThread *thread);
313b1d69
CC
54void qemu_thread_exit(void *retval);
55
e5d355d1 56#endif