diff mbox series

[for-6.2,v3,1/2] qom: DECLARE_INTERFACE_CHECKER macro

Message ID 20210809200714.887337-2-ehabkost@redhat.com
State New
Headers show
Series qom: DECLARE_INTERFACE_CHECKER macro | expand

Commit Message

Eduardo Habkost Aug. 9, 2021, 8:07 p.m. UTC
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 mbox series

Patch

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