Paolo Bonzini e70372fcaf 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>
2018-02-08 09:22:03 +08:00
..
2017-09-22 14:11:25 +02:00
2018-02-08 09:22:03 +08:00
2018-02-08 09:22:03 +08:00
2017-07-24 12:42:55 +01:00
2016-06-07 18:19:23 +03:00
2017-10-16 20:57:13 +03:00
2017-12-18 10:54:13 -05:00
2016-10-26 08:29:01 -07:00
2017-09-05 22:34:40 +02:00
2018-02-08 09:22:03 +08:00
2016-11-01 10:29:03 -06:00
2018-02-07 14:09:25 +01:00
2016-06-16 18:39:03 +02:00
2017-12-18 17:07:02 +03:00
2017-12-29 12:43:39 -08:00
2018-01-16 14:54:50 +01:00
2017-06-16 07:55:00 +08:00
2018-02-08 09:22:03 +08:00
2016-02-23 12:43:05 +00:00
2018-02-08 09:22:03 +08:00
2016-09-15 15:32:22 +03:00
2017-12-20 22:01:24 +08:00
2017-01-24 23:26:52 +03:00