Skip to contentSkip to conversation

vmstate: Add support for an array of ptimer_state *

PATCH New Peter Maydell 1 participant 1 message Dec 12, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vmstate: Add support for an array of ptimer_state *

Add support for defining a vmstate field which is an array of pointers to structures, and use this to define a VMSTATE_PTIMER_ARRAY() which allows an array of ptimer_state* to be used by devices.

---
This is an odd lacuna in the VMSTATE macros, given that the underlying savevm machinery entirely supports the combination of VMS_ flags. This will be used in the Allwinner A10 timer.

 include/hw/ptimer.h         |  4 ++++
 include/migration/vmstate.h | 10 ++++++++++
 2 files changed, 14 insertions(+)
include/hw/ptimer.h +4 -0
index 28fcaf1..a33edf4 100644
@@ -36,4 +36,8 @@ extern const VMStateDescription vmstate_ptimer;
     .offset     = vmstate_offset_pointer(_state, _field, ptimer_state), \
 }
 
+#define VMSTATE_PTIMER_ARRAY(_f, _s, _n)                                \
+    VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(_f, _s, _n, 0,                   \
+                                       vmstate_ptimer, ptimer_state)
+
 #endif
include/migration/vmstate.h +10 -0
index 9d09e60..be193ba 100644
@@ -339,6 +339,16 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = vmstate_offset_array(_state, _field, _type, _num), \
 }
 
+#define VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(_f, _s, _n, _v, _vmsd, _type) { \
+    .name       = (stringify(_f)),                                   \
+    .version_id = (_v),                                              \
+    .num        = (_n),                                              \
+    .vmsd       = &(_vmsd),                                          \
+    .size       = sizeof(_type *),                                    \
+    .flags      = VMS_ARRAY|VMS_STRUCT|VMS_ARRAY_OF_POINTER,         \
+    .offset     = vmstate_offset_array(_s, _f, _type*, _n),          \
+}
+
 #define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \
     .name         = (stringify(_field)),                             \
     .num          = (_num),                                          \
Signature · 1 line
1.8.5