From owner-cvs-all@FreeBSD.ORG Mon Jan 30 09:22:10 2006 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BAE4A16A420; Mon, 30 Jan 2006 09:22:10 +0000 (GMT) (envelope-from peterjeremy@optushome.com.au) Received: from mail08.syd.optusnet.com.au (mail08.syd.optusnet.com.au [211.29.132.189]) by mx1.FreeBSD.org (Postfix) with ESMTP id 127D043D48; Mon, 30 Jan 2006 09:22:09 +0000 (GMT) (envelope-from peterjeremy@optushome.com.au) Received: from turion.vk2pj.dyndns.org (c220-239-19-236.belrs4.nsw.optusnet.com.au [220.239.19.236]) by mail08.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id k0U9M6g0008292 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Mon, 30 Jan 2006 20:22:07 +1100 Received: from turion.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by turion.vk2pj.dyndns.org (8.13.4/8.13.4) with ESMTP id k0U9M50j017653; Mon, 30 Jan 2006 20:22:05 +1100 (EST) (envelope-from peter@turion.vk2pj.dyndns.org) Received: (from peter@localhost) by turion.vk2pj.dyndns.org (8.13.4/8.13.4/Submit) id k0U9M5xT017652; Mon, 30 Jan 2006 20:22:05 +1100 (EST) (envelope-from peter) Date: Mon, 30 Jan 2006 20:22:05 +1100 From: Peter Jeremy To: Scott Long Message-ID: <20060130092205.GB702@turion.vk2pj.dyndns.org> References: <200601292048.k0TKmPSM000635@repoman.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200601292048.k0TKmPSM000635@repoman.freebsd.org> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.11 Cc: cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/sys/kern kern_rwlock.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jan 2006 09:22:10 -0000 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) -- Peter Jeremy