From patchwork Wed Oct 26 20:16:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 121983 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 7FD561007D2 for ; Thu, 27 Oct 2011 07:24:51 +1100 (EST) Received: from localhost ([::1]:58489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJA1j-0003gv-P5 for incoming@patchwork.ozlabs.org; Wed, 26 Oct 2011 16:24:43 -0400 Received: from eggs.gnu.org ([140.186.70.92]:54137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJA1b-0003gf-AG for qemu-devel@nongnu.org; Wed, 26 Oct 2011 16:24:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJA1a-0000ym-1M for qemu-devel@nongnu.org; Wed, 26 Oct 2011 16:24:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11730) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJA1Z-0000ye-My for qemu-devel@nongnu.org; Wed, 26 Oct 2011 16:24:33 -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 p9QKOItL006140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 26 Oct 2011 16:24:18 -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 p9QKHulY018327; Wed, 26 Oct 2011 16:23:43 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 26 Oct 2011 22:16:24 +0200 Message-Id: <783ca638dcf9eadd75cbb2e81059a019b21c8389.1319658750.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: Huacai Chen , Peter Maydell , Alexander Graf , Blue Swirl , Max Filippov , Michael Walle , Paul Brook , "Edgar E. Iglesias" , Aurelien Jarno , Richard Henderson Subject: [Qemu-devel] [PATCH 10/28] vmstate: introduce float32 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 | 5 +++++ savevm.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index 0f0200a..014cdc1 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -354,6 +354,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_ptimer; extern const VMStateInfo vmstate_info_buffer; @@ -875,6 +877,9 @@ extern const VMStateDescription vmstate_hid_ptr_device; #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))) diff --git a/savevm.c b/savevm.c index 557eba4..cd0178c 100644 --- a/savevm.c +++ b/savevm.c @@ -1027,6 +1027,36 @@ const VMStateInfo vmstate_info_uint16_equal = { .put = put_uint16, }; +/* 32 bit float */ + +typedef union { + float32 f; + uint32_t i; +} VMStateFloat32; + +static int get_float32(QEMUFile *f, void *pv, size_t size) +{ + float32 *v = pv; + VMStateFloat32 u; + qemu_get_be32s(f, &u.i); + *v = u.f; + return 0; +} + +static void put_float32(QEMUFile *f, void *pv, size_t size) +{ + float32 *v = pv; + VMStateFloat32 u; + u.f = *v; + qemu_put_be32s(f, &u.i); +} + +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)