cvs commit: src/sys/kern kern_rwlock.c

Scott Long scottl at samsco.org
Mon Jan 30 10:36:51 PST 2006


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



More information about the cvs-src mailing list