]> Git Repo - qemu.git/commit - include/qemu/typedefs.h
lockable: add QemuLockable
authorPaolo Bonzini <[email protected]>
Sat, 3 Feb 2018 15:39:32 +0000 (10:39 -0500)
committerFam Zheng <[email protected]>
Thu, 8 Feb 2018 01:22:03 +0000 (09:22 +0800)
commite70372fcaffc99444edce400a5178cb196cddaf7
treec79196b96035dfb317518b22df44c806017ed79c
parent439b6e5efcd79effc5199cba533fe4b28d75e0f6
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 <[email protected]>
Message-Id: <20180203153935[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Fam Zheng <[email protected]>
Signed-off-by: Fam Zheng <[email protected]>
include/qemu/compiler.h
include/qemu/coroutine.h
include/qemu/lockable.h [new file with mode: 0644]
include/qemu/thread.h
include/qemu/typedefs.h
tests/test-coroutine.c
This page took 0.027182 seconds and 4 git commands to generate.