cvs commit: src/sys/vm vm_map.c
Bruce Evans
bde at zeta.org.au
Tue Jun 29 17:19:31 PDT 2004
On Tue, 29 Jun 2004, Andrew Gallatin wrote:
> Bruce Evans writes:
> > On Mon, 28 Jun 2004, Andrew Gallatin wrote:
> > > > > > Log:
> > > > > > Fix alpha - the use of min() on longs was loosing the high bits and
> > > > > > returning wrong answers, leading to strange values vm2->vm_{s,t,d}size.
> >
> > MIN() and MAX() should not be used in the kernel. 4.4BSD removed them in
> > the kernel, but FreeBSD broke this in rev.1.141 of sys/param.h. They
> > remain removed in RELENG_4.
>
> OK. Then what's the correct fix? ulmin()?
Fixing min() to handle all unsigned types is probably best. Some not-quite
correct fixes:
1. Just use ulmin(). It would work on all supported machines because
vm_offset_t is smaller than u_long (actually the same). This is fragile.
2. (1) plus a compile-time assertion that
sizeof(vm_offset_t) <= sizeof(u_long). This is quite practical. There
are only a few min()'s in all of vm, and only the 2 that you fixed seem
to need special handling (the others are mainly for page counts, and
2^32 pages should be enough for anyone).
3. (1) plus a runtime assertion...
4. (3) with calls to uqmin() instead of failing assertions for larger
vm_offset_t's.
5. (4) plus support for uintmax_t's.
6. Support for uintmax_t's, and just use uimax_min().
7. (6), plus wait for gcc to optimize uimax_min(). gcc currently always
widens the args before comparing them, even with -O3.
Bruce
More information about the cvs-src
mailing list