From owner-freebsd-current Sun Mar 12 22:29: 7 2000 Delivered-To: freebsd-current@freebsd.org Received: from gidora.zeta.org.au (gidora.zeta.org.au [203.26.10.25]) by hub.freebsd.org (Postfix) with SMTP id E57EC37B50E for ; Sun, 12 Mar 2000 22:29:01 -0800 (PST) (envelope-from bde@zeta.org.au) Received: (qmail 11550 invoked from network); 13 Mar 2000 06:28:58 -0000 Received: from bde.zeta.org.au (203.2.228.102) by gidora.zeta.org.au with SMTP; 13 Mar 2000 06:28:58 -0000 Date: Mon, 13 Mar 2000 17:28:47 +1100 (EST) From: Bruce Evans X-Sender: bde@alphplex.bde.org To: John Polstra Cc: paul@originative.co.uk, current@FreeBSD.ORG Subject: Re: MAX_UID ? In-Reply-To: <200003130145.RAA51429@vashon.polstra.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, 12 Mar 2000, John Polstra wrote: > Sheesh, criticism isn't enough? Now it has to be constructive too? ;-) > > I guess it could go into in the > "!defined(_ANSI_SOURCE)" section. Bruce might have a better idea. This is the same as putting it in in the "!defined(_ANSI_SOURCE)" section. Anyway, the names should be FOO_MAX, not MAX_FOO. In C99, there are about 50 *_MAX and *_MIN values defined in for Standard C types alone. I would prefer standard maxof() and minof() interfaces that work on any arithmetic type. These can almost be written in portable C, at least in C89 where types are restricted to char, signed char, ..., long double: #define isfloat(type) ((type)0.5 != 0) #define issigned(type) ((type)-1 < 0) #define isschar(type) (!isfloat(type) && issigned(type) && sizeof(type) == 1) #define isuchar(type) (!isfloat(type) && !issigned(type) && sizeof(type) == 1) ... #define maxof(type) ((type)(isschar(type) ? SCHAR_MAX : isuchar(type) ? UCHAR_MAX ...)) Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message