Date: Mon, 13 Jun 2005 18:27:43 +0200 From: Joerg Sonnenberger <joerg@britannica.bec.de> To: freebsd-hackers@freebsd.org Subject: Re: Obvious bug in /sys/i386/include/bus.h (was: bus_at386.h) Message-ID: <20050613162743.GA769@britannica.bec.de> In-Reply-To: <200506131758.25671.hselasky@c2i.net> References: <200506131412.38967.hselasky@c2i.net> <20050613124427.GD1343@britannica.bec.de> <200506131758.25671.hselasky@c2i.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050613162743.GA769>
