From owner-freebsd-hackers Mon May 14 4:39:49 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 8418737B422; Mon, 14 May 2001 04:39:45 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id VAA28015; Mon, 14 May 2001 21:39:36 +1000 Date: Mon, 14 May 2001 21:38:14 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Dima Dorfman Cc: hackers@freebsd.org, bde@freebsd.org Subject: Re: MIN()/MAX() definitions in sys/param.h In-Reply-To: <20010514071731.1D9F93E28@bazooka.unixfreak.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, 14 May 2001, Dima Dorfman wrote: > Is there a reason the definitions of the MIN() and MAX() macros in > sys/param.h are under an '#ifndef _KERNEL'? Quite a few files in the It is to inhibit use of these macros. The {i,,l,lu,q}{max,min} inline functions are supposed to be used instead. Both of these interfaces are problematic. MIN/MAX can not be implemented to be "safe" macros in Standard C since they need to evaluate their args more than once. Their upper case names indicate that they are unsafe. The {i,,l,lu,q}{max,min} functions are not type-generic, so they are difficult to use correctly for args whose type is typedef'ed. > kernel define these (well, at least MIN) themselves, so it would seem > to make sense to define them globally in sys/param.h for the kernel as > well. Any reason this isn't already done this way, or should I come > up with a patch to fix that? This is a bug in these files. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message