blob: 0a73d50524929f8a7387c6d163e2c4eb2dfe958a [file] [log] [blame]
aliguorie5d355d2009-04-24 18:03:15 +00001#ifndef __QEMU_THREAD_H
2#define __QEMU_THREAD_H 1
aliguorie5d355d2009-04-24 18:03:15 +00003
Alon Levy65097422011-03-15 00:18:02 +02004#include <inttypes.h>
5
aliguorie5d355d2009-04-24 18:03:15 +00006typedef struct QemuMutex QemuMutex;
7typedef struct QemuCond QemuCond;
8typedef struct QemuThread QemuThread;
9
Paolo Bonzini9257d462011-03-12 17:43:52 +010010#ifdef _WIN32
11#include "qemu-thread-win32.h"
12#else
13#include "qemu-thread-posix.h"
14#endif
15
aliguorie5d355d2009-04-24 18:03:15 +000016void qemu_mutex_init(QemuMutex *mutex);
Corentin Chary313b1d62010-07-07 20:58:01 +020017void qemu_mutex_destroy(QemuMutex *mutex);
aliguorie5d355d2009-04-24 18:03:15 +000018void qemu_mutex_lock(QemuMutex *mutex);
19int qemu_mutex_trylock(QemuMutex *mutex);
aliguorie5d355d2009-04-24 18:03:15 +000020void qemu_mutex_unlock(QemuMutex *mutex);
21
22void qemu_cond_init(QemuCond *cond);
Corentin Chary313b1d62010-07-07 20:58:01 +020023void qemu_cond_destroy(QemuCond *cond);
Paolo Bonzini9257d462011-03-12 17:43:52 +010024
25/*
26 * IMPORTANT: The implementation does not guarantee that pthread_cond_signal
27 * and pthread_cond_broadcast can be called except while the same mutex is
28 * held as in the corresponding pthread_cond_wait calls!
29 */
aliguorie5d355d2009-04-24 18:03:15 +000030void qemu_cond_signal(QemuCond *cond);
31void qemu_cond_broadcast(QemuCond *cond);
32void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
aliguorie5d355d2009-04-24 18:03:15 +000033
34void qemu_thread_create(QemuThread *thread,
35 void *(*start_routine)(void*),
36 void *arg);
Jan Kiszkab7680cb2011-03-12 17:43:51 +010037void qemu_thread_get_self(QemuThread *thread);
38int qemu_thread_is_self(QemuThread *thread);
Corentin Chary313b1d62010-07-07 20:58:01 +020039void qemu_thread_exit(void *retval);
40
aliguorie5d355d2009-04-24 18:03:15 +000041#endif