summaryrefslogtreecommitdiffstats
path: root/include/qemu/thread.h
diff options
context:
space:
mode:
authorPaolo Bonzini2018-02-03 16:39:32 +0100
committerFam Zheng2018-02-08 02:22:03 +0100
commite70372fcaffc99444edce400a5178cb196cddaf7 (patch)
treec79196b96035dfb317518b22df44c806017ed79c /include/qemu/thread.h
parenttest-coroutine: add simple CoMutex test (diff)
downloadqemu-e70372fcaffc99444edce400a5178cb196cddaf7.tar.gz
qemu-e70372fcaffc99444edce400a5178cb196cddaf7.tar.xz
qemu-e70372fcaffc99444edce400a5178cb196cddaf7.zip
lockable: add QemuLockable
QemuLockable is a polymorphic lock type that takes an object and knows which function to use for locking and unlocking. The implementation could use C11 _Generic, but since the support is not very widespread I am instead using __builtin_choose_expr and __builtin_types_compatible_p, which are already used by include/qemu/atomic.h. QemuLockable can be used to implement lock guards, or to pass around a lock in such a way that a function can release it and re-acquire it. The next patch will do this for CoQueue. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20180203153935.8056-3-pbonzini@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'include/qemu/thread.h')
-rw-r--r--include/qemu/thread.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/include/qemu/thread.h b/include/qemu/thread.h
index 9af4e945aa..ef7bd16123 100644
--- a/include/qemu/thread.h
+++ b/include/qemu/thread.h
@@ -4,7 +4,6 @@
#include "qemu/processor.h"
#include "qemu/atomic.h"
-typedef struct QemuMutex QemuMutex;
typedef struct QemuCond QemuCond;
typedef struct QemuSemaphore QemuSemaphore;
typedef struct QemuEvent QemuEvent;
@@ -97,9 +96,9 @@ struct Notifier;
void qemu_thread_atexit_add(struct Notifier *notifier);
void qemu_thread_atexit_remove(struct Notifier *notifier);
-typedef struct QemuSpin {
+struct QemuSpin {
int value;
-} QemuSpin;
+};
static inline void qemu_spin_init(QemuSpin *spin)
{