From patchwork Tue Oct 25 14:00:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 121694 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 14D0CB6F8B for ; Wed, 26 Oct 2011 01:03:58 +1100 (EST) Received: from localhost ([::1]:55767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIhbc-0002OS-S4 for incoming@patchwork.ozlabs.org; Tue, 25 Oct 2011 10:03:52 -0400 Received: from eggs.gnu.org ([140.186.70.92]:39778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIhaX-00015K-AZ for qemu-devel@nongnu.org; Tue, 25 Oct 2011 10:02:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RIhaQ-0001xz-Ga for qemu-devel@nongnu.org; Tue, 25 Oct 2011 10:02:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIhaQ-0001xh-7z for qemu-devel@nongnu.org; Tue, 25 Oct 2011 10:02:38 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9PE2bXE027355 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 25 Oct 2011 10:02:37 -0400 Received: from neno.neno. (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9PE25Zd028141; Tue, 25 Oct 2011 10:02:35 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 25 Oct 2011 16:00:45 +0200 Message-Id: <4d1e503e7a8926630d14dc8ef45b609aa64c60ca.1319550280.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 11/25] vmstate: introduce float64 arrays X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Juan Quintela --- hw/hw.h | 4 ++++ savevm.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 0 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index 014cdc1..3044cec 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -355,6 +355,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_ptimer; @@ -880,6 +881,9 @@ extern const VMStateDescription vmstate_hid_ptr_device; #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))) diff --git a/savevm.c b/savevm.c index cd0178c..2e191ad 100644 --- a/savevm.c +++ b/savevm.c @@ -1057,6 +1057,36 @@ const VMStateInfo vmstate_info_float32 = { .put = put_float32, }; +/* 64 bit float */ + +typedef union { + float64 d; + uint64_t l; +} VMStateFloat64; + +static int get_float64(QEMUFile *f, void *pv, size_t size) +{ + float64 *v = pv; + VMStateFloat64 u; + qemu_get_be64s(f, &u.l); + *v = u.d; + return 0; +} + +static void put_float64(QEMUFile *f, void *pv, size_t size) +{ + float64 *v = pv; + VMStateFloat64 u; + u.d = *v; + qemu_put_be64s(f, &u.l); +} + +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)