From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/6] qemu/queue.h: typedef QTAILQ heads
Date: Fri, 7 Dec 2018 11:15:50 +0100 [thread overview]
Message-ID: <3cb3ef4c-4d58-7f5f-6d22-2eca1d2e6dee@redhat.com> (raw)
In-Reply-To: <20181206232333.22408-4-pbonzini@redhat.com>
On 12/7/18 12:23 AM, Paolo Bonzini wrote:
> This will be needed when we change the QTAILQ head and elem structs
> to unions. However, it is also consistent with the usage elsewhere
> in QEMU for other list head structs (see for example FsMountList).
>
> Note that most QTAILQs only need their name in order to do backwards
> walks. Those do not break with the struct->union change, and anyway
> the change will also remove the need to name heads when doing backwards
> walks, so those are not touched here.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> exec.c | 3 ++-
> include/qom/cpu.h | 5 +++--
> ui/input.c | 14 ++++++++------
> 3 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/exec.c b/exec.c
> index b6b2007f27..a629c98eb5 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -94,7 +94,8 @@ int target_page_bits;
> bool target_page_bits_decided;
> #endif
>
> -struct CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);
> +CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);
> +
> /* current CPU in the current thread. It is only valid inside
> cpu_exec() */
> __thread CPUState *current_cpu;
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index 62aef77b87..4662a205c1 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -435,8 +435,9 @@ struct CPUState {
> GArray *iommu_notifiers;
> };
>
> -QTAILQ_HEAD(CPUTailQ, CPUState);
> -extern struct CPUTailQ cpus;
> +typedef QTAILQ_HEAD(CPUTailQ, CPUState) CPUTailQ;
> +extern CPUTailQ cpus;
> +
> #define first_cpu QTAILQ_FIRST_RCU(&cpus)
> #define CPU_NEXT(cpu) QTAILQ_NEXT_RCU(cpu, node)
> #define CPU_FOREACH(cpu) QTAILQ_FOREACH_RCU(cpu, &cpus, node)
> diff --git a/ui/input.c b/ui/input.c
> index 7c9a4109c4..35c7964f64 100644
> --- a/ui/input.c
> +++ b/ui/input.c
> @@ -19,6 +19,9 @@ struct QemuInputHandlerState {
> };
>
> typedef struct QemuInputEventQueue QemuInputEventQueue;
> +typedef QTAILQ_HEAD(QemuInputEventQueueHead, QemuInputEventQueue)
> + QemuInputEventQueueHead;
> +
> struct QemuInputEventQueue {
> enum {
> QEMU_INPUT_QUEUE_DELAY = 1,
> @@ -37,8 +40,7 @@ static QTAILQ_HEAD(, QemuInputHandlerState) handlers =
> static NotifierList mouse_mode_notifiers =
> NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
>
> -static QTAILQ_HEAD(QemuInputEventQueueHead, QemuInputEventQueue) kbd_queue =
> - QTAILQ_HEAD_INITIALIZER(kbd_queue);
> +static QemuInputEventQueueHead kbd_queue = QTAILQ_HEAD_INITIALIZER(kbd_queue);
> static QEMUTimer *kbd_timer;
> static uint32_t kbd_default_delay_ms = 10;
> static uint32_t queue_count;
> @@ -257,7 +259,7 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
>
> static void qemu_input_queue_process(void *opaque)
> {
> - struct QemuInputEventQueueHead *queue = opaque;
> + QemuInputEventQueueHead *queue = opaque;
> QemuInputEventQueue *item;
>
> g_assert(!QTAILQ_EMPTY(queue));
> @@ -288,7 +290,7 @@ static void qemu_input_queue_process(void *opaque)
> }
> }
>
> -static void qemu_input_queue_delay(struct QemuInputEventQueueHead *queue,
> +static void qemu_input_queue_delay(QemuInputEventQueueHead *queue,
> QEMUTimer *timer, uint32_t delay_ms)
> {
> QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1);
> @@ -306,7 +308,7 @@ static void qemu_input_queue_delay(struct QemuInputEventQueueHead *queue,
> }
> }
>
> -static void qemu_input_queue_event(struct QemuInputEventQueueHead *queue,
> +static void qemu_input_queue_event(QemuInputEventQueueHead *queue,
> QemuConsole *src, InputEvent *evt)
> {
> QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1);
> @@ -318,7 +320,7 @@ static void qemu_input_queue_event(struct QemuInputEventQueueHead *queue,
> queue_count++;
> }
>
> -static void qemu_input_queue_sync(struct QemuInputEventQueueHead *queue)
> +static void qemu_input_queue_sync(QemuInputEventQueueHead *queue)
> {
> QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1);
>
>
next prev parent reply other threads:[~2018-12-07 10:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-06 23:23 [Qemu-devel] [PATCH for-4.0 0/6] qemu/queue.h usage cleanup, improved QTAILQ API Paolo Bonzini
2018-12-06 23:23 ` [Qemu-devel] [PATCH 1/6] qemu/queue.h: do not access tqe_prev directly Paolo Bonzini
2018-12-07 7:14 ` Markus Armbruster
2018-12-07 10:14 ` Philippe Mathieu-Daudé
2018-12-06 23:23 ` [Qemu-devel] [PATCH 2/6] qemu/queue.h: leave head structs anonymous unless necessary Paolo Bonzini
2018-12-07 7:28 ` Markus Armbruster
2018-12-07 13:47 ` Paolo Bonzini
2018-12-06 23:23 ` [Qemu-devel] [PATCH 3/6] qemu/queue.h: typedef QTAILQ heads Paolo Bonzini
2018-12-07 7:30 ` Markus Armbruster
2018-12-07 10:15 ` Philippe Mathieu-Daudé [this message]
2018-12-06 23:23 ` [Qemu-devel] [PATCH 4/6] qemu/queue.h: reimplement QTAILQ without pointer-to-pointers Paolo Bonzini
2018-12-07 9:22 ` Markus Armbruster
2018-12-06 23:23 ` [Qemu-devel] [PATCH 5/6] qemu/queue.h: simplify reverse access to QTAILQ Paolo Bonzini
2018-12-06 23:23 ` [Qemu-devel] [PATCH 6/6] checkpatch: warn about queue/queue.h head structs that are not typedef-ed Paolo Bonzini
2018-12-07 9:02 ` Markus Armbruster
2018-12-07 13:49 ` 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=3cb3ef4c-4d58-7f5f-6d22-2eca1d2e6dee@redhat.com \
--to=philmd@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).