Date: Mon, 30 Jan 2006 11:36:53 -0700 From: Scott Long <scottl@samsco.org> To: Peter Jeremy <peterjeremy@optushome.com.au> Cc: cvs-src@freebsd.org, src-committers@freebsd.org, Scott Long <scottl@freebsd.org>, cvs-all@freebsd.org Subject: Re: cvs commit: src/sys/kern kern_rwlock.c Message-ID: <43DE5CC5.7020406@samsco.org> In-Reply-To: <20060130092205.GB702@turion.vk2pj.dyndns.org> References: <200601292048.k0TKmPSM000635@repoman.freebsd.org> <20060130092205.GB702@turion.vk2pj.dyndns.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Peter Jeremy wrote: > On Sun, 2006-Jan-29 20:48:25 +0000, Scott Long wrote: > >> gcc can't >> figure out the order of operations at line 519, and neither can I, but this >> is my best guess. Also correct a number of typos and syntax errors. >> >> Revision Changes Path >> 1.3 +4 -4 src/sys/kern/kern_rwlock.c > > > - if (rw->rw_lock == RW_UNLOCKED || > - !(rw->rw_lock & RW_LOCK_READ) && (what == RW_RLOCKED || > - RW_OWNER(rw) != (uintptr_t)curthread)) > is perfectly well defined in C. Simplifying names/macros/casts: > if (a == b || !(a & c) && (d == e || f != g)) > (partial) precedence rules from operator(7): > () [] -> . left to right > ! ~ ++ -- - (type) * & sizeof right to left > == != left to right > & left to right > && left to right > || left to right > parenthesising to avoid the bottom 4 precedence rules: > if ((a == b) || (!(a & c) && ((d == e) || (f != g)))) > Note that this is different to your patch: > + if ((rw->rw_lock == RW_UNLOCKED || > + !(rw->rw_lock & RW_LOCK_READ)) && (what == RA_RLOCKED || > + (rw_owner(rw) != curthread))) > which turns into: > if ((a == b || !(a & c)) && (d == e || (f != g))) > > If it's just a matter of silencing gcc, I believe that what is wanted > is (with grouping wraps and indents): > * if (rw->rw_lock == RW_UNLOCKED || > * (!(rw->rw_lock & RW_LOCK_READ) && > * (what == RW_RLOCKED || rw_owner(rw) != curthread))) > > Note that the behaviour in 1.2 and 1.3 is different if > (rw->rw_lock == RW_UNLOCKED) > If that's the right logic then please commit it. I was just trying to make the tree compile so that snapshots could be generated. Scott
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?43DE5CC5.7020406>