ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_limits.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1998,1999
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Copyright (c) 1999
00006  * Boris Fomitchev
00007  *
00008  * This material is provided "as is", with absolutely no warranty expressed
00009  * or implied. Any use is at your own risk.
00010  *
00011  * Permission to use or copy this software for any purpose is hereby granted
00012  * without fee, provided the above notices are retained on all copies.
00013  * Permission to modify the code and to distribute modified code is granted,
00014  * provided the above notices are retained, and a notice that the code was
00015  * modified is included with the above copyright notice.
00016  *
00017  */
00018 
00019 #ifndef _STLP_LIMITS_C
00020 #define _STLP_LIMITS_C
00021 
00022 #ifndef _STLP_INTERNAL_LIMITS
00023 #  include <stl/_limits.h>
00024 #endif
00025 
00026 //==========================================================
00027 //  numeric_limits static members
00028 //==========================================================
00029 
00030 _STLP_BEGIN_NAMESPACE
00031 
00032 _STLP_MOVE_TO_PRIV_NAMESPACE
00033 
00034 #if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
00035 
00036 #  define __declare_numeric_base_member(__type, __mem) \
00037 template <class __number> \
00038   const __type _Numeric_limits_base<__number>:: __mem
00039 
00040 __declare_numeric_base_member(bool, is_specialized);
00041 __declare_numeric_base_member(int, digits);
00042 __declare_numeric_base_member(int, digits10);
00043 __declare_numeric_base_member(bool, is_signed);
00044 __declare_numeric_base_member(bool, is_integer);
00045 __declare_numeric_base_member(bool, is_exact);
00046 __declare_numeric_base_member(int, radix);
00047 __declare_numeric_base_member(int, min_exponent);
00048 __declare_numeric_base_member(int, max_exponent);
00049 __declare_numeric_base_member(int, min_exponent10);
00050 __declare_numeric_base_member(int, max_exponent10);
00051 __declare_numeric_base_member(bool, has_infinity);
00052 __declare_numeric_base_member(bool, has_quiet_NaN);
00053 __declare_numeric_base_member(bool, has_signaling_NaN);
00054 __declare_numeric_base_member(float_denorm_style, has_denorm);
00055 __declare_numeric_base_member(bool, has_denorm_loss);
00056 __declare_numeric_base_member(bool, is_iec559);
00057 __declare_numeric_base_member(bool, is_bounded);
00058 __declare_numeric_base_member(bool, is_modulo);
00059 __declare_numeric_base_member(bool, traps);
00060 __declare_numeric_base_member(bool, tinyness_before);
00061 __declare_numeric_base_member(float_round_style, round_style);
00062 
00063 #  undef __declare_numeric_base_member
00064 
00065 #  define __declare_integer_limits_member(__type, __mem) \
00066 template <class _Int, _STLP_LIMITS_MIN_TYPE __imin, _STLP_LIMITS_MAX_TYPE __imax, int __idigits, bool __ismod> \
00067   const __type _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: __mem
00068 
00069 __declare_integer_limits_member(bool, is_specialized);
00070 __declare_integer_limits_member(int, digits);
00071 __declare_integer_limits_member(int, digits10);
00072 __declare_integer_limits_member(bool, is_signed);
00073 __declare_integer_limits_member(bool, is_integer);
00074 __declare_integer_limits_member(bool, is_exact);
00075 __declare_integer_limits_member(int, radix);
00076 __declare_integer_limits_member(bool, is_bounded);
00077 __declare_integer_limits_member(bool, is_modulo);
00078 #  undef __declare_integer_limits_member
00079 
00080 #  if defined (__GNUC__) && (__GNUC__ != 2 || __GNUC_MINOR__ > 96) && (__GNUC__ != 3 || __GNUC_MINOR__ == 0) && (__GNUC__ <= 3)
00081 _STLP_MOVE_TO_STD_NAMESPACE
00082 
00083 #    define __declare_numeric_limits_member(__integer) \
00084   _STLP_TEMPLATE_NULL const int numeric_limits<__integer>::digits; \
00085   _STLP_TEMPLATE_NULL const int numeric_limits<__integer>::digits10; \
00086   _STLP_TEMPLATE_NULL const int numeric_limits<__integer>::radix; \
00087   _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_specialized; \
00088   _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_signed; \
00089   _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_integer; \
00090   _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_exact; \
00091   _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_bounded; \
00092   _STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_modulo
00093 
00094 __declare_numeric_limits_member(_STLP_LONG_LONG);
00095 __declare_numeric_limits_member(unsigned _STLP_LONG_LONG);
00096 
00097 #    undef __declare_numeric_limits_member
00098 
00099 _STLP_MOVE_TO_PRIV_NAMESPACE
00100 #  endif
00101 
00102 #  define __declare_float_limits_member(__type, __mem) \
00103 template <class __number,  \
00104          int __Digits, int __Digits10,    \
00105          int __MinExp, int __MaxExp,      \
00106          int __MinExp10, int __MaxExp10,  \
00107          bool __IsIEC559, \
00108          float_denorm_style __DenormStyle, \
00109          float_round_style __RoundStyle> \
00110 const __type _Floating_limits< __number, __Digits, __Digits10,    \
00111          __MinExp, __MaxExp, __MinExp10, __MaxExp10,  \
00112          __IsIEC559, __DenormStyle, __RoundStyle>::\
00113          __mem
00114 
00115 __declare_float_limits_member(bool, is_specialized);
00116 __declare_float_limits_member(int, digits);
00117 __declare_float_limits_member(int, digits10);
00118 __declare_float_limits_member(bool, is_signed);
00119 __declare_float_limits_member(int, radix);
00120 __declare_float_limits_member(int, min_exponent);
00121 __declare_float_limits_member(int, max_exponent);
00122 __declare_float_limits_member(int, min_exponent10);
00123 __declare_float_limits_member(int, max_exponent10);
00124 __declare_float_limits_member(bool, has_infinity);
00125 __declare_float_limits_member(bool, has_quiet_NaN);
00126 __declare_float_limits_member(bool, has_signaling_NaN);
00127 __declare_float_limits_member(float_denorm_style, has_denorm);
00128 __declare_float_limits_member(bool, has_denorm_loss);
00129 __declare_float_limits_member(bool, is_iec559);
00130 __declare_float_limits_member(bool, is_bounded);
00131 __declare_float_limits_member(bool, traps);
00132 __declare_float_limits_member(bool, tinyness_before);
00133 __declare_float_limits_member(float_round_style, round_style);
00134 #  undef __declare_float_limits_member
00135 
00136 #endif
00137 
00138 
00139 #if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION)
00140 
00141 #  if defined (__GNUC__) || defined (__BORLANDC__)
00142 #    define _STLP_ADDITIONAL_OPEN_BRACKET {
00143 #    define _STLP_ADDITIONAL_CLOSE_BRACKET }
00144 #  else
00145 #    define _STLP_ADDITIONAL_OPEN_BRACKET
00146 #    define _STLP_ADDITIONAL_CLOSE_BRACKET
00147 #  endif
00148 
00149 /* The following code has been extracted from the boost libraries (www.boost.org) and
00150  * adapted with the STLport portability macros. Advantage on previous technique is that
00151  * computation of infinity and NaN values is only based on big/little endianess, compiler
00152  * float, double or long double representation is taken into account thanks to the sizeof
00153  * operator. */
00154 template<class _Number, unsigned short _Word>
00155 struct float_helper {
00156   union _WordsNumber {
00157     unsigned short _Words[8];
00158     _Number _num;
00159   };
00160   static _Number get_word_higher() _STLP_NOTHROW {
00161     _WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET _Word, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET };
00162     return __tmp._num;
00163   } 
00164   static _Number get_word_lower() _STLP_NOTHROW {
00165     _WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET };
00166     __tmp._Words[(sizeof(_Number) >= 12 ? 10 : sizeof(_Number)) / sizeof(unsigned short) - 1] = _Word;
00167     return __tmp._num;
00168   }
00169   static _Number get_from_last_word() _STLP_NOTHROW {
00170 #  if defined (_STLP_BIG_ENDIAN)
00171     return get_word_higher();
00172 #  else /* _STLP_LITTLE_ENDIAN */
00173     return get_word_lower();
00174 #  endif
00175   }
00176   static _Number get_from_first_word() _STLP_NOTHROW {
00177 #  if defined (_STLP_BIG_ENDIAN)
00178     return get_word_lower();
00179 #  else /* _STLP_LITTLE_ENDIAN */
00180     return get_word_higher();
00181 #  endif
00182   }
00183 };
00184 
00185 #  if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_BIG_ENDIAN)
00186 template<class _Number, unsigned short _Word1, unsigned short _Word2>
00187 struct float_helper2 {
00188   union _WordsNumber {
00189     unsigned short _Words[8];
00190     _Number _num;
00191   };
00192   //static _Number get_word_higher() _STLP_NOTHROW {
00193   //  _WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET _Word1, _Word2, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET };
00194   //  return __tmp._num;
00195   //} 
00196   static _Number get_word_lower() _STLP_NOTHROW {
00197     _WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET };
00198     __tmp._Words[(sizeof(_Number) >= 12 ? 10 : sizeof(_Number)) / sizeof(unsigned short) - 2] = _Word1;
00199     __tmp._Words[(sizeof(_Number) >= 12 ? 10 : sizeof(_Number)) / sizeof(unsigned short) - 1] = _Word2;
00200     return __tmp._num;
00201   }
00202   static _Number get_from_last_word() _STLP_NOTHROW {
00203 //#    if defined (_STLP_BIG_ENDIAN)
00204 //    return get_word_higher();
00205 //#    else /* _STLP_LITTLE_ENDIAN */
00206     return get_word_lower();
00207 //#    endif
00208   }
00209 };
00210 #  endif
00211 
00212 /* Former values kept in case moving to boost code has introduce a regression on
00213  * some platform. */
00214 #if 0
00215 #  if defined (_STLP_BIG_ENDIAN)
00216 #    if defined (__OS400__)
00217 #      define _STLP_FLOAT_INF_REP { 0x7f80, 0 }
00218 #      define _STLP_FLOAT_QNAN_REP { 0xffc0, 0 }
00219 #      define _STLP_FLOAT_SNAN_REP { 0xff80, 0 }
00220 #      define _STLP_DOUBLE_INF_REP { 0x7ff0, 0, 0, 0 }
00221 #      define _STLP_DOUBLE_QNAN_REP { 0xfff8, 0, 0, 0 }
00222 #      define _STLP_DOUBLE_SNAN_REP { 0xfff0, 0, 0, 0 }
00223 #      define _STLP_LDOUBLE_INF_REP { 0x7ff0, 0, 0, 0, 0, 0, 0, 0 }
00224 #      define _STLP_LDOUBLE_QNAN_REP { 0xfff8, 0, 0, 0, 0, 0, 0, 0 }
00225 #      define _STLP_LDOUBLE_SNAN_REP { 0xfff0, 0, 0, 0, 0, 0, 0, 0 }
00226 #    else /* __OS400__ */
00227 #      define _STLP_FLOAT_INF_REP   { 0x7f80, 0 }
00228 #      define _STLP_FLOAT_QNAN_REP  { 0x7fc1, 0 }
00229 #      define _STLP_FLOAT_SNAN_REP  { 0x7f81, 0 }
00230 #      define _STLP_DOUBLE_INF_REP  { 0x7ff0, 0, 0, 0 }
00231 #      define _STLP_DOUBLE_QNAN_REP { 0x7ff9, 0, 0, 0 }
00232 #      define _STLP_DOUBLE_SNAN_REP { 0x7ff1, 0, 0, 0 }
00233 #      define _STLP_LDOUBLE_INF_REP { 0x7ff0, 0, 0, 0, 0, 0, 0, 0 }
00234 #      define _STLP_LDOUBLE_QNAN_REP { 0x7ff1, 0, 0, 0, 0, 0, 0, 0 }
00235 #      define _STLP_LDOUBLE_SNAN_REP { 0x7ff9, 0, 0, 0, 0, 0, 0, 0 }
00236 #    endif /* __OS400__ */
00237 #  else /* _STLP_LITTLE_ENDIAN */
00238 #    if defined(__DECCXX)
00239 #      define _STLP_FLOAT_INF_REP { 0, 0x7f80 }
00240 #      define _STLP_FLOAT_QNAN_REP { 0, 0xffc0 }
00241 #      define _STLP_FLOAT_SNAN_REP { 0x5555, 0x7f85 }
00242 #      define _STLP_DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 }
00243 #      define _STLP_DOUBLE_QNAN_REP { 0, 0, 0, 0xfff8 }
00244 #      define _STLP_DOUBLE_SNAN_REP { 0x5555, 0x5555, 0x5555, 0x7ff5 }
00245 #      define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0, 0, 0, 0, 0x7fff }
00246 #      define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0, 0, 0, 0x8000, 0xffff }
00247 #      define _STLP_LDOUBLE_SNAN_REP { 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x7fff}
00248 #    else
00249 #      define _STLP_FLOAT_INF_REP { 0, 0x7f80 }
00250 #      define _STLP_FLOAT_QNAN_REP { 0, 0x7fc0 }
00251 #      define _STLP_FLOAT_SNAN_REP { 0, 0x7fa0 }
00252 #      define _STLP_DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 }
00253 #      define _STLP_DOUBLE_QNAN_REP { 0, 0, 0, 0x7ff8 }
00254 #      define _STLP_DOUBLE_SNAN_REP { 0, 0, 0, 0x7ff4 }
00255 #      if defined (_STLP_MSVC) || defined (__ICL)
00256 #        define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x7FF0, 0 }
00257 #        define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xFFF8, 0 }
00258 #        define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xFFF8, 0 }
00259 #      elif defined (__BORLANDC__)
00260 #        define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x8000, 0x7fff }
00261 #        define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xc000, 0x7fff }
00262 #        define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xa000, 0x7fff }
00263 #      else
00264 #        define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x8000, 0x7fff, 0 }
00265 #        define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xa000, 0x7fff, 0 }
00266 #        define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xc000, 0x7fff, 0 }
00267 #      endif
00268 #    endif
00269 #  endif
00270 
00271 union _F_rep {
00272   unsigned short rep[2];
00273   float val;
00274 };
00275 union _D_rep {
00276   unsigned short rep[4];
00277   double val;
00278 };
00279 
00280 #  ifndef _STLP_NO_LONG_DOUBLE
00281 union _LD_rep {
00282   unsigned short rep[8];
00283   long double val;
00284 };
00285 #  endif
00286 #endif
00287 
00288 template <class __dummy>
00289 float _STLP_CALL _LimG<__dummy>::get_F_inf() {
00290   typedef float_helper<float, 0x7f80u> _FloatHelper;
00291   return _FloatHelper::get_from_last_word();
00292 }
00293 template <class __dummy>
00294 float _STLP_CALL _LimG<__dummy>::get_F_qNaN() {
00295   typedef float_helper<float, 0x7f81u> _FloatHelper;
00296   return _FloatHelper::get_from_last_word();
00297 }
00298 template <class __dummy>
00299 float _STLP_CALL _LimG<__dummy>::get_F_sNaN() {
00300   typedef float_helper<float, 0x7fc1u> _FloatHelper;
00301   return _FloatHelper::get_from_last_word();
00302 }
00303 template <class __dummy>
00304 float _STLP_CALL _LimG<__dummy>::get_F_denormMin() {
00305   typedef float_helper<float, 0x0001u> _FloatHelper;
00306   return _FloatHelper::get_from_first_word();
00307 }
00308 
00309 template <int __use_double_limits>
00310 class _NumericLimitsAccess;
00311 
00312 _STLP_TEMPLATE_NULL
00313 class _NumericLimitsAccess<1> {
00314 public:
00315   static double get_inf() {
00316     typedef float_helper<double, 0x7ff0u> _FloatHelper;
00317     return _FloatHelper::get_from_last_word();
00318   }
00319   static double get_qNaN() {
00320     typedef float_helper<double, 0x7ff1u> _FloatHelper;
00321     return _FloatHelper::get_from_last_word();
00322   }
00323   static double get_sNaN() {
00324     typedef float_helper<double, 0x7ff9u> _FloatHelper;
00325     return _FloatHelper::get_from_last_word();
00326   }
00327 };
00328 
00329 template <class __dummy>
00330 double _STLP_CALL _LimG<__dummy>::get_D_inf()
00331 { return _NumericLimitsAccess<1>::get_inf(); }
00332 template <class __dummy>
00333 double _STLP_CALL _LimG<__dummy>::get_D_qNaN()
00334 { return _NumericLimitsAccess<1>::get_qNaN(); }
00335 template <class __dummy>
00336 double _STLP_CALL _LimG<__dummy>::get_D_sNaN()
00337 { return _NumericLimitsAccess<1>::get_sNaN(); }
00338 template <class __dummy>
00339 double _STLP_CALL _LimG<__dummy>::get_D_denormMin() {
00340   typedef float_helper<double, 0x0001u> _FloatHelper;
00341   return _FloatHelper::get_from_first_word();
00342 }
00343 
00344 #  if !defined (_STLP_NO_LONG_DOUBLE)
00345 _STLP_TEMPLATE_NULL
00346 class _NumericLimitsAccess<0> {
00347 public:
00348   static long double get_inf() {
00349 #    if defined (_STLP_BIG_ENDIAN)
00350     typedef float_helper<long double, 0x7ff0u> _FloatHelper;
00351 #    else
00352     typedef float_helper2<long double, 0x8000u, 0x7fffu> _FloatHelper;
00353 #    endif
00354     return _FloatHelper::get_from_last_word();
00355   }
00356   static long double get_qNaN() {
00357 #    if defined (_STLP_BIG_ENDIAN)
00358     typedef float_helper<long double, 0x7ff1u> _FloatHelper;
00359 #    else
00360     typedef float_helper2<long double, 0xc000u, 0x7fffu> _FloatHelper;
00361 #    endif
00362     return _FloatHelper::get_from_last_word();
00363   }
00364   static long double get_sNaN() {
00365 #    if defined (_STLP_BIG_ENDIAN)
00366     typedef float_helper<long double, 0x7ff9u> _FloatHelper;
00367 #    else
00368     typedef float_helper2<long double, 0x9000u, 0x7fffu> _FloatHelper;
00369 #    endif
00370     return _FloatHelper::get_from_last_word();
00371   }
00372 };
00373 
00374 template <class __dummy>
00375 long double _STLP_CALL _LimG<__dummy>::get_LD_inf() {
00376   const int __use_double_limits = sizeof(double) == sizeof(long double) ? 1 : 0;
00377   return _NumericLimitsAccess<__use_double_limits>::get_inf();
00378 }
00379 template <class __dummy>
00380 long double _STLP_CALL _LimG<__dummy>::get_LD_qNaN() {
00381   const int __use_double_limits = sizeof(double) == sizeof(long double) ? 1 : 0;
00382   return _NumericLimitsAccess<__use_double_limits>::get_qNaN();
00383 }
00384 template <class __dummy>
00385 long double _STLP_CALL _LimG<__dummy>::get_LD_sNaN() {
00386   const int __use_double_limits = sizeof(double) == sizeof(long double) ? 1 : 0;
00387   return _NumericLimitsAccess<__use_double_limits>::get_sNaN();
00388 }
00389 template <class __dummy>
00390 long double _STLP_CALL _LimG<__dummy>::get_LD_denormMin() {
00391   typedef float_helper<long double, 0x0001u> _FloatHelper;
00392   return _FloatHelper::get_from_first_word();
00393 }
00394 #  endif
00395 
00396 #endif /* _STLP_EXPOSE_GLOBALS_IMPLEMENTATION */
00397 
00398 #undef _STLP_LIMITS_MIN_TYPE
00399 #undef _STLP_LIMITS_MAX_TYPE
00400 
00401 _STLP_MOVE_TO_STD_NAMESPACE
00402 
00403 _STLP_END_NAMESPACE
00404 
00405 #endif /* _STLP_LIMITS_C_INCLUDED */

Generated on Mon May 28 2012 04:29:04 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.