qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC v0 6/8] xilinx dont cast to interface types with l


From: Avi Kivity
Subject: Re: [Qemu-devel] [RFC v0 6/8] xilinx dont cast to interface types with links
Date: Wed, 13 Jun 2012 13:55:45 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]