[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: Provide more formal libxl__ctx_lock and _unlock
# HG changeset patch # User Ian Jackson <ian.jackson@xxxxxxxxxxxxx> # Date 1326473667 0 # Node ID cc969d75176039ea14c373f36e6f214e4b23e73b # Parent 2231bc032192d9fdada4a6415f8814dff3bdd14d libxl: Provide more formal libxl__ctx_lock and _unlock Previously the only official interface for the ctx lock was the CTX_LOCK and CTX_UNLOCK convenience macros, which assume and use "ctx" from the surrounding scope. Instead, provide libxl__ctx_lock and _unlock functions which can be used by these convenience macros, and other callers who have nonstandard requirements. Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Committed-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> --- diff -r 2231bc032192 -r cc969d751760 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Fri Jan 13 16:54:19 2012 +0000 +++ b/tools/libxl/libxl_internal.h Fri Jan 13 16:54:27 2012 +0000 @@ -115,7 +115,8 @@ struct xs_handle *xsh; pthread_mutex_t lock; /* protects data structures hanging off the ctx */ - /* Always use CTX_LOCK and CTX_UNLOCK to manipulate this. + /* Always use libxl__ctx_lock and _unlock (or the convenience + * macors CTX_LOCK and CTX_UNLOCK) to manipulate this. * * You may acquire this mutex recursively if it is convenient to * do so. You may not acquire this lock at the same time as any @@ -753,16 +754,18 @@ /* Locking functions. See comment for "lock" member of libxl__ctx. */ -#define CTX_LOCK do { \ - int mutex_r = pthread_mutex_lock(&CTX->lock); \ - assert(!mutex_r); \ - } while(0) +static inline void libxl__ctx_lock(libxl_ctx *ctx) { + int r = pthread_mutex_lock(&ctx->lock); + assert(!r); +} -#define CTX_UNLOCK do { \ - int mutex_r = pthread_mutex_unlock(&CTX->lock); \ - assert(!mutex_r); \ - } while(0) - +static inline void libxl__ctx_unlock(libxl_ctx *ctx) { + int r = pthread_mutex_unlock(&ctx->lock); + assert(!r); +} + +#define CTX_LOCK (libxl__ctx_lock(CTX)) +#define CTX_UNLOCK (libxl__ctx_unlock(CTX)) /* _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |