From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SelF5-0007Of-Al for qemu-devel@nongnu.org; Wed, 13 Jun 2012 06:56:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SelF0-0001f9-EM for qemu-devel@nongnu.org; Wed, 13 Jun 2012 06:56:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SelF0-0001f0-68 for qemu-devel@nongnu.org; Wed, 13 Jun 2012 06:55:58 -0400 Message-ID: <4FD871B1.4000104@redhat.com> Date: Wed, 13 Jun 2012 13:55:45 +0300 From: Avi Kivity MIME-Version: 1.0 References: <4FD86E40.1000100@redhat.com> In-Reply-To: <4FD86E40.1000100@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC v0 6/8] xilinx dont cast to interface types with links List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, qemu-devel@nongnu.org, "Peter A. G. Crosthwaite" , paul@codesourcery.com, edgar.iglesias@gmail.com, afaerber@suse.de, john.williams@petalogix.com On 06/13/2012 01:41 PM, Paolo Bonzini wrote: > > However, something that _is_ bad indeed happens; we try to ref/unref an interface > object. This patch fixes it while keeping things efficient (and in fact fixes one > TODO). Can add a link to an image on http://wiki.qemu.org/Testing and/or test it? > > Anthony, is this above your disgust level? > > Paolo > > > ------------------------ 8< ----------------------- > > diff --git a/qom/object.c b/qom/object.c > index c3a7a47..bd60838 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -63,7 +63,7 @@ struct TypeImpl > InterfaceImpl interfaces[MAX_INTERFACES]; > }; > > -#define INTERFACE(obj) INTERFACE_CHECK(obj, TYPE_INTERFACE) > +#define INTERFACE(obj) ((Interface *)(obj)) > > static Type type_interface; > > @@ -239,13 +239,21 @@ static void type_initialize(TypeImpl *ti) > } > } > > +#define INTERFACE_MAGIC ((GSList *) (intptr_t)0xBAD0BAD) > + > +static inline bool object_is_interface(Object *obj) { > + return obj->interfaces == INTERFACE_MAGIC; > +} Why play games? static GSList interface_magic; static inline bool object_is_interface(Object *obj) { return obj->interfaces == &interface_magic; } though I think we can spare a bool (and developer's sanity) in Object. -- error compiling committee.c: too many arguments to function