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 | #if !defined(BOOST_FUNCTIONAL_DETAIL_FLOAT_FUNCTIONS_HPP) |
---|
7 | #define BOOST_FUNCTIONAL_DETAIL_FLOAT_FUNCTIONS_HPP |
---|
8 | |
---|
9 | #include <cmath> |
---|
10 | |
---|
11 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
---|
12 | # pragma once |
---|
13 | #endif |
---|
14 | |
---|
15 | // The C++ standard requires that the C float functions are overloarded |
---|
16 | // for float, double and long double in the std namespace, but some of the older |
---|
17 | // library implementations don't support this. On some that don't, the C99 |
---|
18 | // float functions (frexpf, frexpl, etc.) are available. |
---|
19 | // |
---|
20 | // Some of this is based on guess work. If I don't know any better I assume that |
---|
21 | // the standard C++ overloaded functions are available. If they're not then this |
---|
22 | // means that the argument is cast to a double and back, which is inefficient |
---|
23 | // and will give pretty bad results for long doubles - so if you know better |
---|
24 | // let me know. |
---|
25 | |
---|
26 | // STLport: |
---|
27 | #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) |
---|
28 | # if (defined(__GNUC__) && __GNUC__ < 3 && (defined(linux) || defined(__linux) || defined(__linux__))) || defined(__DMC__) |
---|
29 | # define BOOST_HASH_USE_C99_FLOAT_FUNCS |
---|
30 | # elif defined(BOOST_MSVC) && BOOST_MSVC < 1300 |
---|
31 | # define BOOST_HASH_USE_C99_FLOAT_FUNCS |
---|
32 | # else |
---|
33 | # define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS |
---|
34 | # endif |
---|
35 | |
---|
36 | // Roguewave: |
---|
37 | // |
---|
38 | // On borland 5.51, with roguewave 2.1.1 the standard C++ overloads aren't |
---|
39 | // defined, but for the same version of roguewave on sunpro they are. |
---|
40 | #elif defined(_RWSTD_VER) |
---|
41 | # if defined(__BORLANDC__) |
---|
42 | # define BOOST_HASH_USE_C99_FLOAT_FUNCS |
---|
43 | # define BOOST_HASH_C99_NO_FLOAT_FUNCS |
---|
44 | # elif defined(__DECCXX) |
---|
45 | # define BOOST_HASH_USE_C99_FLOAT_FUNCS |
---|
46 | # else |
---|
47 | # define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS |
---|
48 | # endif |
---|
49 | |
---|
50 | // libstdc++ (gcc 3.0 onwards, I think) |
---|
51 | #elif defined(__GLIBCPP__) || defined(__GLIBCXX__) |
---|
52 | # define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS |
---|
53 | |
---|
54 | // SGI: |
---|
55 | #elif defined(__STL_CONFIG_H) |
---|
56 | # if defined(linux) || defined(__linux) || defined(__linux__) |
---|
57 | # define BOOST_HASH_USE_C99_FLOAT_FUNCS |
---|
58 | # else |
---|
59 | # define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS |
---|
60 | # endif |
---|
61 | |
---|
62 | // Dinkumware. |
---|
63 | #elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER) |
---|
64 | // Overloaded float functions were probably introduced in an earlier version |
---|
65 | // than this. |
---|
66 | # if defined(_CPPLIB_VER) && (_CPPLIB_VER >= 402) |
---|
67 | # define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS |
---|
68 | # else |
---|
69 | # define BOOST_HASH_USE_C99_FLOAT_FUNCS |
---|
70 | # endif |
---|
71 | |
---|
72 | // Digital Mars |
---|
73 | #elif defined(__DMC__) |
---|
74 | # define BOOST_HASH_USE_C99_FLOAT_FUNCS |
---|
75 | |
---|
76 | // Use overloaded float functions by default. |
---|
77 | #else |
---|
78 | # define BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS |
---|
79 | #endif |
---|
80 | |
---|
81 | namespace boost |
---|
82 | { |
---|
83 | namespace hash_detail |
---|
84 | { |
---|
85 | |
---|
86 | inline float call_ldexp(float v, int exp) |
---|
87 | { |
---|
88 | using namespace std; |
---|
89 | #if defined(BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS) || \ |
---|
90 | defined(BOOST_HASH_C99_NO_FLOAT_FUNCS) |
---|
91 | return ldexp(v, exp); |
---|
92 | #else |
---|
93 | return ldexpf(v, exp); |
---|
94 | #endif |
---|
95 | } |
---|
96 | |
---|
97 | inline double call_ldexp(double v, int exp) |
---|
98 | { |
---|
99 | using namespace std; |
---|
100 | return ldexp(v, exp); |
---|
101 | } |
---|
102 | |
---|
103 | inline long double call_ldexp(long double v, int exp) |
---|
104 | { |
---|
105 | using namespace std; |
---|
106 | #if defined(BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS) |
---|
107 | return ldexp(v, exp); |
---|
108 | #else |
---|
109 | return ldexpl(v, exp); |
---|
110 | #endif |
---|
111 | } |
---|
112 | |
---|
113 | inline float call_frexp(float v, int* exp) |
---|
114 | { |
---|
115 | using namespace std; |
---|
116 | #if defined(BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS) || \ |
---|
117 | defined(BOOST_HASH_C99_NO_FLOAT_FUNCS) |
---|
118 | return frexp(v, exp); |
---|
119 | #else |
---|
120 | return frexpf(v, exp); |
---|
121 | #endif |
---|
122 | } |
---|
123 | |
---|
124 | inline double call_frexp(double v, int* exp) |
---|
125 | { |
---|
126 | using namespace std; |
---|
127 | return frexp(v, exp); |
---|
128 | } |
---|
129 | |
---|
130 | inline long double call_frexp(long double v, int* exp) |
---|
131 | { |
---|
132 | using namespace std; |
---|
133 | #if defined(BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS) |
---|
134 | return frexp(v, exp); |
---|
135 | #else |
---|
136 | return frexpl(v, exp); |
---|
137 | #endif |
---|
138 | } |
---|
139 | } |
---|
140 | } |
---|
141 | |
---|
142 | #if defined(BOOST_HASH_USE_C99_FLOAT_FUNCS) |
---|
143 | #undef BOOST_HASH_USE_C99_FLOAT_FUNCS |
---|
144 | #endif |
---|
145 | |
---|
146 | #if defined(BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS) |
---|
147 | #undef BOOST_HASH_USE_OVERLOAD_FLOAT_FUNCS |
---|
148 | #endif |
---|
149 | |
---|
150 | #if defined(BOOST_HASH_C99_NO_FLOAT_FUNCS) |
---|
151 | #undef BOOST_HASH_C99_NO_FLOAT_FUNCS |
---|
152 | #endif |
---|
153 | |
---|
154 | #endif |
---|