From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40174) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6uYY-00034x-QR for qemu-devel@nongnu.org; Tue, 06 Aug 2013 23:37:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V6uYL-0005cM-NF for qemu-devel@nongnu.org; Tue, 06 Aug 2013 23:37:02 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:56975) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6uYL-0005bt-Gh for qemu-devel@nongnu.org; Tue, 06 Aug 2013 23:36:49 -0400 Received: by mail-pd0-f170.google.com with SMTP id x10so937823pdj.1 for ; Tue, 06 Aug 2013 20:36:48 -0700 (PDT) Message-ID: <5201C0CA.2070808@ozlabs.ru> Date: Wed, 07 Aug 2013 13:36:42 +1000 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <1375323463-32747-1-git-send-email-afaerber@suse.de> <1375323463-32747-2-git-send-email-afaerber@suse.de> <52008FAE.8060709@ozlabs.ru> <5200B4C1.9010008@suse.de> In-Reply-To: <5200B4C1.9010008@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH for-next v2 01/22] object: Add OBJECT_GET_PARENT_CLASS() macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Cc: Peter Crosthwaite , qemu-devel@nongnu.org, Anthony Liguori On 08/06/2013 06:33 PM, Andreas Färber wrote: > Am 06.08.2013 07:54, schrieb Alexey Kardashevskiy: >> On 08/01/2013 12:17 PM, Andreas Färber wrote: >>> The object argument is currently unused and may be used to optimize the >>> class lookup when needed. >>> >>> Inspired-by: Peter Crosthwaite >>> Signed-off-by: Andreas Färber >>> --- >>> include/qom/object.h | 10 ++++++++++ >>> 1 file changed, 10 insertions(+) >>> >>> diff --git a/include/qom/object.h b/include/qom/object.h >>> index 23fc048..a8e71dc 100644 >>> --- a/include/qom/object.h >>> +++ b/include/qom/object.h >>> @@ -511,6 +511,16 @@ struct TypeInfo >>> OBJECT_CLASS_CHECK(class, object_get_class(OBJECT(obj)), name) >>> >>> /** >>> + * OBJECT_GET_PARENT_CLASS: >>> + * @obj: The object to obtain the parent class for. >>> + * @name: The QOM typename of @obj. >>> + * >>> + * Returns the parent class for a given object of a specific class. >>> + */ >>> +#define OBJECT_GET_PARENT_CLASS(obj, name) \ >>> + object_class_get_parent(object_class_by_name(name)) >>> + >>> +/** >>> * InterfaceInfo: >>> * @type: The name of the interface. >>> * >>> >> >> Has anyone ever tried to use this macro? > > Since you're asking me, obviously later in this virtio series it's used > and in the IndustryPack series as well. > > I'm not aware of anyone else having used it yet - I'm still waiting for > review feedback from Peter Cr. and/or Anthony (or you!) before I put it > on qom-next. Still do not understand what "obj" is doing here. This what I would suggest: #define OBJECT_GET_PARENT_CLASS(obj, name) \ object_class_get_parent(OBJECT_GET_CLASS(ObjectClass, (obj), (name))) @name here is just to make sure we are at the right level of the class hierarchy. And use it like this: static void xics_kvm_cpu_setup(XICSState *icp, PowerPCCPU *cpu) { XICSStateClass *xsc = XICS_COMMON_CLASS( OBJECT_GET_PARENT_CLASS(OBJECT(icp), TYPE_KVM_XICS)); ... Here both source and destination classes are checked, everyone must be happy :) -- Alexey