Patchwork [11/25] vmstate: factor VMSTATE_*BUFFER* definitions

login
register
mail settings
Submitter Juan Quintela
Date Oct. 19, 2009, 6:42 p.m.
Message ID <3f0d49e274770144dd9015e1389e6958ecf50df5.1255976538.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/36402/
State New
Headers show

Comments

Juan Quintela - Oct. 19, 2009, 6:42 p.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/hw.h |   32 +++++++++++---------------------
 1 files changed, 11 insertions(+), 21 deletions(-)

Patch

diff --git a/hw/hw.h b/hw/hw.h
index aea50a6..dd065c8 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -458,29 +458,13 @@  extern const VMStateInfo vmstate_info_buffer;
     .offset     = vmstate_offset_array(_state, _field, _type, _num), \
 }

-#define VMSTATE_STATIC_BUFFER(_field, _state, _version) {            \
+#define VMSTATE_STATIC_BUFFER(_field, _state, _version, _start, _size) {   \
     .name       = (stringify(_field)),                               \
     .version_id = (_version),                                        \
-    .size       = sizeof(typeof_field(_state,_field)),               \
+    .size       = (_size - _start),                                  \
     .info       = &vmstate_info_buffer,                              \
     .flags      = VMS_BUFFER,                                        \
-    .offset     = vmstate_offset_buffer(_state, _field),             \
-}
-
-#define VMSTATE_PARTIAL_BUFFER(_field, _state, _size) {              \
-    .name       = (stringify(_field)),                               \
-    .size       = (_size),                                           \
-    .info       = &vmstate_info_buffer,                              \
-    .flags      = VMS_BUFFER,                                        \
-    .offset     = vmstate_offset_buffer(_state, _field),             \
-}
-
-#define VMSTATE_BUFFER_START_MIDDLE(_field, _state, start) {         \
-    .name       = (stringify(_field)),                               \
-    .size       = sizeof(typeof_field(_state,_field)) - start,       \
-    .info       = &vmstate_info_buffer,                              \
-    .flags      = VMS_BUFFER,                                        \
-    .offset     = vmstate_offset_buffer(_state, _field) + start,     \
+    .offset     = vmstate_offset_buffer(_state, _field) + _start,    \
 }

 extern const VMStateDescription vmstate_pci_device;
@@ -622,10 +606,16 @@  extern const VMStateDescription vmstate_i2c_slave;
     VMSTATE_INT32_VARRAY_V(_f, _s, _f_n, 0)

 #define VMSTATE_BUFFER_V(_f, _s, _v)                                  \
-    VMSTATE_STATIC_BUFFER(_f, _s, _v)
+    VMSTATE_STATIC_BUFFER(_f, _s, _v, 0, sizeof(typeof_field(_s, _f)))

 #define VMSTATE_BUFFER(_f, _s)                                        \
-    VMSTATE_STATIC_BUFFER(_f, _s, 0)
+    VMSTATE_BUFFER_V(_f, _s, 0)
+
+#define VMSTATE_PARTIAL_BUFFER(_f, _s, _size)                         \
+    VMSTATE_STATIC_BUFFER(_f, _s, 0, 0, _size)
+
+#define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
+    VMSTATE_STATIC_BUFFER(_f, _s, 0, _start, sizeof(typeof_field(_s, _f)))

 #ifdef NEED_CPU_H
 #if TARGET_LONG_BITS == 64