From owner-freebsd-hackers@FreeBSD.ORG Mon Jun 13 18:31:11 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6388516A41C for ; Mon, 13 Jun 2005 18:31:11 +0000 (GMT) (envelope-from joerg@britannica.bec.de) Received: from hydra.bec.de (www.ostsee-abc.de [62.206.222.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id D370C43D1D for ; Mon, 13 Jun 2005 18:31:10 +0000 (GMT) (envelope-from joerg@britannica.bec.de) Received: from britannica.bec.de (unknown [139.30.252.67]) by hydra.bec.de (Postfix) with ESMTP id A3A2B35707 for ; Mon, 13 Jun 2005 20:31:09 +0200 (CEST) Received: by britannica.bec.de (Postfix, from userid 1001) id B984B5428; Mon, 13 Jun 2005 18:27:43 +0200 (CEST) Date: Mon, 13 Jun 2005 18:27:43 +0200 From: Joerg Sonnenberger To: freebsd-hackers@freebsd.org Message-ID: <20050613162743.GA769@britannica.bec.de> Mail-Followup-To: freebsd-hackers@freebsd.org References: <200506131412.38967.hselasky@c2i.net> <20050613124427.GD1343@britannica.bec.de> <200506131758.25671.hselasky@c2i.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200506131758.25671.hselasky@c2i.net> User-Agent: Mutt/1.5.6i Subject: Re: Obvious bug in /sys/i386/include/bus.h (was: bus_at386.h) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2005 18:31:11 -0000 On Mon, Jun 13, 2005 at 05:58:24PM +0200, Hans Petter Selasky wrote: > static void > filter(struct fifo *f) > { > do { > if(!f->len) > { > if(f->m) ...; > > f->m = get_mbuf(); > if(!f->m) break; > > f->len = m->m_len; > f->ptr = m->m_data; > } > > /* f->Z_chip is the maximum transfer length */ > > io_len = min(f->len, f->Z_chip); if (io_len == 0) continue; > > bus_space_write_multi_1(t,h,xxx,f->ptr,io_len); > > f->len -= io_len; > f->Z_chip -= io_len; > f->ptr += io_len; > > } while(Z_chip); > } > [...] > Adding that extra check for zero transfer length is not going to affect > performance at all. If one does that using "C", the compiler can optimize > away that "if(count) ..." when "count" is a constant. Besides the i386 > machine instructions "ins" and "outs" already exhibit that behaviour. The compiler can only optimize it away if it is known to be a constant. But thinking again about it, it should be documented at least whether a count of 0 is allowed or not. I think it makes more sense to not allow it, but others (you included) might disagree. Joerg