epoc32/include/stdapis/stlport/stl/_limits.c
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  * Copyright (c) 1998,1999
     3  * Silicon Graphics Computer Systems, Inc.
     4  *
     5  * Copyright (c) 1999 
     6  * Boris Fomitchev
     7  *
     8  * This material is provided "as is", with absolutely no warranty expressed
     9  * or implied. Any use is at your own risk.
    10  *
    11  * Permission to use or copy this software for any purpose is hereby granted 
    12  * without fee, provided the above notices are retained on all copies.
    13  * Permission to modify the code and to distribute modified code is granted,
    14  * provided the above notices are retained, and a notice that the code was
    15  * modified is included with the above copyright notice.
    16  *
    17  */
    18 
    19 # if !defined (_STLP_LIMITS_C)
    20 #  define _STLP_LIMITS_C
    21 
    22 #ifndef _STLP_INTERNAL_LIMITS_H
    23 # include <stl/_limits.h>
    24 #endif
    25 
    26 //==========================================================
    27 //  numeric_limits static members
    28 //==========================================================
    29 
    30 _STLP_BEGIN_NAMESPACE
    31 
    32 # if ! defined ( _STLP_STATIC_CONST_INIT_BUG)
    33 
    34 #   define __declare_numeric_base_member(__type, __mem, _Init) \
    35 template <class __number> \
    36   const __type _Numeric_limits_base<__number>:: __mem
    37 
    38 __declare_numeric_base_member(bool, is_specialized, false);
    39 __declare_numeric_base_member(int, digits, 0);
    40 __declare_numeric_base_member(int, digits10, 0);
    41 __declare_numeric_base_member(bool, is_signed, false);
    42 __declare_numeric_base_member(bool, is_integer, false);
    43 __declare_numeric_base_member(bool, is_exact, false);
    44 __declare_numeric_base_member(int, radix, 0);
    45 __declare_numeric_base_member(int, min_exponent, 0);
    46 __declare_numeric_base_member(int, max_exponent, 0);
    47 __declare_numeric_base_member(int, min_exponent10, 0);
    48 __declare_numeric_base_member(int, max_exponent10, 0);
    49 __declare_numeric_base_member(bool, has_infinity, false);
    50 __declare_numeric_base_member(bool, has_quiet_NaN, false);
    51 __declare_numeric_base_member(bool, has_signaling_NaN, false);
    52 __declare_numeric_base_member(float_denorm_style, has_denorm, denorm_absent);
    53 __declare_numeric_base_member(bool, has_denorm_loss, false);
    54 __declare_numeric_base_member(bool, is_iec559, false);
    55 __declare_numeric_base_member(bool, is_bounded, false);
    56 __declare_numeric_base_member(bool, is_modulo, false);
    57 __declare_numeric_base_member(bool, traps, false);
    58 __declare_numeric_base_member(bool, tinyness_before, false);
    59 __declare_numeric_base_member(float_round_style, round_style, round_toward_zero);
    60 
    61 # undef __declare_numeric_base_member
    62 
    63 #   define __declare_integer_limits_member(__type, __mem, _Init) \
    64 template <class _Int, _STLP_LIMITS_MIN_TYPE __imin, _STLP_LIMITS_MAX_TYPE __imax, int __idigits, bool __ismod> \
    65   const __type _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: __mem
    66 
    67 __declare_integer_limits_member(bool, is_specialized, true);
    68 __declare_integer_limits_member(int, digits, (__idigits < 0) ? \
    69 			    ((int)((sizeof(_Int) * (CHAR_BIT))) - ((__imin == 0) ? 0 : 1)) \
    70                             : (__idigits) );
    71 __declare_integer_limits_member(int, digits10, (int)(301UL * digits) /1000);
    72 __declare_integer_limits_member(bool, is_signed, __imin != 0);
    73 __declare_integer_limits_member(bool, is_integer, true);
    74 __declare_integer_limits_member(bool, is_exact, true);
    75 __declare_integer_limits_member(int, radix, 2);
    76 __declare_integer_limits_member(bool, is_bounded, true);
    77 __declare_integer_limits_member(bool, is_modulo, true);
    78 
    79 #   define __declare_float_limits_member(__type, __mem, _Init) \
    80 template <class __number,  \
    81          int __Digits, int __Digits10,    \
    82          int __MinExp, int __MaxExp,      \
    83          int __MinExp10, int __MaxExp10,  \
    84          bool __IsIEC559, \
    85          float_round_style __RoundStyle> \
    86 const __type _Floating_limits< __number, __Digits, __Digits10,    \
    87          __MinExp, __MaxExp, __MinExp10, __MaxExp10,  \
    88          __IsIEC559, __RoundStyle>::\
    89          __mem
    90 
    91 __declare_float_limits_member(bool, is_specialized, true);  
    92 __declare_float_limits_member(int, digits, __Digits);  
    93 __declare_float_limits_member(int, digits10, __Digits10);  
    94 __declare_float_limits_member(bool, is_signed, true);  
    95 __declare_float_limits_member(int, radix, FLT_RADIX);  
    96 __declare_float_limits_member(int, min_exponent, __MinExp);  
    97 __declare_float_limits_member(int, max_exponent, __MaxExp);  
    98 __declare_float_limits_member(int, min_exponent10, __MinExp10);  
    99 __declare_float_limits_member(int, max_exponent10, __MaxExp10);  
   100 __declare_float_limits_member(bool, has_infinity, true);
   101 __declare_float_limits_member(bool, has_quiet_NaN, true);
   102 __declare_float_limits_member(bool, has_signaling_NaN, true);
   103 __declare_float_limits_member(float_denorm_style, has_denorm, denorm_indeterminate);
   104 __declare_float_limits_member(bool, has_denorm_loss, false);
   105 __declare_float_limits_member(bool, is_iec559, __IsIEC559);
   106 __declare_float_limits_member(bool, is_bounded, true);
   107 __declare_float_limits_member(bool, traps, true);
   108 __declare_float_limits_member(bool, tinyness_before, false);
   109 __declare_float_limits_member(float_round_style, round_style, __RoundStyle);
   110 
   111 # endif /* _STLP_STATIC_CONST_INIT_BUG */
   112 
   113 
   114 # ifdef _STLP_EXPOSE_GLOBALS_IMPLEMENTATION
   115 
   116 # if defined(_STLP_BIG_ENDIAN)
   117 # if defined(__OS400__)
   118 #  define _STLP_FLOAT_INF_REP { 0x7f80, 0 }
   119 #  define _STLP_FLOAT_QNAN_REP { 0xffc0, 0 }
   120 #  define _STLP_FLOAT_SNAN_REP { 0xff80, 0 }
   121 #  define _STLP_DOUBLE_INF_REP { 0x7ff0, 0, 0, 0 }
   122 #  define _STLP_DOUBLE_QNAN_REP { 0xfff8, 0, 0, 0 }
   123 #  define _STLP_DOUBLE_SNAN_REP { 0xfff0, 0, 0, 0 }
   124 #  define _STLP_LDOUBLE_INF_REP { 0x7ff0, 0, 0, 0, 0, 0, 0, 0 }
   125 #  define _STLP_LDOUBLE_QNAN_REP { 0xfff8, 0, 0, 0, 0, 0, 0, 0 }
   126 #  define _STLP_LDOUBLE_SNAN_REP { 0xfff0, 0, 0, 0, 0, 0, 0, 0 }
   127 # else
   128 #  define _STLP_FLOAT_INF_REP   { 0x7f80, 0 }
   129 #  define _STLP_FLOAT_SNAN_REP  { 0x7f81, 0 }
   130 #  define _STLP_FLOAT_QNAN_REP  { 0x7fc1, 0 }
   131 #  define _STLP_DOUBLE_INF_REP  { 0x7ff0, 0, 0, 0 }
   132 #  define _STLP_DOUBLE_QNAN_REP { 0x7ff1, 0, 0, 0 }
   133 #  define _STLP_DOUBLE_SNAN_REP { 0x7ff9, 0, 0, 0 }
   134 #  define _STLP_LDOUBLE_INF_REP { 0x7ff0, 0, 0, 0, 0, 0, 0, 0 }
   135 #  define _STLP_LDOUBLE_SNAN_REP { 0x7ff1, 0, 0, 0, 0, 0, 0, 0 }
   136 #  define _STLP_LDOUBLE_QNAN_REP { 0x7ff9, 0, 0, 0, 0, 0, 0, 0 }
   137 # endif
   138 
   139 # elif defined (_STLP_LITTLE_ENDIAN)
   140 
   141 # if 0 /* defined(_STLP_MSVC) || defined(__linux__) */
   142 // some IA-32 platform ?? 
   143 #  define _STLP_FLOAT_INF_REP { 0, 0x7f80 }
   144 #  define _STLP_FLOAT_QNAN_REP { 0, 0xffc0 }
   145 #  define _STLP_FLOAT_SNAN_REP { 0, 0xff80 }
   146 
   147 #  define _STLP_DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 }
   148 #  define _STLP_DOUBLE_QNAN_REP { 0, 0, 0, 0xfff8 }
   149 #  define _STLP_DOUBLE_SNAN_REP { 0, 0, 0, 0xfff0 }
   150 #  define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x7FF0, 0 } // ????
   151 #  define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xFFF8, 0 } // ????
   152 #  define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xFFF0, 0 } // ????
   153 
   154 # elif defined(__DECCXX)
   155 
   156 #  define _STLP_FLOAT_INF_REP { 0, 0x7f80 }
   157 #  define _STLP_FLOAT_QNAN_REP { 0, 0xffc0 }
   158 #  define _STLP_FLOAT_SNAN_REP { 0x5555, 0x7f85 }
   159 
   160 #  define _STLP_DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 }
   161 #  define _STLP_DOUBLE_QNAN_REP { 0, 0, 0, 0xfff8 }
   162 #  define _STLP_DOUBLE_SNAN_REP { 0x5555, 0x5555, 0x5555, 0x7ff5 }
   163 
   164 #  define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0, 0, 0, 0, 0x7fff }
   165 #  define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0, 0, 0, 0x8000, 0xffff }
   166 #  define _STLP_LDOUBLE_SNAN_REP { 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x7fff}
   167 # else
   168 #  define _STLP_FLOAT_INF_REP { 0, 0x7f80 }
   169 #  define _STLP_FLOAT_QNAN_REP { 0, 0x7fC0 }
   170 #  define _STLP_FLOAT_SNAN_REP { 0x0001, 0x7f80 }
   171 #  define _STLP_DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 }
   172 #  define _STLP_DOUBLE_QNAN_REP { 0, 0, 0, 0x7ff8 }
   173 #  define _STLP_DOUBLE_SNAN_REP { 0x0001, 0, 0, 0x7ff0 }
   174 #  if defined (_STLP_MSVC) || defined (__ICL) || defined (__BORLANDC__)
   175 #   define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x7FF0, 0 } // ????
   176 #   define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xFFF8, 0 } // ????
   177 #   define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xFFF8, 0 }
   178 #  else
   179 #   define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x8000, 0x7fff }
   180 #   define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xa000, 0x7fff }
   181 #   define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xc000, 0x7fff }
   182 #  endif
   183 # endif
   184 #else
   185 /* This is an architecture we don't know how to handle. Return some
   186 obviously wrong values. */
   187 # define _STLP_FLOAT_INF_REP { 0, 0 }
   188 # define _STLP_FLOAT_QNAN_REP { 0, 0 }
   189 # define _STLP_FLOAT_SNAN_REP { 0, 0 }
   190 # define _STLP_DOUBLE_INF_REP { 0, 0 }
   191 # define _STLP_DOUBLE_QNAN_REP { 0, 0 }
   192 # define _STLP_DOUBLE_SNAN_REP { 0, 0 }
   193 # define _STLP_LDOUBLE_INF_REP { 0 }
   194 # define _STLP_LDOUBLE_QNAN_REP { 0 }
   195 # define _STLP_LDOUBLE_SNAN_REP { 0 }
   196 
   197 #endif
   198 
   199 #if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
   200 # ifndef _STLP_NO_LONG_DOUBLE
   201 template <class __dummy>
   202 const _L_rep _LimG<__dummy>::_L_inf  = {_STLP_LDOUBLE_INF_REP}; 
   203 template <class __dummy>
   204 const _L_rep _LimG<__dummy>::_L_qNaN  = {_STLP_LDOUBLE_QNAN_REP}; 
   205 template <class __dummy>
   206 const _L_rep _LimG<__dummy>::_L_sNaN  = {_STLP_LDOUBLE_SNAN_REP}; 
   207 # endif
   208 template <class __dummy>
   209 const _D_rep _LimG<__dummy>::_D_inf  = {_STLP_DOUBLE_INF_REP}; 
   210 template <class __dummy>
   211 const _D_rep _LimG<__dummy>::_D_qNaN  = {_STLP_DOUBLE_QNAN_REP}; 
   212 template <class __dummy>
   213 const _D_rep _LimG<__dummy>::_D_sNaN  = {_STLP_DOUBLE_SNAN_REP}; 
   214 template <class __dummy>
   215 const _F_rep _LimG<__dummy>::_F_inf  = {_STLP_FLOAT_INF_REP}; 
   216 template <class __dummy>
   217 const _F_rep _LimG<__dummy>::_F_qNaN  = {_STLP_FLOAT_QNAN_REP}; 
   218 template <class __dummy>
   219 const _F_rep _LimG<__dummy>::_F_sNaN  = {_STLP_FLOAT_SNAN_REP}; 
   220 
   221 #else
   222 
   223 __DECLARE_INSTANCE( const _F_rep,
   224                    _LimG<bool>::_F_inf,  = _STLP_FLOAT_INF_REP);
   225 __DECLARE_INSTANCE( const _F_rep,
   226                    _LimG<bool>::_F_qNaN,  = _STLP_FLOAT_QNAN_REP);
   227 __DECLARE_INSTANCE( const _F_rep,
   228                    _LimG<bool>::_F_sNaN,  = _STLP_FLOAT_SNAN_REP);
   229 __DECLARE_INSTANCE( const _D_rep,
   230                    _LimG<bool>::_D_inf,  = _STLP_DOUBLE_INF_REP);
   231 __DECLARE_INSTANCE( const _D_rep,
   232                    _LimG<bool>::_D_qNaN,  = _STLP_DOUBLE_QNAN_REP);
   233 __DECLARE_INSTANCE( const _D_rep,
   234                    _LimG<bool>::_D_sNaN,  = _STLP_DOUBLE_SNAN_REP);
   235 # ifndef _STLP_NO_LONG_DOUBLE
   236 __DECLARE_INSTANCE( const _L_rep,
   237                    _LimG<bool>::_L_inf,  = _STLP_LDOUBLE_INF_REP);
   238 __DECLARE_INSTANCE( const _L_rep,
   239                    _LimG<bool>::_L_qNaN,  = _STLP_LDOUBLE_QNAN_REP);
   240 __DECLARE_INSTANCE( const _L_rep,
   241                    _LimG<bool>::_L_sNaN,  = _STLP_LDOUBLE_SNAN_REP);
   242 # endif
   243 
   244 #endif /* STATIC_DATA */   
   245 
   246 # endif /* _STLP_EXPOSE_GLOBALS_IMPLEMENTATION */
   247     
   248 # undef __declare_integer_limits_member
   249 # undef __declare_float_limits_member
   250 # undef __HACK_ILIMITS
   251 # undef __HACK_NOTHING
   252 # undef __declare_int_members
   253 # undef __declare_float_members
   254 # undef _STLP_LIMITS_MIN_TYPE
   255 # undef _STLP_LIMITS_MAX_TYPE
   256 
   257 # undef _STLP_FLOAT_INF_REP
   258 # undef _STLP_FLOAT_QNAN_REP
   259 # undef _STLP_FLOAT_SNAN_REP
   260 # undef _STLP_DOUBLE_INF_REP
   261 # undef _STLP_DOUBLE_QNAN_REP
   262 # undef _STLP_DOUBLE_SNAN_REP
   263 # undef _STLP_LDOUBLE_INF_REP
   264 # undef _STLP_LDOUBLE_QNAN_REP
   265 # undef _STLP_LDOUBLE_SNAN_REP
   266 
   267 _STLP_END_NAMESPACE
   268 
   269 
   270 #endif /* _STLP_LIMITS_C_INCLUDED */