From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Subject: [PULL 3/5] qapi: Introduce QAPI_LIST_APPEND
Date: Thu, 28 Jan 2021 08:45:04 +0100 [thread overview]
Message-ID: <20210128074506.2725379-4-armbru@redhat.com> (raw)
In-Reply-To: <20210128074506.2725379-1-armbru@redhat.com>
From: Eric Blake <eblake@redhat.com>
Similar to the existing QAPI_LIST_PREPEND, but designed for use where
we want to preserve insertion order. Callers will be added in
upcoming patches. Note the difference in signature: PREPEND takes
List*, APPEND takes List**.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210113221013.390592-4-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
include/qapi/util.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/qapi/util.h b/include/qapi/util.h
index 6178e98e97..d7bfb30e25 100644
--- a/include/qapi/util.h
+++ b/include/qapi/util.h
@@ -37,4 +37,17 @@ int parse_qapi_name(const char *name, bool complete);
(list) = _tmp; \
} while (0)
+/*
+ * For any pointer to a GenericList @tail (usually the 'next' member of a
+ * list element), insert @element at the back and update the tail.
+ *
+ * Note that this macro evaluates @element exactly once, so it is safe
+ * to have side-effects with that argument.
+ */
+#define QAPI_LIST_APPEND(tail, element) do { \
+ *(tail) = g_malloc0(sizeof(**(tail))); \
+ (*(tail))->value = (element); \
+ (tail) = &(*(tail))->next; \
+} while (0)
+
#endif
--
2.26.2
next prev parent reply other threads:[~2021-01-28 7:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 7:45 [PULL 0/5] QAPI patches patches for 2021-01-28 Markus Armbruster
2021-01-28 7:45 ` [PULL 1/5] net: Clarify early exit condition Markus Armbruster
2021-01-28 7:45 ` [PULL 2/5] qapi: A couple more QAPI_LIST_PREPEND() stragglers Markus Armbruster
2021-01-28 7:45 ` Markus Armbruster [this message]
2021-01-28 7:45 ` [PULL 4/5] qapi: Use QAPI_LIST_APPEND in trivial cases Markus Armbruster
2021-01-28 7:45 ` [PULL 5/5] qapi: More complex uses of QAPI_LIST_APPEND Markus Armbruster
2021-01-29 10:10 ` [PULL 0/5] QAPI patches patches for 2021-01-28 Peter Maydell
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=20210128074506.2725379-4-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/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.