blob: e008b60028c8359f3fd57631034253362e2d79b0 [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
Harsh Prateek Bora5f7d05e2011-10-25 12:10:40 +053022#define rcu_read_lock() do { } while (0)
23#define rcu_read_unlock() do { } while (0)
24
aliguorie5d355d2009-04-24 18:03:15 +000025void qemu_cond_init(QemuCond *cond);
Corentin Chary313b1d62010-07-07 20:58:01 +020026void qemu_cond_destroy(QemuCond *cond);
Paolo Bonzini9257d462011-03-12 17:43:52 +010027
28/*
29 * IMPORTANT: The implementation does not guarantee that pthread_cond_signal
30 * and pthread_cond_broadcast can be called except while the same mutex is
31 * held as in the corresponding pthread_cond_wait calls!
32 */
aliguorie5d355d2009-04-24 18:03:15 +000033void qemu_cond_signal(QemuCond *cond);
34void qemu_cond_broadcast(QemuCond *cond);
35void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
aliguorie5d355d2009-04-24 18:03:15 +000036
37void qemu_thread_create(QemuThread *thread,
38 void *(*start_routine)(void*),
39 void *arg);
Jan Kiszkab7680cb2011-03-12 17:43:51 +010040void qemu_thread_get_self(QemuThread *thread);
41int qemu_thread_is_self(QemuThread *thread);
Corentin Chary313b1d62010-07-07 20:58:01 +020042void qemu_thread_exit(void *retval);
43
aliguorie5d355d2009-04-24 18:03:15 +000044#endif