]> git.proxmox.com Git - mirror_qemu.git/blame - include/qemu/thread.h
Add 'debug-threads' suboption to --name
[mirror_qemu.git] / include / 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;
c7c4d063 10typedef struct QemuEvent QemuEvent;
e5d355d1
AL
11typedef 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 22void qemu_mutex_init(QemuMutex *mutex);
313b1d69 23void qemu_mutex_destroy(QemuMutex *mutex);
e5d355d1
AL
24void qemu_mutex_lock(QemuMutex *mutex);
25int qemu_mutex_trylock(QemuMutex *mutex);
e5d355d1
AL
26void qemu_mutex_unlock(QemuMutex *mutex);
27
5f7d05ec
HPB
28#define rcu_read_lock() do { } while (0)
29#define rcu_read_unlock() do { } while (0)
30
e5d355d1 31void qemu_cond_init(QemuCond *cond);
313b1d69 32void qemu_cond_destroy(QemuCond *cond);
9257d46d
PB
33
34/*
35 * IMPORTANT: The implementation does not guarantee that pthread_cond_signal
36 * and pthread_cond_broadcast can be called except while the same mutex is
37 * held as in the corresponding pthread_cond_wait calls!
38 */
e5d355d1
AL
39void qemu_cond_signal(QemuCond *cond);
40void qemu_cond_broadcast(QemuCond *cond);
41void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
e5d355d1 42
38b14db3
PB
43void qemu_sem_init(QemuSemaphore *sem, int init);
44void qemu_sem_post(QemuSemaphore *sem);
45void qemu_sem_wait(QemuSemaphore *sem);
46int qemu_sem_timedwait(QemuSemaphore *sem, int ms);
47void qemu_sem_destroy(QemuSemaphore *sem);
48
c7c4d063
PB
49void qemu_event_init(QemuEvent *ev, bool init);
50void qemu_event_set(QemuEvent *ev);
51void qemu_event_reset(QemuEvent *ev);
52void qemu_event_wait(QemuEvent *ev);
53void qemu_event_destroy(QemuEvent *ev);
54
e5d355d1 55void qemu_thread_create(QemuThread *thread,
cf218714
JK
56 void *(*start_routine)(void *),
57 void *arg, int mode);
58void *qemu_thread_join(QemuThread *thread);
b7680cb6 59void qemu_thread_get_self(QemuThread *thread);
2d797b65 60bool qemu_thread_is_self(QemuThread *thread);
313b1d69 61void qemu_thread_exit(void *retval);
8f480de0 62void qemu_thread_naming(bool enable);
313b1d69 63
e5d355d1 64#endif