Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Oct 2021 08:32:51 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Gleb Smirnoff <glebius@freebsd.org>
Cc:        mjg@freebsd.org, jhb@freebsd.org, jeff@freebsd.org, arch@freebsd.org
Subject:   Re: rwlock(9) and mutex(9) definitions
Message-ID:  <YXjkg8UpjpjCRYGd@kib.kiev.ua>
In-Reply-To: <YXjimhWUYCwaYoWi@FreeBSD.org>
References:  <YXiw1afVlQyEhQyc@FreeBSD.org> <YXizhiRnByvyisXe@kib.kiev.ua> <YXi0PM6babQKFulv@kib.kiev.ua> <YXjS16MQZiKm4E/r@FreeBSD.org> <YXjYCj2zh0cjL/%2Bq@kib.kiev.ua> <YXjadvxmJRoXwWUj@FreeBSD.org> <YXjfcclPCfbhYYCQ@kib.kiev.ua> <YXjimhWUYCwaYoWi@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

On Tue, Oct 26, 2021 at 10:24:42PM -0700, Gleb Smirnoff wrote:
> On Wed, Oct 27, 2021 at 08:11:13AM +0300, Konstantin Belousov wrote:
> K> > Okay, let's put return aside. This would compile with true
> K> > functions (e.g. WITNESS), otherwise not:
> K> > 
> K> > void
> K> > something(bool clue)
> K> > {
> K> > 	clue ? rw_rlock(lock) : rw_wlock(lock);
> K> > }
> K> > 
> K> > And this is correct code per 6.5.15.
> K> 
> K> So why cannot you write it as 
> K> ...
> K> 	if (clue)
> K> 		rw_rlock(lock);
> K> 	else
> K> 		rw_wlock(lock);
> 
> Of course I can. But manual page rwlock(9) says I can treat them as functions, thus
> use in conditional operator.
> 
> My point is that the fact that I can work around this, doesn't justify the
> problem not being fixed.
> 
> What is a downside of wrapping them in "__extension__ ({ })"?
I do not object against __extension__, I was interested in real situation
where you cannot work-around it.  I am fine with making *lock() correct
expressions.


help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YXjkg8UpjpjCRYGd>