From owner-cvs-all@FreeBSD.ORG Wed Jun 30 10:30:52 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BF76716A4CE; Wed, 30 Jun 2004 10:30:52 +0000 (GMT) Received: from VARK.homeunix.com (adsl-69-107-104-105.dsl.pltn13.pacbell.net [69.107.104.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5E88643D4C; Wed, 30 Jun 2004 10:30:52 +0000 (GMT) (envelope-from das@FreeBSD.ORG) Received: from VARK.homeunix.com (localhost [127.0.0.1]) by VARK.homeunix.com (8.12.11/8.12.10) with ESMTP id i5UAUJN1067914; Wed, 30 Jun 2004 03:30:19 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by VARK.homeunix.com (8.12.11/8.12.10/Submit) id i5UAUIkj067913; Wed, 30 Jun 2004 03:30:18 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Date: Wed, 30 Jun 2004 03:30:18 -0700 From: David Schultz To: Brian Fundakowski Feldman Message-ID: <20040630103018.GA67854@VARK.homeunix.com> Mail-Followup-To: Brian Fundakowski Feldman , Bruce Evans , Andrew Gallatin , src-committers@FreeBSD.ORG, cvs-src@FreeBSD.ORG, cvs-all@FreeBSD.ORG References: <200406281915.i5SJFeaV060231@repoman.freebsd.org> <20040628152232.A2977@grasshopper.cs.duke.edu> <20040628193858.GG5635@green.homeunix.org> <16608.30892.745161.730935@grasshopper.cs.duke.edu> <20040629114614.T2908@gamplex.bde.org> <16609.23767.245708.270218@grasshopper.cs.duke.edu> <20040630095111.U2619@gamplex.bde.org> <20040630030248.GA26810@VARK.homeunix.com> <20040630080047.GC946@green.homeunix.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040630080047.GC946@green.homeunix.org> cc: cvs-src@FreeBSD.ORG cc: src-committers@FreeBSD.ORG cc: Andrew Gallatin cc: Bruce Evans cc: cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/sys/vm vm_map.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jun 2004 10:30:52 -0000 On Wed, Jun 30, 2004, Brian Fundakowski Feldman wrote: > On Tue, Jun 29, 2004 at 08:02:48PM -0700, David Schultz wrote: > > On Wed, Jun 30, 2004, Bruce Evans wrote: > > > 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. > > > > Hmm...but this means either > > > > a) slightly pessimizing 32-bit ports with a function on uintmax_t's, > > > > b) using a macro and introducing double-expansion problems, or > > > > c) using GCC extensions > > > > Option (c) seems best from a technical standpoint, except that > > we'd be making it harder than it already is to compile the kernel > > with compilers other than gcc and icc. (Do others have the > > statement expr extension?) > > No, the correct fix is using MIN() or MAX() that are well-documented > to provide the exact side-effects C programmers know to expect. They > automatically return the correct type, too, with no coercion! Erm...the only places where people should be using min() and max() over MIN() and MAX() is where double expansion is problematic. It really says something about the limitations of your language when you're allowed to have type independence or applicative order argument evaluation, but not both.