qemu-thread.h 1.2 KB
Newer Older
1 2 3
#ifndef __QEMU_THREAD_H
#define __QEMU_THREAD_H 1

A
Alon Levy 已提交
4 5
#include <inttypes.h>

6 7 8 9
typedef struct QemuMutex QemuMutex;
typedef struct QemuCond QemuCond;
typedef struct QemuThread QemuThread;

10 11 12 13 14 15
#ifdef _WIN32
#include "qemu-thread-win32.h"
#else
#include "qemu-thread-posix.h"
#endif

16
void qemu_mutex_init(QemuMutex *mutex);
17
void qemu_mutex_destroy(QemuMutex *mutex);
18 19 20 21
void qemu_mutex_lock(QemuMutex *mutex);
int qemu_mutex_trylock(QemuMutex *mutex);
void qemu_mutex_unlock(QemuMutex *mutex);

22 23 24
#define rcu_read_lock() do { } while (0)
#define rcu_read_unlock() do { } while (0)

25
void qemu_cond_init(QemuCond *cond);
26
void qemu_cond_destroy(QemuCond *cond);
27 28 29 30 31 32

/*
 * IMPORTANT: The implementation does not guarantee that pthread_cond_signal
 * and pthread_cond_broadcast can be called except while the same mutex is
 * held as in the corresponding pthread_cond_wait calls!
 */
33 34 35 36 37 38 39
void qemu_cond_signal(QemuCond *cond);
void qemu_cond_broadcast(QemuCond *cond);
void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);

void qemu_thread_create(QemuThread *thread,
                       void *(*start_routine)(void*),
                       void *arg);
J
Jan Kiszka 已提交
40 41
void qemu_thread_get_self(QemuThread *thread);
int qemu_thread_is_self(QemuThread *thread);
42 43
void qemu_thread_exit(void *retval);

44
#endif