Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Aug 2010 16:21:47 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Dimitry Andric <dim@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r212064 - head/sys/boot/pc98/boot2
Message-ID:  <201008311621.48087.jhb@freebsd.org>
In-Reply-To: <4C7D5DD2.40407@FreeBSD.org>
References:  <201008311811.o7VIBoC5037894@svn.freebsd.org> <201008311537.51825.jhb@freebsd.org> <4C7D5DD2.40407@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, August 31, 2010 3:53:54 pm Dimitry Andric wrote:
> On 2010-08-31 21:37, John Baldwin wrote:
> >> -    return *(p + 0x401) * 128 * 1024 + *(u_int16_t *)(p + 0x594) * 1024 
* 1024;
> >> +    return *p * 128 * 1024 + *(u_int16_t *)(p + (0x594 - 0x401)) * 1024 
* 1024;
> >>  }
> > 
> > Perhaps replace '(p + 0x594 - 0x401)' with just 'PTOV(0x594)'?
> > 
> > I would actually find it cleaner to remove 'p' altogether perhaps:
> > 
> > 	return (*(u_char *)PTOV(0x401) * 128 * 1024 +
> > 	    *(uint16_t *)PTOV(0x594) * 1024 * 1024);
> 
> Yes, I attempted this variation at first, but it made the code bigger,
> which I wanted to avoid: it went from "11 bytes available" to "7 bytes"
> available.
> 
> I tried several semantically equivalent permutations of the expression,
> and the one I committed gave no increase or decrease in code size.
> 
> Apparently the code size produced by gcc is very sensitive to even
> minimal changes.  For example, a lot of the PTOV() pointer dereferences
> should really be qualified with 'volatile', but that even causes boot2
> to become too big to fit!
> 
> If the 4 extra bytes are no problem, then I would be glad to change it
> to the above expression, though.  It is certainly clearer. :)

I would go with cleaner as long as it fits.  I would only resort to weird 
tricks such as the 'p' one used previously if they are actually needed.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008311621.48087.jhb>