From patchwork Mon Oct 19 18:43:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 36408 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 716CCB7B6F for ; Tue, 20 Oct 2009 06:16:29 +1100 (EST) Received: from localhost ([127.0.0.1]:39568 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MzxiU-0002eb-Hb for incoming@patchwork.ozlabs.org; Mon, 19 Oct 2009 15:16:26 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MzxDI-0006G7-EW for qemu-devel@nongnu.org; Mon, 19 Oct 2009 14:44:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MzxD9-0006AL-V6 for qemu-devel@nongnu.org; Mon, 19 Oct 2009 14:44:07 -0400 Received: from [199.232.76.173] (port=49050 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MzxD8-00069m-2y for qemu-devel@nongnu.org; Mon, 19 Oct 2009 14:44:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47610) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MzxD6-0006LA-SA for qemu-devel@nongnu.org; Mon, 19 Oct 2009 14:44:01 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9JIi0sf031899 for ; Mon, 19 Oct 2009 14:44:00 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9JIhcC9012656; Mon, 19 Oct 2009 14:43:59 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 19 Oct 2009 20:43:01 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 16/25] vmstate: Introduce the concept of sub-arrays X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org VMSTATE_SUB_ARRAY(..., start, num, ...) saves the num elems starting at position start of the array Signed-off-by: Juan Quintela --- hw/hw.h | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index d3bf0a7..b98f0c9 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -352,6 +352,9 @@ extern const VMStateInfo vmstate_info_unused_buffer; (offsetof(_state, _field) + \ type_check_array(_type, typeof_field(_state, _field), _num)) +#define vmstate_offset_sub_array(_state, _field, _type, _start) \ + (offsetof(_state, _field[_start])) + #define vmstate_offset_buffer(_state, _field) \ vmstate_offset_array(_state, _field, uint8_t, \ sizeof(typeof_field(_state, _field))) @@ -395,6 +398,16 @@ extern const VMStateInfo vmstate_info_unused_buffer; .offset = vmstate_offset_array(_state, _field, _type, _num),\ } +#define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num = (_num), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_ARRAY, \ + .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \ +} + #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\ .name = (stringify(_field)), \ .version_id = (_version), \ @@ -614,6 +627,12 @@ extern const VMStateDescription vmstate_i2c_slave; #define VMSTATE_INT32_ARRAY(_f, _s, _n) \ VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0) +#define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \ + VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t) + +#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ + VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) + #define VMSTATE_BUFFER_V(_f, _s, _v) \ VMSTATE_STATIC_BUFFER(_f, _s, _v, 0, sizeof(typeof_field(_s, _f)))