blob: a78a8f2524bf9affd5a476433b0bc2f69e6ccb53 [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
Jan Kiszkacf218712011-12-12 17:21:31 +010016#define QEMU_THREAD_JOINABLE 0
17#define QEMU_THREAD_DETACHED 1
18
aliguorie5d355d2009-04-24 18:03:15 +000019void qemu_mutex_init(QemuMutex *mutex);
Corentin Chary313b1d62010-07-07 20:58:01 +020020void qemu_mutex_destroy(QemuMutex *mutex);
aliguorie5d355d2009-04-24 18:03:15 +000021void qemu_mutex_lock(QemuMutex *mutex);
22int qemu_mutex_trylock(QemuMutex *mutex);
aliguorie5d355d2009-04-24 18:03:15 +000023void qemu_mutex_unlock(QemuMutex *mutex);
24
Harsh Prateek Bora5f7d05e2011-10-25 12:10:40 +053025#define rcu_read_lock() do { } while (0)
26#define rcu_read_unlock() do { } while (0)
27
aliguorie5d355d2009-04-24 18:03:15 +000028void qemu_cond_init(QemuCond *cond);
Corentin Chary313b1d62010-07-07 20:58:01 +020029void qemu_cond_destroy(QemuCond *cond);
Paolo Bonzini9257d462011-03-12 17:43:52 +010030
31/*
32 * IMPORTANT: The implementation does not guarantee that pthread_cond_signal
33 * and pthread_cond_broadcast can be called except while the same mutex is
34 * held as in the corresponding pthread_cond_wait calls!
35 */
aliguorie5d355d2009-04-24 18:03:15 +000036void qemu_cond_signal(QemuCond *cond);
37void qemu_cond_broadcast(QemuCond *cond);
38void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
aliguorie5d355d2009-04-24 18:03:15 +000039
40void qemu_thread_create(QemuThread *thread,
Jan Kiszkacf218712011-12-12 17:21:31 +010041 void *(*start_routine)(void *),
42 void *arg, int mode);
43void *qemu_thread_join(QemuThread *thread);
Jan Kiszkab7680cb2011-03-12 17:43:51 +010044void qemu_thread_get_self(QemuThread *thread);
45int qemu_thread_is_self(QemuThread *thread);
Corentin Chary313b1d62010-07-07 20:58:01 +020046void qemu_thread_exit(void *retval);
47
aliguorie5d355d2009-04-24 18:03:15 +000048#endif