Patchwork [10/25] vmstate: factor vmstate_offset_buffer

login
register
mail settings
Submitter Juan Quintela
Date Oct. 19, 2009, 6:42 p.m.
Message ID <22ce40bec5b21956f332db80e1108d2bd86af199.1255976538.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/36401/
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 |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

Patch

diff --git a/hw/hw.h b/hw/hw.h
index d669755..aea50a6 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -350,6 +350,10 @@  extern const VMStateInfo vmstate_info_buffer;
     (offsetof(_state, _field) +                                      \
      type_check_array(_type, typeof_field(_state, _field), _num))

+#define vmstate_offset_buffer(_state, _field)                        \
+    vmstate_offset_array(_state, _field, uint8_t,                    \
+                         sizeof(typeof_field(_state, _field)))
+
 #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) {     \
     .name       = (stringify(_field)),                               \
     .version_id = (_version),                                        \
@@ -460,8 +464,7 @@  extern const VMStateInfo vmstate_info_buffer;
     .size       = sizeof(typeof_field(_state,_field)),               \
     .info       = &vmstate_info_buffer,                              \
     .flags      = VMS_BUFFER,                                        \
-    .offset     = offsetof(_state, _field)                           \
-        + type_check_array(uint8_t,typeof_field(_state, _field),sizeof(typeof_field(_state,_field))) \
+    .offset     = vmstate_offset_buffer(_state, _field),             \
 }

 #define VMSTATE_PARTIAL_BUFFER(_field, _state, _size) {              \
@@ -469,8 +472,7 @@  extern const VMStateInfo vmstate_info_buffer;
     .size       = (_size),                                           \
     .info       = &vmstate_info_buffer,                              \
     .flags      = VMS_BUFFER,                                        \
-    .offset     = offsetof(_state, _field)                           \
-        + type_check_array(uint8_t,typeof_field(_state, _field),sizeof(typeof_field(_state,_field))) \
+    .offset     = vmstate_offset_buffer(_state, _field),             \
 }

 #define VMSTATE_BUFFER_START_MIDDLE(_field, _state, start) {         \
@@ -478,8 +480,7 @@  extern const VMStateInfo vmstate_info_buffer;
     .size       = sizeof(typeof_field(_state,_field)) - start,       \
     .info       = &vmstate_info_buffer,                              \
     .flags      = VMS_BUFFER,                                        \
-    .offset     = offsetof(_state, _field) + start                   \
-        + type_check_array(uint8_t,typeof_field(_state, _field),sizeof(typeof_field(_state,_field))) \
+    .offset     = vmstate_offset_buffer(_state, _field) + start,     \
 }

 extern const VMStateDescription vmstate_pci_device;