diff mbox

[08/35] vmstate: introduce float32 arrays

Message ID b894204df3fb4058abf165559daf19b7ffe28c62.1336128412.git.quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela May 4, 2012, 10:54 a.m. UTC
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 savevm.c  |   25 +++++++++++++++++++++++++
 vmstate.h |    5 +++++
 2 files changed, 30 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/savevm.c b/savevm.c
index 2d18bab..a22278e 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1082,6 +1082,31 @@  const VMStateInfo vmstate_info_uint16_equal = {
     .put  = put_uint16,
 };

+/* 32 bit float */
+
+static int get_float32(QEMUFile *f, void *pv, size_t size)
+{
+    float32 *v = pv;
+    uint32_t u;
+    qemu_get_be32s(f, &u);
+    *v = make_float32(u);
+    return 0;
+}
+
+static void put_float32(QEMUFile *f, void *pv, size_t size)
+{
+    float32 *v = pv;
+    uint32_t u;
+    u = float32_val(*v);
+    qemu_put_be32s(f, &u);
+}
+
+const VMStateInfo vmstate_info_float32 = {
+    .name = "float32",
+    .get  = get_float32,
+    .put  = put_float32,
+};
+
 /* timers  */

 static int get_timer(QEMUFile *f, void *pv, size_t size)
diff --git a/vmstate.h b/vmstate.h
index 1a4a60b..135c5aa 100644
--- a/vmstate.h
+++ b/vmstate.h
@@ -130,6 +130,8 @@  extern const VMStateInfo vmstate_info_uint16;
 extern const VMStateInfo vmstate_info_uint32;
 extern const VMStateInfo vmstate_info_uint64;

+extern const VMStateInfo vmstate_info_float32;
+
 extern const VMStateInfo vmstate_info_timer;
 extern const VMStateInfo vmstate_info_buffer;
 extern const VMStateInfo vmstate_info_unused_buffer;
@@ -559,6 +561,9 @@  extern const VMStateDescription vmstate_cpu;
 #define VMSTATE_INT64_ARRAY(_f, _s, _n)                               \
     VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)

+#define VMSTATE_FLOAT32_ARRAY(_f, _s, _n)                             \
+    VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float32, float32)
+
 #define VMSTATE_BUFFER_V(_f, _s, _v)                                  \
     VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))