epoc32/include/stdapis/boost/functional/detail/float_functions.hpp
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 
     2 //  Copyright Daniel James 2005-2006. Use, modification, and distribution are
     3 //  subject to the Boost Software License, Version 1.0. (See accompanying
     4 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     5 /*
     6  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     7 */
     8 #if !defined(BOOST_FUNCTIONAL_DETAIL_FLOAT_FUNCTIONS_HPP)
     9 #define BOOST_FUNCTIONAL_DETAIL_FLOAT_FUNCTIONS_HPP
    10 
    11 #include <cmath>
    12 
    13 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
    14 # pragma once
    15 #endif
    16 
    17 // The C++ standard requires that the C float functions are overloarded
    18 // for float, double and long double in the std namespace, but some of the older
    19 // library implementations don't support this. On some that don't, the C99
    20 // float functions (frexpf, frexpl, etc.) are available.
    21 //
    22 // Some of this is based on guess work. If I don't know any better I assume that
    23 // the standard C++ overloaded functions are available. If they're not then this
    24 // means that the argument is cast to a double and back, which is inefficient
    25 // and will give pretty bad results for long doubles - so if you know better
    26 // let me know.
    27 
    28 // STLport:
    29 #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
    30 #  if (defined(__GNUC__) && __GNUC__ < 3 && (defined(linux) || defined(__linux) || defined(__linux__))) || defined(__DMC__)
    31 #    define BOOST_HASH_USE_C99_FLOAT_FUNCS
    32 #  elif defined(BOOST_MSVC) && BOOST_MSVC < 1300
    33 #    define BOOST_HASH_USE_C99_FLOAT_FUNCS
    34 #  else
    35 #    define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS
    36 #  endif
    37 
    38 // Roguewave:
    39 //
    40 // On borland 5.51, with roguewave 2.1.1 the standard C++ overloads aren't
    41 // defined, but for the same version of roguewave on sunpro they are.
    42 #elif defined(_RWSTD_VER)
    43 #  if defined(__BORLANDC__)
    44 #    define BOOST_HASH_USE_C99_FLOAT_FUNCS
    45 #    define BOOST_HASH_C99_NO_FLOAT_FUNCS
    46 #  elif defined(__DECCXX)
    47 #    define BOOST_HASH_USE_C99_FLOAT_FUNCS
    48 #  else
    49 #    define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS
    50 #  endif
    51 
    52 // libstdc++ (gcc 3.0 onwards, I think)
    53 #elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
    54 #  define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS
    55 
    56 // SGI:
    57 #elif defined(__STL_CONFIG_H)
    58 #  if defined(linux) || defined(__linux) || defined(__linux__)
    59 #    define BOOST_HASH_USE_C99_FLOAT_FUNCS
    60 #  else
    61 #    define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS
    62 #  endif
    63 
    64 // Dinkumware.
    65 #elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
    66 // Overloaded float functions were probably introduced in an earlier version
    67 // than this.
    68 #  if defined(_CPPLIB_VER) && (_CPPLIB_VER >= 402)
    69 #    define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS
    70 #  else
    71 #    define BOOST_HASH_USE_C99_FLOAT_FUNCS
    72 #  endif
    73 
    74 // Digital Mars
    75 #elif defined(__DMC__)
    76 #  define BOOST_HASH_USE_C99_FLOAT_FUNCS
    77 
    78 // Use overloaded float functions by default.
    79 #else
    80 #  define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS
    81 #endif
    82 
    83 namespace boost
    84 {
    85     namespace hash_detail
    86     {
    87 
    88         inline float call_ldexp(float v, int exp)
    89         {
    90             using namespace std;
    91 #if defined(BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS) || \
    92     defined(BOOST_HASH_C99_NO_FLOAT_FUNCS)
    93             return ldexp(v, exp);
    94 #else
    95             return ldexpf(v, exp);
    96 #endif
    97         }
    98 
    99         inline double call_ldexp(double v, int exp)
   100         {
   101             using namespace std;
   102             return ldexp(v, exp);
   103         }
   104 
   105 #ifndef __SYMBIAN32__
   106         inline long double call_ldexp(long double v, int exp)
   107         {
   108             using namespace std;
   109 #if defined(BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS)
   110             return ldexp(v, exp);
   111 #else
   112             return ldexpl(v, exp);
   113 #endif
   114         }
   115 #endif
   116 
   117         inline float call_frexp(float v, int* exp)
   118         {
   119             using namespace std;
   120 #if defined(BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS) || \
   121     defined(BOOST_HASH_C99_NO_FLOAT_FUNCS)
   122             return frexp(v, exp);
   123 #else
   124             return frexpf(v, exp);
   125 #endif
   126         }
   127 
   128         inline double call_frexp(double v, int* exp)
   129         {
   130             using namespace std;
   131             return frexp(v, exp);
   132         }
   133 
   134 
   135 #ifndef __SYMBIAN32__
   136         inline long double call_frexp(long double v, int* exp)
   137         {
   138             using namespace std;
   139 #if defined(BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS)
   140             return frexp(v, exp);
   141 #else
   142             return frexpl(v, exp);
   143 #endif
   144         }
   145 #endif        
   146     }
   147 }
   148 
   149 #if defined(BOOST_HASH_USE_C99_FLOAT_FUNCS)
   150 #undef BOOST_HASH_USE_C99_FLOAT_FUNCS
   151 #endif
   152 
   153 #if defined(BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS)
   154 #undef BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS
   155 #endif
   156 
   157 #if defined(BOOST_HASH_C99_NO_FLOAT_FUNCS)
   158 #undef BOOST_HASH_C99_NO_FLOAT_FUNCS
   159 #endif
   160 
   161 #endif