From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Daniel P. Berrange" <berrange@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@gmail.com>
Subject: [PATCH for-6.2 v3 1/2] qom: DECLARE_INTERFACE_CHECKER macro
Date: Mon, 9 Aug 2021 16:07:13 -0400 [thread overview]
Message-ID: <20210809200714.887337-2-ehabkost@redhat.com> (raw)
In-Reply-To: <20210809200714.887337-1-ehabkost@redhat.com>
The new macro will be similar to DECLARE_INSTANCE_CHECKER,
but for interface types (that use INTEFACE_CHECK instead of
OBJECT_CHECK).
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes series v1 -> v2: none
Change series v2 -> v3:
* Rebased on top of
[PATCH for-6.2 00/12] qom: Get rid of all manual usage of OBJECT_CHECK & friends
---
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org
---
include/qom/object.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index faae0d841fe..4a9d7017d9f 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -178,6 +178,20 @@ struct Object
OBJ_NAME(const void *obj) \
{ return OBJECT_CHECK(InstanceType, obj, TYPENAME); }
+/**
+ * DECLARE_INTERFACE_CHECKER:
+ * @InstanceType: instance type
+ * @OBJ_NAME: the object name in uppercase with underscore separators
+ * @TYPENAME: type name
+ *
+ * This macro will provide the instance type cast functions for a
+ * QOM interface type.
+ */
+#define DECLARE_INTERFACE_CHECKER(InstanceType, OBJ_NAME, TYPENAME) \
+ static inline G_GNUC_UNUSED InstanceType * \
+ OBJ_NAME(const void *obj) \
+ { return INTERFACE_CHECK(InstanceType, obj, TYPENAME); }
+
/**
* DECLARE_CLASS_CHECKERS:
* @ClassType: class struct name
--
2.31.1
next prev parent reply other threads:[~2021-08-09 20:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-09 20:07 [PATCH for-6.2 v3 0/2] qom: DECLARE_INTERFACE_CHECKER macro Eduardo Habkost
2021-08-09 20:07 ` Eduardo Habkost [this message]
2021-08-09 20:07 ` [PATCH for-6.2 v3 2/2] [autoamted] Use " Eduardo Habkost
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=20210809200714.887337-2-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=berrange@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=pbonzini@redhat.com \
--cc=philmd@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).