Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
lio.h
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2.1 of the GNU Lesser General Public License 
00007   as published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU Lesser General Public 
00021   License along with this program; if not, write the Free Software 
00022   Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 
00023   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 
00037 /* USMID @(#) libf/include/lio.h        92.0    10/08/98 14:30:10 */
00038   
00039 /*
00040  *      Constants.
00041  */
00042 
00043 #define BLANK   ((int) ' ')
00044 #define COMMA   ((int) ',')
00045 #define DQUOTE  ((int) '"')
00046 #define LPAREN  ((int) '(')
00047 #define MINUS   ((int) '-')
00048 #define PERIOD  ((int) '.')
00049 #define PLUS    ((int) '+')
00050 #define RPAREN  ((int) ')')
00051 #define SLASH   ((int) '/')
00052 #define SQUOTE  ((int) '\'')
00053 #define STAR    ((int) '*')
00054 #define ZERO    ((int) '0')
00055 
00056 /*
00057  *      Define some sets of characters and macros to set them.  This
00058  *      is done to provide quick, in-line versions of isdigit(),
00059  *      isspace(), etc.  It works for any characters whose ordinal
00060  *      values are less than the word size (64).  That is, digits,
00061  *      whitespace, and most separators.
00062  */
00063 
00064 #ifdef  _CRAY
00065 #define BIT1    1L
00066 #else
00067 #define BIT1    1LL
00068 #endif
00069 
00070 #define DIGITS  ((BIT1 << (int) '0') | \
00071                  (BIT1 << (int) '1') | \
00072                  (BIT1 << (int) '2') | \
00073                  (BIT1 << (int) '3') | \
00074                  (BIT1 << (int) '4') | \
00075                  (BIT1 << (int) '5') | \
00076                  (BIT1 << (int) '6') | \
00077                  (BIT1 << (int) '7') | \
00078                  (BIT1 << (int) '8') | \
00079                  (BIT1 << (int) '9') )
00080 
00081 #define SPACES  ((BIT1 << (int) ' ' ) | \
00082                  (BIT1 << (int) '\t') | \
00083                  (BIT1 << (int) '\r') | \
00084                  (BIT1 << (int) '\n') | \
00085                  (BIT1 << (int) '\v') | \
00086                  (BIT1 << (int) '\f') )
00087 
00088 #define SEPS    ( SPACES | \
00089                  (BIT1 << SLASH) | \
00090                  (BIT1 << COMMA) )
00091 
00092 #define DELIMS  ( SEPS | \
00093                  (BIT1 << RPAREN) )
00094 
00095 #define STRDLM  ((BIT1 << SQUOTE) | \
00096                  (BIT1 << DQUOTE) )
00097 /*
00098  *      OUT_OF_RANGE returns nonzero iff an item (character) is too
00099  *      large for a word set operation (> 64).  Note that the CRAY
00100  *      PVP hardward always yields zero for shifts which exceed the
00101  *      word size, so this function can be a no-op.
00102  */
00103 
00104 #ifdef  _CRAY1
00105 #define OUT_OF_RANGE(item)      0
00106 #else
00107 #define OUT_OF_RANGE(item)      ((item) & ~077)
00108 #endif
00109 
00110 /*
00111  *      IN_SET returns nonzero iff an item (character) is in a set of
00112  *      items (characters).  Note that the >> operator is undefined
00113  *      for counts larger than the size of the type--the CRAY PVP
00114  *      version of IN_SET takes advantage of the CRAY PVP hardware
00115  *      always yielding zero for shifts which exceed the word size.
00116  */
00117 
00118 #define IN_SET(set, item) \
00119         (OUT_OF_RANGE(item) ? 0 : (((set) >> (item)) & 1))
00120 
00121 /*
00122  *      Now define some character set operations for commonly used
00123  *      (list-directed I/O, namelist I/O, formatted I/O, etc) set
00124  *      tests.
00125  *
00126  *      IS_WHITESPACE   Is character whitespace?
00127  *      IS_DIGIT        Is character a digit?
00128  *      IS_SEPARATOR    Is character a separator (whitespace, slash, or comma)?
00129  *      IS_DELIMITER    Is character a delimiter (separator or rparen)?
00130  *      IS_STRING_DELIMITER     Is character a string delimiter (single
00131  *                              or double quote)?
00132  */
00133 
00134 #define IS_WHITESPACE(x)        IN_SET(SPACES, (int) (x))
00135 #define IS_DIGIT(x)             IN_SET(DIGITS, (int) (x))
00136 #define IS_SEPARATOR(x)         IN_SET(  SEPS, (int) (x))
00137 #define IS_DELIMITER(x)         IN_SET(DELIMS, (int) (x))
00138 #define IS_STRING_DELIMITER(x)  IN_SET(STRDLM, (int) (x))
00139 
00140 /*
00141  *      Field width constants for output conversions.
00142  */
00143 
00144 #define WOCTWRD 22
00145 #define WOCTHWD 11
00146 #define WINT    21      /* field width large enough for -2**64 */
00147 
00148 /*
00149  *      The following are the number of decimal to print for list directed
00150  *      output of real values.
00151  *
00152  *      The *_P_* macros represent the value of the PRECISION intrinsic
00153  *      function for variables of the specified type.
00154  *
00155  *      By default, list directed output of real values prints out all the 
00156  *      significant digits of precision available.   The number of decimal
00157  *      digits needed is 
00158  *
00159  *              2 + INT(p * log10(2))
00160  *
00161  *      where p is the number of bits in the mantissa.  Remember to count the
00162  *      1 implicit mantissa bit in IEEE formats.  (From Steele and White,
00163  *      "Proceedings of the ACM SIGPLAN'90 Conference on Programming Language 
00164  *      Design and Implementation", White Plains, New York, June 20-22, 1990)
00165  */
00166 
00167 #define DREAL4_IEEE      9      /*  4-byte IEEE REAL */
00168 #define DREAL8_IEEE     17      /*  8-byte IEEE REAL */
00169 #define DREAL16_IEEE    36      /* 16-byte IEEE REAL */
00170 #define DREAL16_DD      34      /* 16-byte IEEE double double REAL */
00171 #define DREAL4_P_IEEE    6      /*  4-byte IEEE REAL partial precision */
00172 #define DREAL8_P_IEEE   15      /*  8-byte IEEE REAL partial precision */
00173 #define DREAL16_P_IEEE  33      /* 16-byte IEEE REAL partial precision */
00174 #define DREAL16_P_DD    31      /* 16-byte double double partial precision */
00175 
00176 #define DREAL8_CRI      16      /* 8-byte CRAY REAL */
00177 #define DREAL16_CRI     30      /* 16-byte CRAY REAL */
00178 #define DREAL8_P_CRI    14      /* 8-byte CRAY REAL partial precision */
00179 #define DREAL16_P_CRI   28      /* 16-byte CRAY REAL partial precision */
00180 
00181 #ifdef  IEEE_FLOATING_POINT     
00182 #define DREAL4          DREAL4_IEEE
00183 #define DEXP4           2
00184 #define DREAL8          DREAL8_IEEE
00185 #define DEXP8           3
00186 #define DREAL4_P        DREAL4_P_IEEE
00187 #define DREAL8_P        DREAL8_P_IEEE
00188 #ifdef  __mips
00189 #define DREAL16         DREAL16_DD
00190 #define DREAL16_P       DREAL16_P_DD
00191 #define DEXP16          3
00192 #else
00193 #define DREAL16         DREAL16_IEEE
00194 #define DREAL16_P       DREAL16_P_IEEE
00195 #define DEXP16          4
00196 #endif
00197 #else   /* CRAY floating-point */
00198 #define DREAL8          DREAL8_CRI
00199 #define DREAL16         DREAL16_CRI
00200 #define DREAL8_P        DREAL8_P_CRI
00201 #define DREAL16_P       DREAL16_P_CRI
00202 #define DEXP8           4       /* Maximum digits in exponent */
00203 #define DEXP16          4       /* Maximum digits in exponent */
00204 #endif
00205 
00206 #define DREAL8_YMP80    13      /* 8-byte  CRAY REAL (partial precision) */
00207 #define DREAL16_YMP80   29      /* 16-byte CRAY REAL (partial precision) */
00208 
00209 /*
00210  *      WREALx is the w part of the Ew.d edit descriptor.  We add five
00211  *      to provide room for a leading blank, a leading sign, a decimal
00212  *      point, the exponent ('E') designator, and the sign of the exponent.
00213  */
00214 
00215 #ifdef  DREAL4
00216 #define WREAL4  (DREAL4+DEXP4+5)
00217 #endif
00218 #define WREAL8  (DREAL8+DEXP8+5)
00219 #define WREAL16 (DREAL16+DEXP16+5)
00220 
00221 /*
00222  *      ITEMBUFSIZ is the maximum total field width for one numeric item.  Use
00223  *      complex double as a convenient absolute upper bound.  Leave room for 
00224  *      this and a possible integer repeat count and a '*'.  The 3 are for 
00225  *      '(,)' and the 10 are for a little breathing room.
00226  */
00227 
00228 #define ITEMBUFSIZ      (WINT + 1 + 2*WREAL16 + 3 + 10)
00229 
00230 /*
00231  *      Externs
00232  */
00233 
00234 #ifdef  DREAL4
00235 extern int _dreal4;
00236 #endif
00237 extern int _dreal8;
00238 extern int _dreal16;
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines