From patchwork Tue Jun 18 09:45:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 252205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D09DC2C009F for ; Tue, 18 Jun 2013 19:52:13 +1000 (EST) Received: from localhost ([::1]:55077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UosaC-0007mh-0Q for incoming@patchwork.ozlabs.org; Tue, 18 Jun 2013 05:52:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UosZn-0007hl-VP for qemu-devel@nongnu.org; Tue, 18 Jun 2013 05:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UosZk-00084t-Uh for qemu-devel@nongnu.org; Tue, 18 Jun 2013 05:51:47 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:44737) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UosZk-00083H-O9 for qemu-devel@nongnu.org; Tue, 18 Jun 2013 05:51:44 -0400 Received: by mail-pd0-f180.google.com with SMTP id 10so3732489pdi.39 for ; Tue, 18 Jun 2013 02:51:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=EYRqVIG/zLC+FshTent7d3iPe7rPI0dfukaAfF36o2c=; b=iBKGWjAi2jUbnnl0jptO8Sn/+Sn436iJzG1P7QZ/VE3u2WUmNfkyvYjYclQ5pJIUDr QXTLjtdkK2der2BDB9GVGnasHeTY120oacbbfbKufm1uZgUvfFoCJ0kG9+CTIvNa4xyT ZZ3Vg5Pb7FSEToe02hd9FJToOzE8EO+bUrbWRrLWbmFFygpxumThaeRqeB48abOjFj8P bsgbQxLKz15pddncrjCSt/CqDMuSoKklsq/YziU12FXJi8Z3JottjPLcChQ//OtdCpqF Ighpzm3mReINAGv6vvbvv+7/W1RY5HgULNn7qmzvwNzLM/TC1sFBatNsK8QS03nsmFow YTtQ== X-Received: by 10.66.26.179 with SMTP id m19mr1492034pag.4.1371549103844; Tue, 18 Jun 2013 02:51:43 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id xz1sm18904376pab.5.2013.06.18.02.51.40 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Tue, 18 Jun 2013 02:51:42 -0700 (PDT) From: peter.crosthwaite@xilinx.com To: qemu-devel@nongnu.org Date: Tue, 18 Jun 2013 19:45:36 +1000 Message-Id: <7ddd1c80f6996331c7ff158c858d456cf62170cc.1371548267.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.8.3.rc1.44.gb387c77.dirty In-Reply-To: References: X-Gm-Message-State: ALoCoQmJCuW648NZtM3zZEunceUmXfOuarrcpF1fsYVOpRPXB+MfbdnLeJZNQkWSd5FKDd8Ztgjk X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.180 Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, mst@redhat.com, pbonzini@redhat.com, edgar.iglesias@gmail.com, afaerber@suse.de Subject: [Qemu-devel] [RFC PATCH v1 3/7] qdev-core: Introduce DEVICE super class cast macros 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 From: Peter Crosthwaite Add macros DEVICE_SUPER_CLASS and DEVICE_GET_SUPER_CLASS. These are the similar to their respective non SUPER versions, except instead of returning the class object for the concrete class, they return their parent classes implementation (usually some form of abstract class). Signed-off-by: Peter Crosthwaite --- include/hw/qdev-core.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 7fbffcb..96647c4 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -16,6 +16,10 @@ enum { #define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE) #define DEVICE_CLASS(klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE) #define DEVICE_GET_CLASS(obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE) +#define DEVICE_SUPER_CLASS(klass, typename) \ + DEVICE_CLASS(object_class_get_super(OBJECT_CLASS(klass), typename)) +#define DEVICE_GET_SUPER_CLASS(obj, typename) \ + DEVICE_SUPER_CLASS(DEVICE_GET_CLASS(obj), typename) typedef int (*qdev_initfn)(DeviceState *dev); typedef int (*qdev_event)(DeviceState *dev);