From patchwork Tue Jan 5 20:34:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 42224 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 85C7EB6EEE for ; Wed, 6 Jan 2010 10:38:45 +1100 (EST) Received: from localhost ([127.0.0.1]:35421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSIyj-0002zD-59 for incoming@patchwork.ozlabs.org; Tue, 05 Jan 2010 18:38:21 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSG7V-000579-VK for qemu-devel@nongnu.org; Tue, 05 Jan 2010 15:35:14 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSG7R-00050S-8n for qemu-devel@nongnu.org; Tue, 05 Jan 2010 15:35:13 -0500 Received: from [199.232.76.173] (port=50765 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSG7Q-000507-U8 for qemu-devel@nongnu.org; Tue, 05 Jan 2010 15:35:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18719) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NSG7Q-0003J4-Bo for qemu-devel@nongnu.org; Tue, 05 Jan 2010 15:35:08 -0500 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 o05KZ7Bu028087 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Jan 2010 15:35:07 -0500 Received: from localhost (vpn-10-105.rdu.redhat.com [10.11.10.105]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o05KZ5ZL010603; Tue, 5 Jan 2010 15:35:06 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Tue, 5 Jan 2010 18:34:54 -0200 Message-Id: <1262723698-23658-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1262723698-23658-1-git-send-email-lcapitulino@redhat.com> References: <1262723698-23658-1-git-send-email-lcapitulino@redhat.com> 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. Cc: aliguori@us.ibm.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 1/5] QList: Introduce QLIST_FOREACH_ENTRY() 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 Iterate over QList entries, it's needed to call qlist_entry_obj() to retrieve the stored QObject. I'm not sure if it's ok to have this, because it's not as easy as qlist_iter() and the QListEntry data type is now exposed to the users, which means we have one more struct to be maintained when we have libqmp. Adding anyway, as it's more compact and people are asking for it. Signed-off-by: Luiz Capitulino --- qlist.h | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/qlist.h b/qlist.h index afdc446..a3261e1 100644 --- a/qlist.h +++ b/qlist.h @@ -29,6 +29,16 @@ typedef struct QList { #define qlist_append(qlist, obj) \ qlist_append_obj(qlist, QOBJECT(obj)) +#define QLIST_FOREACH_ENTRY(qlist, var) \ + for ((var) = ((qlist)->head.tqh_first); \ + (var); \ + (var) = ((var)->next.tqe_next)) + +static inline QObject *qlist_entry_obj(const QListEntry *entry) +{ + return entry->value; +} + QList *qlist_new(void); QList *qlist_copy(QList *src); void qlist_append_obj(QList *qlist, QObject *obj);