From owner-freebsd-standards Wed Feb 27 11:49:25 2002 Delivered-To: freebsd-standards@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id A1E8037B405 for ; Wed, 27 Feb 2002 11:49:17 -0800 (PST) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g1RJhxM43573; Wed, 27 Feb 2002 14:43:59 -0500 (EST) (envelope-from mike) Date: Wed, 27 Feb 2002 14:43:59 -0500 From: Mike Barcroft To: Bruce Evans Cc: "M. Warner Losh" , standards@FreeBSD.ORG Subject: Re: Garrett's POSIX versions patch for review Message-ID: <20020227144359.R31007@espresso.q9media.com> References: <20020226.224449.28794535.imp@village.org> <20020227184645.K47808-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="i9LlY+UWpKt15+FH" Content-Disposition: inline In-Reply-To: <20020227184645.K47808-100000@gamplex.bde.org>; from bde@zeta.org.au on Wed, Feb 27, 2002 at 06:57:27PM +1100 Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --i9LlY+UWpKt15+FH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Bruce Evans writes: > On Tue, 26 Feb 2002, M. Warner Losh wrote: > > > I think that these diffs look good on the surface. I agree that it > > would be nice to have a prisitine c99 env, but if that's hard to do, > > then I don't see waiting the rest of the changes. > > I think they look bad on the surface :-). E.g., using #if defined (...) > instead of #ifdef, and indenting preprocessor code are style bugs. > There are superflous underscores. One might think I would be able to identify and fix style bugs in my own patches. :) Updated version attached. > I don't remember any technical problems from when I reviewed the first > version of Garrett's patch. The new __FOO_VISIBLE macros are much easier > to use than the old _FOO_VISIBLE[_BAR] ones. When I spoke about the logic bug, I was specifically referring to this part here: %%% +#if defined(_POSIX_C_SOURCE) +# if _POSIX_C_SOURCE >= 200199 +# define __POSIX_VISIBLE 200199 +# endif +# if _POSIX_C_SOURCE >= 199506 +# define __POSIX_VISIBLE 199506 +# endif +# if _POSIX_C_SOURCE >= 199309 +# define __POSIX_VISIBLE 199309 +# endif +# if _POSIX_C_SOURCE >= 199009 +# define __POSIX_VISIBLE 199009 +# endif +# if _POSIX_C_SOURCE < 199009 +# define __POSIX_VISIBLE 198808 +# endif %%% Best regards, Mike Barcroft --i9LlY+UWpKt15+FH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="cdefs2.diff" Index: cdefs.h =================================================================== RCS file: /work/repo/src/sys/sys/cdefs.h,v retrieving revision 1.49 diff -u -r1.49 cdefs.h --- cdefs.h 4 Dec 2001 01:29:54 -0000 1.49 +++ cdefs.h 27 Feb 2002 19:31:10 -0000 @@ -268,4 +268,99 @@ #define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var)) #endif +/*- + * The following definitions are an extension of the behavior originally + * implemented in , but with a different level of grandularity. + * POSIX.1 requires that the macros we test be defined before any standard + * header file is included. + * + * Here's a quick run-down of the versions: + * defined(_POSIX_SOURCE) 1003.1-1988 + * _POSIX_C_SOURCE == 1 1003.1-1990 + * _POSIX_C_SOURCE == 199309 1003.1b-1993 + * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, + * and the omnibus ISO/IEC 9945-1: 1996 + * _POSIX_C_SOURCE == 200112 1003.1-2001 + * + * In addition, the X/Open Portability Guide, which is now the Single UNIX + * Specification, defines a feature-test macro which indicates the version of + * that specification, and which subsumes _POSIX_C_SOURCE. + * + * Our macros begin with two underscores to avoid namespace screwage. + */ + +/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE < 199309 +#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ +#define _POSIX_C_SOURCE 199009 +#endif + +/* Deal with various X/Open Portability Guides and Single UNIX Spec. */ +#ifdef _XOPEN_SOURCE +#if _XOPEN_SOURCE >= 600 +#define __XSI_VISIBLE 600 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200112 +#elif _XOPEN_SOURCE >= 500 +#define __XSI_VISIBLE 500 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199506 +#endif +#endif + +/* + * Deal with all versions of POSIX. The ordering relative to the tests above is + * important. + */ +#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE 198808 +#endif +#ifdef _POSIX_C_SOURCE +#if _POSIX_C_SOURCE >= 200112 +#define __POSIX_VISIBLE 200112 +#define __ISO_C_VISIBLE 1999 +#elif _POSIX_C_SOURCE >= 199506 +#define __POSIX_VISIBLE 199506 +#define __ISO_C_VISIBLE 1990 +#elif _POSIX_C_SOURCE >= 199309 +#define __POSIX_VISIBLE 199309 +#define __ISO_C_VISIBLE 1990 +#elif _POSIX_C_SOURCE >= 199009 +#define __POSIX_VISIBLE 199009 +#define __ISO_C_VISIBLE 1990 +#else +#define __POSIX_VISIBLE 198808 +#define __ISO_C_VISIBLE 0 +#endif /* _POSIX_C_SOURCE */ +#else +/*- + * Deal with _ANSI_SOURCE: + * If it is defined, and no other compilation environment is explicitly + * requested, then define our internal feature-test macros to zero. This + * makes no difference to the preprocessor (undefined symbols in preprocessing + * expressions are defined to have value zero), but makes it more convenient for + * a test program to print out the values. + * + * If a program mistakenly defines _ANSI_SOURCE and some other macro such as + * _POSIX_C_SOURCE, we will assume that it wants the broader compilation + * environment (and in fact we will never get here). + */ +#ifdef _ANSI_SOURCE /* Hide almost everything. */ +#define __POSIX_VISIBLE 0 +#define __XSI_VISIBLE 0 +#define __BSD_VISIBLE 0 +#define __ISO_C_VISIBLE 1990 +#else /* Default environment: show everything. */ +#define __POSIX_VISIBLE 200112 +#define __XSI_VISIBLE 600 +#define __BSD_VISIBLE 1 +#define __ISO_C_VISIBLE 1999 +#endif +#endif + +#if __POSIX_VISIBLE +#define _POSIX_VERSION 200112 +#define _KPOSIX_VERSION 200112 +#endif + #endif /* !_SYS_CDEFS_H_ */ --i9LlY+UWpKt15+FH-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message