From: Ian Jackson Date: Wed, 11 Apr 2012 13:14:18 +0000 (+0100) Subject: libxl: provide STATE_AO_GC X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=37136d68c45604a7d8e51513cbd00c2a99321716;p=xen.git libxl: provide STATE_AO_GC 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 Committed-by: Ian Jackson --- diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index a8372bbc3a..a4b933beaa 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_ao) \ + 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. */