Patchwork [RFC,v1,4/7] qom/cpu: Introduce CPU super class cast macros

login
register
mail settings
Submitter Peter Crosthwaite
Date June 18, 2013, 9:46 a.m.
Message ID <d30a943775b5e9cd5b28b99b2b9e7d4b8ab12d8f.1371548267.git.peter.crosthwaite@xilinx.com>
Download mbox | patch
Permalink /patch/252207/
State New
Headers show

Comments

Peter Crosthwaite - June 18, 2013, 9:46 a.m.
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Add macros CPU_SUPER_CLASS and CPU_GET_SUPER_CLASS. These are the
similar to their respective non SUPER versions, except instead of
returning the class object for the concrete class, they return their
parent classes implementation (usually some form of abstract class).

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 include/qom/cpu.h | 4 ++++
 1 file changed, 4 insertions(+)

Patch

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index a5bb515..50d478a 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -39,6 +39,10 @@  typedef int (*WriteCoreDumpFunction)(void *buf, size_t size, void *opaque);
 #define CPU(obj) OBJECT_CHECK(CPUState, (obj), TYPE_CPU)
 #define CPU_CLASS(class) OBJECT_CLASS_CHECK(CPUClass, (class), TYPE_CPU)
 #define CPU_GET_CLASS(obj) OBJECT_GET_CLASS(CPUClass, (obj), TYPE_CPU)
+#define CPU_SUPER_CLASS(klass, typename) \
+    CPU_CLASS(object_class_get_super(OBJECT_CLASS(klass), typename))
+#define CPU_GET_SUPER_CLASS(obj, typename) \
+    CPU_SUPER_CLASS(CPU_GET_CLASS(obj), typename)
 
 typedef struct CPUState CPUState;