diff mbox

[09/35] vmstate: introduce float64 arrays

Message ID d34a10aef6aada0704826ce5d684117e7f65e4b3.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 |    4 ++++
 2 files changed, 29 insertions(+), 0 deletions(-)

Comments

Andreas Färber May 4, 2012, 1:03 p.m. UTC | #1
Am 04.05.2012 12:54, schrieb Juan Quintela:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  savevm.c  |   25 +++++++++++++++++++++++++
>  vmstate.h |    4 ++++
>  2 files changed, 29 insertions(+), 0 deletions(-)
> 
> diff --git a/savevm.c b/savevm.c
> index a22278e..da8f234 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1107,6 +1107,31 @@ const VMStateInfo vmstate_info_float32 = {
>      .put  = put_float32,
>  };
> 
> +/* 64 bit float */
> +
> +static int get_float64(QEMUFile *f, void *pv, size_t size)
> +{
> +    float64 *v = pv;
> +    uint64_t u;
> +    qemu_get_be64s(f, &u);
> +    *v = make_float64(u);
> +    return 0;
> +}
> +
> +static void put_float64(QEMUFile *f, void *pv, size_t size)
> +{
> +    float64 *v = pv;
> +    uint64_t u;
> +    u = float64_val(*v);
> +    qemu_put_be64s(f, &u);
> +}
> +
> +const VMStateInfo vmstate_info_float64 = {
> +    .name = "float64",
> +    .get  = get_float64,
> +    .put  = put_float64,
> +};
> +
>  /* timers  */
> 
>  static int get_timer(QEMUFile *f, void *pv, size_t size)
> diff --git a/vmstate.h b/vmstate.h
> index 135c5aa..d3fb88c 100644
> --- a/vmstate.h
> +++ b/vmstate.h
> @@ -131,6 +131,7 @@ extern const VMStateInfo vmstate_info_uint32;
>  extern const VMStateInfo vmstate_info_uint64;
> 
>  extern const VMStateInfo vmstate_info_float32;
> +extern const VMStateInfo vmstate_info_float64;
> 
>  extern const VMStateInfo vmstate_info_timer;
>  extern const VMStateInfo vmstate_info_buffer;
> @@ -564,6 +565,9 @@ extern const VMStateDescription vmstate_cpu;
>  #define VMSTATE_FLOAT32_ARRAY(_f, _s, _n)                             \
>      VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float32, float32)
> 
> +#define VMSTATE_FLOAT64_ARRAY(_f, _s, _n)                             \
> +    VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float64, float64)

Same comment as for float32:
Why not _FLOAT64_ARRAY -> _FLOAT64_ARRAY_V -> _ARRAY?

/-F

> +
>  #define VMSTATE_BUFFER_V(_f, _s, _v)                                  \
>      VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
>
diff mbox

Patch

diff --git a/savevm.c b/savevm.c
index a22278e..da8f234 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1107,6 +1107,31 @@  const VMStateInfo vmstate_info_float32 = {
     .put  = put_float32,
 };

+/* 64 bit float */
+
+static int get_float64(QEMUFile *f, void *pv, size_t size)
+{
+    float64 *v = pv;
+    uint64_t u;
+    qemu_get_be64s(f, &u);
+    *v = make_float64(u);
+    return 0;
+}
+
+static void put_float64(QEMUFile *f, void *pv, size_t size)
+{
+    float64 *v = pv;
+    uint64_t u;
+    u = float64_val(*v);
+    qemu_put_be64s(f, &u);
+}
+
+const VMStateInfo vmstate_info_float64 = {
+    .name = "float64",
+    .get  = get_float64,
+    .put  = put_float64,
+};
+
 /* timers  */

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

 extern const VMStateInfo vmstate_info_float32;
+extern const VMStateInfo vmstate_info_float64;

 extern const VMStateInfo vmstate_info_timer;
 extern const VMStateInfo vmstate_info_buffer;
@@ -564,6 +565,9 @@  extern const VMStateDescription vmstate_cpu;
 #define VMSTATE_FLOAT32_ARRAY(_f, _s, _n)                             \
     VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float32, float32)

+#define VMSTATE_FLOAT64_ARRAY(_f, _s, _n)                             \
+    VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float64, float64)
+
 #define VMSTATE_BUFFER_V(_f, _s, _v)                                  \
     VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))