2 // Copyright 2005-2009 Daniel James.
3 // Distributed under 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)
6 #if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER)
7 #define BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER
9 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
13 #include <boost/config.hpp>
14 #include <boost/functional/hash/detail/float_functions.hpp>
15 #include <boost/functional/hash/detail/limits.hpp>
16 #include <boost/integer/static_log2.hpp>
17 #include <boost/cstdint.hpp>
18 #include <boost/assert.hpp>
20 // Include hash implementation for the current platform.
23 #if defined(__CYGWIN__)
24 # if defined(__i386__) || defined(_M_IX86)
25 # include <boost/functional/hash/detail/hash_float_x86.hpp>
27 # include <boost/functional/hash/detail/hash_float_generic.hpp>
30 # include <boost/functional/hash/detail/hash_float_generic.hpp>
33 // Can we use fpclassify?
36 #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
37 #define BOOST_HASH_USE_FPCLASSIFY 0
40 #elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
41 # if (defined(__USE_ISOC99) || defined(_GLIBCXX_USE_C99_MATH)) && \
42 !(defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
43 # define BOOST_HASH_USE_FPCLASSIFY 1
45 # define BOOST_HASH_USE_FPCLASSIFY 0
50 # define BOOST_HASH_USE_FPCLASSIFY 0
53 #if BOOST_HASH_USE_FPCLASSIFY
55 #include <boost/config/no_tr1/cmath.hpp>
62 inline std::size_t float_hash_value(T v)
65 switch (fpclassify(v)) {
69 return (std::size_t)(v > 0 ? -1 : -2);
71 return (std::size_t)(-3);
74 return float_hash_impl(v);
83 #else // !BOOST_HASH_USE_FPCLASSIFY
90 inline std::size_t float_hash_value(T v)
92 return v == 0 ? 0 : float_hash_impl(v);
97 #endif // BOOST_HASH_USE_FPCLASSIFY
99 #undef BOOST_HASH_USE_FPCLASSIFY