Date: Wed, 27 Oct 2021 10:11:05 +0200 From: Mateusz Guzik <mjguzik@gmail.com> To: Gleb Smirnoff <glebius@freebsd.org> Cc: kib@freebsd.org, jhb@freebsd.org, jeff@freebsd.org, arch@freebsd.org Subject: Re: rwlock(9) and mutex(9) definitions Message-ID: <CAGudoHH701ZOhPC=PJDoN2-gEQ1U2sVXEBmz00b2fki0bTVc9w@mail.gmail.com> In-Reply-To: <YXiw1afVlQyEhQyc@FreeBSD.org> References: <YXiw1afVlQyEhQyc@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 10/27/21, Gleb Smirnoff <glebius@freebsd.org> wrote: > Hi, > > [To: list constructed with help of git blame] > > despite manual pages describe locking functions as voids in > reality some of them (not all) are preprocessor defines wrapped > in "do {} while (0)". > > Such wraps don't really behave as a true void. For example you > can not tail call them: > > void > smartass_lock(lock, clue) > { > if (clue) > return (rw_rlock(lock)); > else > return (rw_wlock(lock)); > } > > This will fail on rw_wlock, but not on rw_rlock. However, if you > have WITNESS it will compile correctly :) > > So, we need either make these function "static inline void" in > mtx.h and rwlock.h, or wrap them in __extension__ ({ }). Btw, the > latter is already done for mtx_trylock_spin() by kib in 90b581f2cc327. > Of course for try-lock functions inability of tail call is a bigger > issue then for voids. However, voids should be fixed as well, I believe. > > Your call? "static inline" or "__extension__ ({ })"? > I don't have an opinion which way to go here, but will have to note that the inlines should probably get retired in favor of asm funcs, but it wont happen anytime soon. -- Mateusz Guzik <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGudoHH701ZOhPC=PJDoN2-gEQ1U2sVXEBmz00b2fki0bTVc9w>