From: Ian Campbell Subject: Re: [PATCH 19/31] libxl: provide STATE_AO_GC Date: Wed, 11 Apr 2012 10:17:16 +0100 Message-ID: <1334135836.5394.87.camel@zakaz.uk.xensource.com> References: <1334084885-14474-1-git-send-email-ian.jackson@eu.citrix.com> <1334084885-14474-20-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1334084885-14474-20-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Tue, 2012-04-10 at 20:07 +0100, Ian Jackson wrote: > Provide a convenience macro for use in ao callback functions, and > document that it should be used. > > Signed-off-by: Ian Jackson Acked-by: Ian Campbell > --- > tools/libxl/libxl_internal.h | 11 ++++++++--- > 1 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h > index a8372bb..76875bb 100644 > --- a/tools/libxl/libxl_internal.h > +++ b/tools/libxl/libxl_internal.h > @@ -1266,9 +1266,10 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); > * - Note that during callback functions, two gcs are available: > * - The one in egc, whose lifetime is only this callback > * - The one in ao, whose lifetime is the asynchronous operation > - * Usually callback function should use CONTAINER_OF > - * to obtain its own structure, containing a pointer to the ao, > - * and then use the gc from that ao. > + * Usually callback function should use CONTAINER_OF to obtain its > + * own state structure, containing a pointer to the ao. It should > + * then obtain the ao and use the ao's gc; this is most easily done > + * using the convenience macro STATE_AO_GC. > */ > > #define AO_CREATE(ctx, domid, ao_how) \ > @@ -1298,6 +1299,10 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); > #define AO_GC \ > libxl__gc *const gc = &ao->gc > > +#define STATE_AO_GC(op) \ > + libxl__ao *const ao = op->ao; \ > + AO_GC > + > > /* All of these MUST be called with the ctx locked. > * libxl__ao_inprogress MUST be called with the ctx locked exactly once. */