From: Eric Blake <eblake@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: famz@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/5] lockable: add QemuLockable
Date: Thu, 25 Jan 2018 14:13:20 -0600 [thread overview]
Message-ID: <19017a4f-c586-5551-9fcb-d10b49eaa961@redhat.com> (raw)
In-Reply-To: <20180125175949.7780-3-pbonzini@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1153 bytes --]
On 01/25/2018 11:59 AM, Paolo Bonzini wrote:
> 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>
> ---
> +
> +static inline __attribute__((__always_inline__)) QemuLockable *
> +qemu_make_lockable(void *x, QemuLockable *lockable)
> +{
> + /* We cannot test this in a macro, otherwise we get * compiler
Spurious '*' ?
> + * warnings like "the address of 'm' will always evaluate as 'true'".
> + */
> + return x ? lockable : NULL;
> +}
> +
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2018-01-25 20:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 17:59 [Qemu-devel] [PATCH v3 0/5] coroutine-lock: polymorphic CoQueue Paolo Bonzini
2018-01-25 17:59 ` [Qemu-devel] [PATCH 1/5] test-coroutine: add simple CoMutex test Paolo Bonzini
2018-01-29 13:26 ` Stefan Hajnoczi
2018-01-25 17:59 ` [Qemu-devel] [PATCH 2/5] lockable: add QemuLockable Paolo Bonzini
2018-01-25 20:13 ` Eric Blake [this message]
2018-01-26 3:11 ` Fam Zheng
2018-01-26 5:24 ` Fam Zheng
2018-01-29 11:42 ` Stefan Hajnoczi
2018-01-29 14:30 ` Paolo Bonzini
2018-01-25 17:59 ` [Qemu-devel] [PATCH 3/5] coroutine-lock: convert CoQueue to use QemuLockable Paolo Bonzini
2018-01-29 13:26 ` Stefan Hajnoczi
2018-01-25 17:59 ` [Qemu-devel] [PATCH 4/5] coroutine-lock: make qemu_co_enter_next thread-safe Paolo Bonzini
2018-01-25 20:15 ` Eric Blake
2018-01-29 13:26 ` Stefan Hajnoczi
2018-02-01 15:28 ` Paolo Bonzini
2018-01-25 17:59 ` [Qemu-devel] [PATCH 5/5] curl: convert to CoQueue Paolo Bonzini
2018-01-29 13:27 ` Stefan Hajnoczi
2018-01-25 18:08 ` [Qemu-devel] [PATCH v3 0/5] coroutine-lock: polymorphic CoQueue no-reply
2018-01-25 20:31 ` Eric Blake
-- strict thread matches above, loose matches on Subject: below --
2018-02-01 21:29 [Qemu-devel] [PATCH v4 " Paolo Bonzini
2018-02-01 21:29 ` [Qemu-devel] [PATCH 2/5] lockable: add QemuLockable Paolo Bonzini
2018-02-03 15:39 [Qemu-devel] [PATCH v5 0/5] coroutine-lock: polymorphic CoQueue Paolo Bonzini
2018-02-03 15:39 ` [Qemu-devel] [PATCH 2/5] lockable: add QemuLockable Paolo Bonzini
2018-02-03 20:44 ` Richard Henderson
2018-02-05 14:38 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19017a4f-c586-5551-9fcb-d10b49eaa961@redhat.com \
--to=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).