Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 May 2001 21:38:14 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Dima Dorfman <dima@unixfreak.org>
Cc:        hackers@freebsd.org, bde@freebsd.org
Subject:   Re: MIN()/MAX() definitions in sys/param.h
Message-ID:  <Pine.BSF.4.21.0105142111400.29267-100000@besplex.bde.org>
In-Reply-To: <20010514071731.1D9F93E28@bazooka.unixfreak.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0105142111400.29267-100000>