Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
standards.h
Go to the documentation of this file.
00001 #ifndef __STANDARDS_H__
00002 #define __STANDARDS_H__
00003 
00004 /*
00005 
00006   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00007 
00008   This program is free software; you can redistribute it and/or modify it
00009   under the terms of version 2 of the GNU General Public License as
00010   published by the Free Software Foundation.
00011 
00012   This program is distributed in the hope that it would be useful, but
00013   WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00015 
00016   Further, this software is distributed without any warranty that it is
00017   free of the rightful claim of any third person regarding infringement 
00018   or the like.  Any license provided herein, whether implied or 
00019   otherwise, applies only to this software file.  Patent licenses, if 
00020   any, provided herein do not apply to combinations of this program with 
00021   other software, or any other product whatsoever.  
00022 
00023   You should have received a copy of the GNU General Public License along
00024   with this program; if not, write the Free Software Foundation, Inc., 59
00025   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00026 
00027   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00028   Mountain View, CA 94043, or:
00029 
00030   http://www.sgi.com
00031 
00032   For further information regarding this notice, see:
00033 
00034   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00035 
00036 */
00037 
00038 #ident "$Id: standards.h,v 1.1.1.1 2002-05-22 20:10:17 dsystem Exp $"
00039 
00040 /*
00041  * We define short forms for the predicates required by various
00042  * headers to support the various standards.
00043  *
00044  * These predicates are used to build up permitted declarations.
00045  * For ANSI-C specified headers, only ANSI-C definitions need no predicate.
00046  * Most are restrictive predicates - declaring when a symbol is NOT
00047  * permitted rather than when they are. Often, if no feature test macro is
00048  * declared then ALL symbols in a header are visible.(the notable exception
00049  * is ANSI headers - they MUST contain only ANSI symbols unless some other
00050  * feature test macro is used.
00051  * These predicates are built up from the following feature test macros:
00052  *      _SGI_SOURCE - used to extend ANSI headers to contain SGI specific
00053  *                    symbols. Both XOPEN and POSIX feature test macros
00054  *                    must override ALL symbols added by this macro
00055  *      _XOPEN_SOURCE - enable Xopen symbols and suppress non-Xopen symbols
00056  *                      According to XPG4 section 2.2 defining _XOPEN_SOURCE
00057  *                      should suffice to enable all _POSIX_SOURCE and
00058  *                      _POSIX_C_SOURCE symbols (well, POSIX90 and POSIX1003.2
00059  *                      symbols)
00060  *      _POSIX_SOURCE
00061  *      _POSIX_C_SOURCE - enable POSIX symbols and suppress non-POSIX symbols.
00062  * In ANSI mode, _SGI_SOURCE is not defined.
00063  *
00064  * One main assumption here is that for the most part, the symbol space
00065  * is ever increasing: ANSI -> POSIX90 -> (POSIX93 -> XOPEN4) -> SGI
00066  * The main hassle is POSIX93 and XPG4
00067  * For the few things that violate this, special predicates must be used.
00068  */
00069 
00070 /*
00071  *
00072  * Note:  The '+0' is used with defines in comparisons in order to 
00073  *        prevent compiler syntax errors produced when the defined variable
00074  *        within user programs do not assign a value.
00075  *
00076  *        For example, the _XOPEN_SOURCE+0 is needed in order to prevent
00077  *        compiler syntax errors when _XOPEN_SOURCE is used within 
00078  *        comparisions and the #define _XOPEN_SOURCE with no value is used
00079  *        within the application source.  The #define _XOPEN_SOURCE with
00080  *        no value is used to designate XPG4 conformance.
00081  */
00082 
00083 /*
00084  * ANSI symbols - In ANSI headers only ANSI symbols are permitted unless
00085  * additional feature test macros are given.
00086  * But in other headers we give all symbols (unless restricted by some other
00087  * feature test macro like POSIX or XOPEN).
00088  *
00089  * In non-ANSI headers we want ALL symbols present regardless of whether
00090  * we are in ANSI more or not.
00091  * In ANSI headers we want ALL symbols if we not in ANSI mode and only
00092  * ANSI symbols if we are in ANSI mode UNLESS they ask for more
00093  * symbols via a feature test macro.
00094  */
00095 
00096 #define _ANSIMODE       (!defined(__EXTENSIONS__))
00097 #define _NO_ANSIMODE    (defined(__EXTENSIONS__) || \
00098                 defined(_SGI_SOURCE) || \
00099                 defined(_POSIX_SOURCE) || \
00100                 defined(_POSIX_C_SOURCE) || \
00101                 defined(_MIPSABI_SOURCE) || \
00102                 defined(_LARGEFILE64_SOURCE) || \
00103                 defined(_XOPEN_SOURCE))
00104 
00105 /*
00106  * POSIX symbols - additions various POSIX standards add over ANSI -
00107  * mode:ANSI    -> symbols are visible (except in ANSI headers)
00108  *      POSIX   -> symbols are visible
00109  *      SGI     -> symbols are visible
00110  *      XOPEN   -> symbols are visible
00111  *
00112  * POSIX90 - 1003.1a (first POSIX)
00113  * POSIX2  - 1003.2 (shells & utilities)
00114  * POSIX93 - 1003.1b (real-time ++)
00115  * POSIX1C - 1003.1c (pthreads..)
00116  *
00117  * Note that _POSIX_SOURCE is obsolete and corresponds to _POSIX_C_SOURCE = 1.
00118  * _POSIX_C_SOURCE=2 was defined by 1003.2
00119  * 1003.1b sets _POSIX_C_SOURCE to 199309L.
00120  */
00121 #define _POSIX90        (defined(_POSIX_SOURCE) || \
00122                          defined(_POSIX_C_SOURCE) || \
00123                          defined(_XOPEN_SOURCE) || \
00124                          defined(_SGI_SOURCE) || \
00125                          _ANSIMODE)
00126 #define _POSIX2         ((defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE+0 > 1)) ||\
00127                          defined(_XOPEN_SOURCE) || \
00128                          defined(_SGI_SOURCE) || \
00129                          _ANSIMODE)
00130 
00131 /*
00132  * Note that POSIX93 and XPG4 each have extensions over the other.
00133  * Thus one can make NO assumptions (as one could previously) that
00134  * if its POSIX then it must be XOPEN. According to XPG4 (section:2.2) if
00135  * _POSIX_C_SOURCE is >2 then the the behavior is undefined.
00136  * For maximal developer latitude, we don't turn off POSIX93 extensions
00137  * if they specify _XOPEN_SOURCE - they can get both if they wish.
00138  *
00139  * New symbols that are both in XPG4 and 1003.1b need to be enabled via:
00140  *      #if _POSIX93 || _XOPEN4
00141  * These symbols shouldn't be visible in POSIX90/2 mode.
00142  */
00143 #define _POSIX93 \
00144                 ((defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE+0 >= 199309L)) ||\
00145                  (defined(_SGI_SOURCE) && _NO_XOPEN4 && _NO_POSIX) || \
00146                  (_ANSIMODE && _NO_XOPEN4 && _NO_POSIX))
00147 #define _NO_POSIX       (!defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE))
00148 
00149 /*
00150  * POSIX 1003.1c - new symbols made visible by pthreads, etc.
00151  * None of these are in XPG4.
00152  * We add _SGI_REENTRANT_FUNCTIONS for backward compatibility
00153  * Of course these symbols shouldn't be visible when in POSIX90/2/93 mode.
00154  * These really can't be visible in MIPS ABI mode either.
00155  */
00156 #define _POSIX1C \
00157                 ((defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE+0 >= 199506L)) ||\
00158                  (defined(_SGI_SOURCE) && _NO_XOPEN4 && _NO_POSIX && _NO_ABIAPI) || \
00159                  defined(_SGI_REENTRANT_FUNCTIONS) || \
00160                  _XOPEN5 || \
00161                  (_ANSIMODE && _NO_XOPEN4 && _NO_POSIX && _NO_ABIAPI))
00162 
00163 /*
00164  * predicate for XOPEN XPG4 additions and extensions -
00165  * mode:ANSI    -> symbols visible (except in ANSI headers)
00166  *      POSIX   -> symbols not visible
00167  *      SGI     -> symbols visible
00168  *      XOPEN   -> symbols visible
00169  */
00170 #define _XOPEN4         (defined(_XOPEN_SOURCE) || \
00171                                 ((defined(_SGI_SOURCE) && _NO_POSIX)) || \
00172                                 (_ANSIMODE && _NO_POSIX))
00173 #define _NO_XOPEN4      (!defined(_XOPEN_SOURCE) || \
00174                                 (defined(_XOPEN_SOURCE) && \
00175                                 (_XOPEN_SOURCE+0 >= 500)))
00176 /*
00177  * Following is a define for XOPEN XPG4 Unix eXtensions
00178  */
00179 #define _XOPEN4UX \
00180                 ((defined(_XOPEN_SOURCE) && \
00181                         defined(_XOPEN_SOURCE_EXTENDED) && \
00182                         _XOPEN_SOURCE_EXTENDED+0 == 1) || \
00183                 (defined(_SGI_SOURCE) && _NO_POSIX && _NO_XOPEN4) || \
00184                 (_ANSIMODE && _NO_POSIX && _NO_XOPEN4))
00185 
00186 /*
00187  * predicate for XOPEN XPG5 additions and extensions -
00188  * mode:ANSI    -> symbols visible (except in ANSI headers)
00189  *      POSIX   -> symbols not visible
00190  *      SGI     -> symbols visible
00191  *      XPG4    -> symbols visible
00192  *      XPG5    -> symbols visible
00193  */
00194 #define _XOPEN5         ((defined(_XOPEN_SOURCE) && \
00195                                 (_XOPEN_SOURCE+0 >= 500)) || \
00196                         ((defined(_SGI_SOURCE) && _NO_POSIX && _NO_XOPEN4)) || \
00197                                 (_ANSIMODE && _NO_POSIX))
00198 #define _NO_XOPEN5      (!defined(_XOPEN_SOURCE) || \
00199                                 (defined(_XOPEN_SOURCE) && \
00200                                 (_XOPEN_SOURCE+0 < 500)))
00201 
00202 /*
00203  * predicates for SGI extensions
00204  *      These include 'standard' unix functions/defines that aren't part of
00205  *      any published standard but are common in the 'standard' unix world.
00206  * mode:ANSI    -> symbols not visible
00207  *      POSIX   -> symbols not visible
00208  *      SGI     -> symbols visible
00209  *      XOPEN   -> symbols not visible
00210  */
00211 #define _SGIAPI         ((defined(_SGI_SOURCE) && \
00212                                 _NO_POSIX && _NO_XOPEN4 && _NO_XOPEN5) || \
00213                         (_ANSIMODE && _NO_POSIX && _NO_XOPEN4 && _NO_XOPEN5))
00214 
00215 /*
00216  * predicates for MIPS ABI extensions
00217  * mode:ANSI    -> symbols not visible
00218  *      POSIX   -> symbols not visible
00219  *      SGI     -> symbols visible
00220  *      XOPEN   -> symbols not visible
00221  *
00222  * The value that _MIPSABI_SOURCE contains is the MIPS ABI 
00223  * Black Book (BB for short) revision number.  For example, the 
00224  * number two (2) refers to the MIPS ABI BB2.0 revision.
00225  *
00226  * XXX - Eventually when all references to _ABI_SOURCE get replaced
00227  *       with _MIPSABI_SOURCE then the below check for _ABI_SOURCE will
00228  *       be deleted.
00229  */
00230 #define _ABIAPI \
00231                 ((defined(_MIPSABI_SOURCE) && (_MIPSABI_SOURCE+0 >= 2)) || \
00232                 defined(_ABI_SOURCE))
00233 #define _NO_ABIAPI \
00234                 ((!defined(_MIPSABI_SOURCE) || (_MIPSABI_SOURCE+0 < 2)) && \
00235                 !defined(_ABI_SOURCE))
00236 
00237 /*
00238  * predicates for MIPS Large File ABI extensions
00239  * mode:ANSI    -> symbols not visible
00240  *      POSIX   -> symbols not visible
00241  *      SGI     -> symbols visible
00242  *      XOPEN   -> symbols not visible
00243  */
00244 #define _LFAPI          (defined(_LARGEFILE64_SOURCE) || _SGIAPI)
00245 
00246 /*
00247  * predicates to get reentrant functions
00248  */
00249 #define _REENTRANT_FUNCTIONS    (defined(_SGI_REENTRANT_FUNCTIONS))
00250 
00251 #endif /* __STANDARDS_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines