[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/25] vmstate: factor vmstate_offset_value
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 07/25] vmstate: factor vmstate_offset_value |
Date: |
Mon, 19 Oct 2009 20:42:52 +0200 |
Signed-off-by: Juan Quintela <address@hidden>
---
hw/hw.h | 31 +++++++++++++------------------
1 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/hw/hw.h b/hw/hw.h
index cd42f74..d1395e9 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -338,14 +338,17 @@ extern const VMStateInfo vmstate_info_buffer;
#define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
#define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
+#define vmstate_offset_value(_state, _field, _type) \
+ (offsetof(_state, _field) + \
+ type_check(_type, typeof_field(_state, _field)))
+
#define VMSTATE_SINGLE(_field, _state, _version, _info, _type) { \
.name = (stringify(_field)), \
.version_id = (_version), \
.size = sizeof(_type), \
.info = &(_info), \
.flags = VMS_SINGLE, \
- .offset = offsetof(_state, _field) \
- + type_check(_type,typeof_field(_state, _field)) \
+ .offset = vmstate_offset_value(_state, _field, _type), \
}
#define VMSTATE_SINGLE_TEST(_field, _state, _test, _info, _type) { \
@@ -354,8 +357,7 @@ extern const VMStateInfo vmstate_info_buffer;
.size = sizeof(_type), \
.info = &(_info), \
.flags = VMS_SINGLE, \
- .offset = offsetof(_state, _field) \
- + type_check(_type,typeof_field(_state, _field)) \
+ .offset = vmstate_offset_value(_state, _field, _type), \
}
#define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
@@ -364,8 +366,7 @@ extern const VMStateInfo vmstate_info_buffer;
.info = &(_info), \
.size = sizeof(_type), \
.flags = VMS_SINGLE|VMS_POINTER, \
- .offset = offsetof(_state, _field) \
- + type_check(_type,typeof_field(_state, _field)) \
+ .offset = vmstate_offset_value(_state, _field, _type), \
}
#define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
@@ -393,8 +394,7 @@ extern const VMStateInfo vmstate_info_buffer;
#define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info,
_type) {\
.name = (stringify(_field)), \
.version_id = (_version), \
- .num_offset = offsetof(_state, _field_num) \
- + type_check(int32_t,typeof_field(_state, _field_num)), \
+ .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
.info = &(_info), \
.size = sizeof(_type), \
.flags = VMS_VARRAY_INT32|VMS_POINTER, \
@@ -408,8 +408,7 @@ extern const VMStateInfo vmstate_info_buffer;
.vmsd = &(_vmsd), \
.size = sizeof(_type), \
.flags = VMS_STRUCT, \
- .offset = offsetof(_state, _field) \
- + type_check(_type,typeof_field(_state, _field)) \
+ .offset = vmstate_offset_value(_state, _field, _type), \
}
#define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) { \
@@ -417,8 +416,7 @@ extern const VMStateInfo vmstate_info_buffer;
.vmsd = &(_vmsd), \
.size = sizeof(_type), \
.flags = VMS_STRUCT|VMS_POINTER, \
- .offset = offsetof(_state, _field) \
- + type_check(_type,typeof_field(_state, _field)) \
+ .offset = vmstate_offset_value(_state, _field, _type), \
}
#define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type)
{\
@@ -445,8 +443,7 @@ extern const VMStateInfo vmstate_info_buffer;
#define VMSTATE_STRUCT_ARRAY_SIZE_UINT8(_field, _state, _field__num, _version,
_vmsd, _type) { \
.name = (stringify(_field)), \
- .num_offset = offsetof(_state, _field_num) \
- + type_check(uint8_t,typeof_field(_state, _field_num)), \
+ .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
.version_id = (_version), \
.vmsd = &(_vmsd), \
.size = sizeof(_type), \
@@ -490,8 +487,7 @@ extern const VMStateDescription vmstate_pci_device;
.size = sizeof(PCIDevice), \
.vmsd = &vmstate_pci_device, \
.flags = VMS_STRUCT, \
- .offset = offsetof(_state, _field) \
- + type_check(PCIDevice,typeof_field(_state, _field)) \
+ .offset = vmstate_offset_value(_state, _field, PCIDevice), \
}
extern const VMStateDescription vmstate_i2c_slave;
@@ -501,8 +497,7 @@ extern const VMStateDescription vmstate_i2c_slave;
.size = sizeof(i2c_slave), \
.vmsd = &vmstate_i2c_slave, \
.flags = VMS_STRUCT, \
- .offset = offsetof(_state, _field) \
- + type_check(i2c_slave,typeof_field(_state, _field)) \
+ .offset = vmstate_offset_value(_state, _field, i2c_slave), \
}
/* _f : field name
--
1.6.2.5
- [Qemu-devel] [PATCH 00/25] VMState cleanups and conversion of network drivers, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 01/25] vmstate: Add support for partial buffers transmission, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 03/25] vnmstate: fix name for uint8_equal, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 02/25] serial: use post_load version_id field and remove pre_load function, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 04/25] vmstate: add VMSTATE_UINT16_EQUAL[_V], Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 05/25] vmstate: Rename VMS_VARRAY to VMS_VARRAY_INT32, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 06/25] vmstate: fix indentation, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 07/25] vmstate: factor vmstate_offset_value,
Juan Quintela <=
- [Qemu-devel] [PATCH 08/25] vmstate: factor vmstate_offset_pointer, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 09/25] vmstate: factor vmstate_offset_array, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 10/25] vmstate: factor vmstate_offset_buffer, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 11/25] vmstate: factor VMSTATE_*BUFFER* definitions, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 12/25] vmstate: Unfold VMSTATE_INT32_VARRAY() only use and remove it, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 13/25] vmstate: add VMS_VARRAY_UINT16_UNSAFE (varrays with uint16 indexes), Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 15/25] vmstate: Add VMSTATE_BUFFER_UNUSED, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 17/25] rtl8139: port TallyCounters to vmstate, Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 14/25] vmstate: Add version arg to VMSTATE_SINGLE_TEST(), Juan Quintela, 2009/10/19
- [Qemu-devel] [PATCH 16/25] vmstate: Introduce the concept of sub-arrays, Juan Quintela, 2009/10/19