Re: rwlock(9) and mutex(9) definitions
- Reply: Konstantin Belousov : "Re: rwlock(9) and mutex(9) definitions"
- In reply to: Konstantin Belousov : "Re: rwlock(9) and mutex(9) definitions"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 27 Oct 2021 04:17:27 UTC
On Wed, Oct 27, 2021 at 05:06:52AM +0300, Konstantin Belousov wrote: K> > counters. K> K> That said, you seems to use wrong syntax for your example. Might be, it K> is enough to fix that, and not change the definition? K> K> void K> something(bool clue) K> { K> if (clue) { K> rw_rlock(lock); K> else K> rw_wlock(lock); K> } K> Both rw_rlock and rw_wlock are in tail context. You cannot _return_ void. You actually can return void to hint compiler for a tail call optimization. It is not a wrong syntax. Other code that is working with true void functions (e.g. with WITNESS) and doesn't work with "do {} while" is: void something(bool clue) { return (clue ? rw_rlock(lock) : rw_wlock(lock)); } This is explicitly allowed in 6.5.15 of the C11 standard. Of course all this code can be written in some other way, so constraint of KPI not being true functions can be worked around, but I believe better it be fixed. -- Gleb Smirnoff