diff options
author | Juan Quintela <quintela@redhat.com> | 2009-08-20 19:42:35 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-08-27 20:30:22 -0500 |
commit | 6f67c50ff42943a2ae51202dad0ef996dc40bb51 (patch) | |
tree | 0acd576a2ed29828b96a4417716e67b3b6ca6252 /hw/hw.h | |
parent | 2d1e9f96a2dc081e3a7eeb7b55482e0de4752fca (diff) |
Add VMState support for static sized buffers (uint_8)
This patch adds support for static sized buffer and typecheks that the buffer is right.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/hw.h')
-rw-r--r-- | hw/hw.h | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -285,6 +285,7 @@ enum VMStateFlags { VMS_ARRAY = 0x004, VMS_STRUCT = 0x008, VMS_VARRAY = 0x010, /* Array with size in another field */ + VMS_BUFFER = 0x020, /* static sized buffer */ }; typedef struct { @@ -321,6 +322,7 @@ extern const VMStateInfo vmstate_info_uint32; extern const VMStateInfo vmstate_info_uint64; extern const VMStateInfo vmstate_info_timer; +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) @@ -389,6 +391,16 @@ extern const VMStateInfo vmstate_info_timer; + type_check_array(_type,typeof_field(_state, _field),_num) \ } +#define VMSTATE_STATIC_BUFFER(_field, _state, _version) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .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))) \ +} + /* _f : field name _f_n : num of elements field_name _n : num of elements @@ -459,6 +471,12 @@ extern const VMStateInfo vmstate_info_timer; #define VMSTATE_INT32_VARRAY(_f, _s, _f_n) \ VMSTATE_INT32_VARRAY_V(_f, _s, _f_n, 0) +#define VMSTATE_BUFFER_V(_f, _s, _v) \ + VMSTATE_STATIC_BUFFER(_f, _s, _v) + +#define VMSTATE_BUFFER(_f, _s) \ + VMSTATE_STATIC_BUFFER(_f, _s, 0) + #define VMSTATE_END_OF_LIST() \ {} |