mirror of
https://git.proxmox.com/git/qemu
synced 2025-06-15 04:18:02 +00:00

We have qemu_cpu_self and qemu_thread_self. The latter is retrieving the current thread, the former is checking for equality (using CPUState). We also have qemu_thread_equal which is only used like qemu_cpu_self. This refactors the interfaces, creating qemu_cpu_is_self and qemu_thread_is_self as well ass qemu_thread_get_self. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
#ifndef __QEMU_THREAD_H
|
|
#define __QEMU_THREAD_H 1
|
|
#include "semaphore.h"
|
|
#include "pthread.h"
|
|
|
|
struct QemuMutex {
|
|
pthread_mutex_t lock;
|
|
};
|
|
|
|
struct QemuCond {
|
|
pthread_cond_t cond;
|
|
};
|
|
|
|
struct QemuThread {
|
|
pthread_t thread;
|
|
};
|
|
|
|
typedef struct QemuMutex QemuMutex;
|
|
typedef struct QemuCond QemuCond;
|
|
typedef struct QemuThread QemuThread;
|
|
|
|
void qemu_mutex_init(QemuMutex *mutex);
|
|
void qemu_mutex_destroy(QemuMutex *mutex);
|
|
void qemu_mutex_lock(QemuMutex *mutex);
|
|
int qemu_mutex_trylock(QemuMutex *mutex);
|
|
int qemu_mutex_timedlock(QemuMutex *mutex, uint64_t msecs);
|
|
void qemu_mutex_unlock(QemuMutex *mutex);
|
|
|
|
void qemu_cond_init(QemuCond *cond);
|
|
void qemu_cond_destroy(QemuCond *cond);
|
|
void qemu_cond_signal(QemuCond *cond);
|
|
void qemu_cond_broadcast(QemuCond *cond);
|
|
void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
|
|
int qemu_cond_timedwait(QemuCond *cond, QemuMutex *mutex, uint64_t msecs);
|
|
|
|
void qemu_thread_create(QemuThread *thread,
|
|
void *(*start_routine)(void*),
|
|
void *arg);
|
|
void qemu_thread_signal(QemuThread *thread, int sig);
|
|
void qemu_thread_get_self(QemuThread *thread);
|
|
int qemu_thread_is_self(QemuThread *thread);
|
|
void qemu_thread_exit(void *retval);
|
|
|
|
#endif
|