Date: Tue, 28 Oct 2014 11:54:54 -0400 From: John Baldwin <jhb@freebsd.org> To: Mateusz Guzik <mjguzik@gmail.com> Cc: John-Mark Gurney <jmg@funkthat.com>, freebsd-arch@freebsd.org Subject: Re: refcount_release_take_##lock Message-ID: <201410281154.54581.jhb@freebsd.org> In-Reply-To: <20141027192721.GA28049@dft-labs.eu> References: <20141025184448.GA19066@dft-labs.eu> <2629048.tOq3sNXcCP@ralph.baldwin.cx> <20141027192721.GA28049@dft-labs.eu>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410281154.54581.jhb>