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