From owner-freebsd-arch@FreeBSD.ORG Tue Oct 28 16:21:10 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2A3E73C8 for ; Tue, 28 Oct 2014 16:21:10 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0402F210 for ; Tue, 28 Oct 2014 16:21:10 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id DA997B995; Tue, 28 Oct 2014 12:21:08 -0400 (EDT) From: John Baldwin To: Mateusz Guzik Subject: Re: refcount_release_take_##lock Date: Tue, 28 Oct 2014 11:54:54 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20140415; KDE/4.5.5; amd64; ; ) References: <20141025184448.GA19066@dft-labs.eu> <2629048.tOq3sNXcCP@ralph.baldwin.cx> <20141027192721.GA28049@dft-labs.eu> In-Reply-To: <20141027192721.GA28049@dft-labs.eu> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201410281154.54581.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 28 Oct 2014 12:21:08 -0400 (EDT) Cc: John-Mark Gurney , freebsd-arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Oct 2014 16:21:10 -0000 On Monday, October 27, 2014 3:27:21 pm Mateusz Guzik wrote: > On Mon, Oct 27, 2014 at 11:27:45AM -0400, John Baldwin wrote: > > Please keep the refcount_*() prefix so it matches the rest of the API. I > > would just declare the functions directly in refcount.h rather than requiring > > a macro to be invoked in each C file. We can also just implement the needed > > lock types for now instead of all of them. > > > > You could maybe replace 'take' with 'lock', but either name is fine. > > > > > We need sx and rwlocks (and temporarily mutexes, but that is going away > in few days). Ok. > I ran into the following issue: opensolaris code has its own rwlock.h, > and their refcount.h eventually includes ours refcount.h (and it has to > since e.g. our file.h requires it). > > I don't know any good solution. Ugh. > We could add locking funcs to a separate header (refcount_lock.h?) or use the > following hack: > > +#ifdef _SYS_RWLOCK_H_ > +REFCOUNT_RELEASE_LOCK_DEFINE(rwlock, struct rwlock, rw_wlock, rw_wunlock); > +#else The problem here is that typically refcount.h would be included before rwlock.h (style(9) sorts headers alphabetically). Given that you want to inline this anyway, you could perhaps implement it as a macro instead of an inline function? That would result in it only being parsed when used which would side-step this. It's not really ideal but might be less ugly than the other options. Something like: #define _refcount_release_lock(count, lock, LOCK_OP, UNLOCK_OP) \ ... #define refcount_release_lock_mtx(count, lock) \ _refcount_release_lock((count), (lock), mtx_lock, mtx_unlock) -- John Baldwin