From: Ian Campbell Subject: Re: [PATCH 15/15] libxl: New event generation API Date: Fri, 9 Dec 2011 20:41:33 +0000 Message-ID: <1323463293.20936.11.camel@dagon.hellion.org.uk> References: <1323108621-22654-1-git-send-email-ian.jackson@eu.citrix.com> <1323108621-22654-16-git-send-email-ian.jackson@eu.citrix.com> <20194.22539.574524.956955@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20194.22539.574524.956955@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: "xen-devel@lists.xensource.com" , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Fri, 2011-12-09 at 18:48 +0000, Ian Jackson wrote: > Now Linux and Xen have a tendency, when they need a name for an > unlocked version of foo, to use the name _foo. Obviously this is no > good in a userspace program and anyway I think it is a completely > ridiculous convention. We need something much clearer. > > foo_internal is a possibility but that merely suggests that the > GC_INIT has been done, and doesn't make it 100% clear that the caller > must already have done CTX_LOCK. Some places also use foo_raw, not sure how much of an improvement that is though. Maybe a simple comment is sufficient: /* Must be called with $LOCK held */ int libxl_event_check(libxl_ctx *ctx, libxl_event **event_r, ... It's a shame there is no pthread_mutex_is_locked or an assert containing it would be nicely self documenting. I suppose CTX_LOCK could set a flag in the context which we could assert on, but, ick. Stepping back a bit: Since the lock is recursive do we really need the unlocked version? All the callers of event_check_unlocked (apart from libxl_event_check) could call libxl_event_check instead. Ian.