From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 3/5] qemu-queue: drop QCIRCLEQ
Date: Fri, 13 Jan 2012 20:11:04 +0100 [thread overview]
Message-ID: <jepvk9$i0j$1@dough.gmane.org> (raw)
In-Reply-To: <4F106457.3040208@redhat.com>
On 01/13/2012 06:05 PM, Paolo Bonzini wrote:
> I think it's not entirely correct because the cast in QTAILQ_PREV and
> QTAILQ_FOREACH_REVERSE does not look like valid ANSI C. No matter how
> hard I look I admit I cannot figure out how it works, but anyway I
> suspect it can be changed to ANSI C using typeof if one was bitten by
> it. So removing QCIRCLEQ is not a bad idea anyway.
Ah, got it. Here are two ways to rewrite it using typeof (not exactly
ANSI C of course, but perhaps somewhat more aliasing friendly).
#define QTAILQ_PREV(elm, next) \
(*(((__typeof__((elm)->next) *)((elm)->next.tqe_prev))->tqe_prev))
#define Q_TAILQ_PREV(tqe) \
((__typeof__(tqe) *)((tqe).tqe_prev))
#define QTAILQ_PREV(elm, next) \
(Q_TAILQ_PREV(*Q_TAILQ_PREV((elm)->next))->tqe_next)
It's treating the TAILQ as a half-linear (forwards), half-circular
(backwards) list. Doing two backwards accesses and one forwards
access ensures that the last access is always on a pointer rather
than a pointer-to-pointer. Clever.
Paolo
next prev parent reply other threads:[~2012-01-13 19:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-13 16:34 [Qemu-devel] [PATCH v2 0/5] qemu-queue cleanups Paolo Bonzini
2012-01-13 16:34 ` [Qemu-devel] [PATCH v2 1/5] notifier: switch to QLIST Paolo Bonzini
2012-01-13 16:34 ` [Qemu-devel] [PATCH v2 2/5] qemu-queue: add QSLIST Paolo Bonzini
2012-01-13 16:34 ` [Qemu-devel] [PATCH v2 3/5] qemu-queue: drop QCIRCLEQ Paolo Bonzini
2012-01-13 16:44 ` Peter Maydell
2012-01-13 17:05 ` Paolo Bonzini
2012-01-13 19:11 ` Paolo Bonzini [this message]
2012-01-13 16:34 ` [Qemu-devel] [PATCH v2 4/5] coroutine: switch to QSLIST Paolo Bonzini
2012-01-13 16:34 ` [Qemu-devel] [PATCH v2 5/5] block: use QSLIST for the AIO free list Paolo Bonzini
2012-02-17 16:03 ` Anthony Liguori
2012-02-15 9:05 ` [Qemu-devel] [PATCH v2 0/5] qemu-queue cleanups Paolo Bonzini
2012-02-17 18:15 ` Anthony Liguori
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='jepvk9$i0j$1@dough.gmane.org' \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.