svn commit: r212064 - head/sys/boot/pc98/boot2

John Baldwin jhb at freebsd.org
Tue Aug 31 20:22:02 UTC 2010


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


More information about the svn-src-head mailing list