blob: acdb6b2339c3bf679b7dac26940b06953302a4e2 [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
4typedef struct QemuMutex QemuMutex;
5typedef struct QemuCond QemuCond;
6typedef struct QemuThread QemuThread;
7
Paolo Bonzini9257d462011-03-12 17:43:52 +01008#ifdef _WIN32
9#include "qemu-thread-win32.h"
10#else
11#include "qemu-thread-posix.h"
12#endif
13
aliguorie5d355d2009-04-24 18:03:15 +000014void qemu_mutex_init(QemuMutex *mutex);
Corentin Chary313b1d62010-07-07 20:58:01 +020015void qemu_mutex_destroy(QemuMutex *mutex);
aliguorie5d355d2009-04-24 18:03:15 +000016void qemu_mutex_lock(QemuMutex *mutex);
17int qemu_mutex_trylock(QemuMutex *mutex);
18int qemu_mutex_timedlock(QemuMutex *mutex, uint64_t msecs);
19void qemu_mutex_unlock(QemuMutex *mutex);
20
21void qemu_cond_init(QemuCond *cond);
Corentin Chary313b1d62010-07-07 20:58:01 +020022void qemu_cond_destroy(QemuCond *cond);
Paolo Bonzini9257d462011-03-12 17:43:52 +010023
24/*
25 * IMPORTANT: The implementation does not guarantee that pthread_cond_signal
26 * and pthread_cond_broadcast can be called except while the same mutex is
27 * held as in the corresponding pthread_cond_wait calls!
28 */
aliguorie5d355d2009-04-24 18:03:15 +000029void qemu_cond_signal(QemuCond *cond);
30void qemu_cond_broadcast(QemuCond *cond);
31void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
32int qemu_cond_timedwait(QemuCond *cond, QemuMutex *mutex, uint64_t msecs);
33
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