Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2007-10-21 04:54:36


Author: danieljames
Date: 2007-10-21 04:54:36 EDT (Sun, 21 Oct 2007)
New Revision: 40266
URL: http://svn.boost.org/trac/boost/changeset/40266

Log:
Merge from trunk. Including floating point hash tweaks.

Properties modified:
   branches/hash/ (props changed)
Text files modified:
   branches/hash/boost/asio/detail/socket_ops.hpp | 9 +++++++++
   branches/hash/boost/asio/ip/address_v6.hpp | 2 +-
   branches/hash/boost/asio/ip/detail/socket_option.hpp | 2 +-
   branches/hash/boost/functional/detail/hash_float.hpp | 27 +++++++++++++--------------
   branches/hash/libs/asio/test/socket_base.cpp | 32 ++++++++++++++++----------------
   5 files changed, 40 insertions(+), 32 deletions(-)

Modified: branches/hash/boost/asio/detail/socket_ops.hpp
==============================================================================
--- branches/hash/boost/asio/detail/socket_ops.hpp (original)
+++ branches/hash/boost/asio/detail/socket_ops.hpp 2007-10-21 04:54:36 EDT (Sun, 21 Oct 2007)
@@ -549,8 +549,17 @@
       && timeout->tv_usec > 0 && timeout->tv_usec < 1000)
     timeout->tv_usec = 1000;
 #endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+
+#if defined(__hpux)
+ timespec ts;
+ ts.tv_sec = timeout ? timeout->tv_sec : 0;
+ ts.tv_nsec = timeout ? timeout->tv_usec * 1000 : 0;
+ return error_wrapper(::pselect(nfds, readfds,
+ writefds, exceptfds, timeout ? &ts : 0, 0), ec);
+#else
   return error_wrapper(::select(nfds, readfds,
         writefds, exceptfds, timeout), ec);
+#endif
 }
 
 inline int poll_read(socket_type s, boost::system::error_code& ec)

Modified: branches/hash/boost/asio/ip/address_v6.hpp
==============================================================================
--- branches/hash/boost/asio/ip/address_v6.hpp (original)
+++ branches/hash/boost/asio/ip/address_v6.hpp 2007-10-21 04:54:36 EDT (Sun, 21 Oct 2007)
@@ -301,7 +301,7 @@
   {
     using namespace std; // For memcmp.
     int memcmp_result = memcmp(&a1.addr_, &a2.addr_,
- sizeof(boost::asio::detail::in6_addr_type)) < 0;
+ sizeof(boost::asio::detail::in6_addr_type));
     if (memcmp_result < 0)
       return true;
     if (memcmp_result > 0)

Modified: branches/hash/boost/asio/ip/detail/socket_option.hpp
==============================================================================
--- branches/hash/boost/asio/ip/detail/socket_option.hpp (original)
+++ branches/hash/boost/asio/ip/detail/socket_option.hpp 2007-10-21 04:54:36 EDT (Sun, 21 Oct 2007)
@@ -38,7 +38,7 @@
 class boolean
 {
 public:
-#if defined(__sun) || defined(_AIX) || defined(__osf__)
+#if defined(__sun) || defined(_AIX) || defined(__osf__) || defined(__hpux)
   typedef unsigned char value_type;
 #else
   typedef int value_type;

Modified: branches/hash/boost/functional/detail/hash_float.hpp
==============================================================================
--- branches/hash/boost/functional/detail/hash_float.hpp (original)
+++ branches/hash/boost/functional/detail/hash_float.hpp 2007-10-21 04:54:36 EDT (Sun, 21 Oct 2007)
@@ -20,7 +20,6 @@
 #include <boost/limits.hpp>
 #include <boost/assert.hpp>
 
-
 // Select implementation for the current platform.
 
 // Cygwn
@@ -90,7 +89,6 @@
             seed ^= value + (seed<<6) + (seed>>2);
         }
 
-
 // A simple, non-portable hash algorithm for x86.
 #if defined(BOOST_HASH_USE_x86_BINARY_HASH)
         inline std::size_t float_hash_impl(float v)
@@ -124,19 +122,19 @@
         {
             int exp = 0;
 
- // The result of frexp is always between 0.5 and 1, so its
- // top bit will always be 1. Subtract by 0.5 to remove that.
- if(v >= 0) {
- v = boost::hash_detail::call_frexp(v, &exp) - T(0.5);
- }
- else {
- v = -boost::hash_detail::call_frexp(v, &exp) - T(0.5);
- exp = ~exp;
- }
+ v = boost::hash_detail::call_frexp(v, &exp);
 
- // TODO: Of course, this doesn't pass when hashing infinity or NaN.
- //BOOST_ASSERT(0 <= v && v < 0.5);
+ // A postive value is easier to hash, so combine the
+ // sign with the exponent.
+ if(v < 0) {
+ v = -v;
+ exp += limits<T>::max_exponent -
+ limits<T>::min_exponent;
+ }
 
+ // The result of frexp is always between 0.5 and 1, so its
+ // top bit will always be 1. Subtract by 0.5 to remove that.
+ v -= T(0.5);
             v = boost::hash_detail::call_ldexp(v,
                     limits<std::size_t>::digits + 1);
             std::size_t seed = static_cast<std::size_t>(v);
@@ -150,7 +148,8 @@
 
             for(std::size_t i = 0; i != length; ++i)
             {
- v = boost::hash_detail::call_ldexp(v, limits<std::size_t>::digits);
+ v = boost::hash_detail::call_ldexp(v,
+ limits<std::size_t>::digits);
                 std::size_t part = static_cast<std::size_t>(v);
                 v -= part;
                 hash_float_combine(seed, part);

Modified: branches/hash/libs/asio/test/socket_base.cpp
==============================================================================
--- branches/hash/libs/asio/test/socket_base.cpp (original)
+++ branches/hash/libs/asio/test/socket_base.cpp 2007-10-21 04:54:36 EDT (Sun, 21 Oct 2007)
@@ -373,16 +373,16 @@
   socket_base::send_low_watermark send_low_watermark1(4096);
   BOOST_CHECK(send_low_watermark1.value() == 4096);
   tcp_sock.set_option(send_low_watermark1, ec);
-#if defined(WIN32) || defined(__linux__) || defined(__sun) || defined(__hpux)
- BOOST_CHECK(!!ec); // Not supported on Windows, Linux, Solaris or HP-UX.
+#if defined(WIN32) || defined(__linux__) || defined(__sun)
+ BOOST_CHECK(!!ec); // Not supported on Windows, Linux or Solaris.
 #else
   BOOST_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
 #endif
 
   socket_base::send_low_watermark send_low_watermark2;
   tcp_sock.get_option(send_low_watermark2, ec);
-#if defined(WIN32) || defined(__sun) || defined(__hpux)
- BOOST_CHECK(!!ec); // Not supported on Windows, Solaris or HP-UX.
+#if defined(WIN32) || defined(__sun)
+ BOOST_CHECK(!!ec); // Not supported on Windows or Solaris.
 #elif defined(__linux__)
   BOOST_CHECK(!ec); // Not supported on Linux but can get value.
 #else
@@ -393,16 +393,16 @@
   socket_base::send_low_watermark send_low_watermark3(8192);
   BOOST_CHECK(send_low_watermark3.value() == 8192);
   tcp_sock.set_option(send_low_watermark3, ec);
-#if defined(WIN32) || defined(__linux__) || defined(__sun) || defined(__hpux)
- BOOST_CHECK(!!ec); // Not supported on Windows, Linux, Solaris or HP-UX.
+#if defined(WIN32) || defined(__linux__) || defined(__sun)
+ BOOST_CHECK(!!ec); // Not supported on Windows, Linux or Solaris.
 #else
   BOOST_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
 #endif
 
   socket_base::send_low_watermark send_low_watermark4;
   tcp_sock.get_option(send_low_watermark4, ec);
-#if defined(WIN32) || defined(__sun) || defined(__hpux)
- BOOST_CHECK(!!ec); // Not supported on Windows, Solaris or HP-UX.
+#if defined(WIN32) || defined(__sun)
+ BOOST_CHECK(!!ec); // Not supported on Windows or Solaris.
 #elif defined(__linux__)
   BOOST_CHECK(!ec); // Not supported on Linux but can get value.
 #else
@@ -437,16 +437,16 @@
   socket_base::receive_low_watermark receive_low_watermark1(4096);
   BOOST_CHECK(receive_low_watermark1.value() == 4096);
   tcp_sock.set_option(receive_low_watermark1, ec);
-#if defined(WIN32) || defined(__sun) || defined(__hpux)
- BOOST_CHECK(!!ec); // Not supported on Windows, Solaris or HP-UX.
+#if defined(WIN32) || defined(__sun)
+ BOOST_CHECK(!!ec); // Not supported on Windows or Solaris.
 #else
   BOOST_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
 #endif
 
   socket_base::receive_low_watermark receive_low_watermark2;
   tcp_sock.get_option(receive_low_watermark2, ec);
-#if defined(WIN32) || defined(__sun) || defined(__hpux)
- BOOST_CHECK(!!ec); // Not supported on Windows, Solaris or HP-UX.
+#if defined(WIN32) || defined(__sun)
+ BOOST_CHECK(!!ec); // Not supported on Windows or Solaris.
 #else
   BOOST_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
   BOOST_CHECK(receive_low_watermark2.value() == 4096);
@@ -455,16 +455,16 @@
   socket_base::receive_low_watermark receive_low_watermark3(8192);
   BOOST_CHECK(receive_low_watermark3.value() == 8192);
   tcp_sock.set_option(receive_low_watermark3, ec);
-#if defined(WIN32) || defined(__sun) || defined(__hpux)
- BOOST_CHECK(!!ec); // Not supported on Windows, Solaris or HP-UX.
+#if defined(WIN32) || defined(__sun)
+ BOOST_CHECK(!!ec); // Not supported on Windows or Solaris.
 #else
   BOOST_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
 #endif
 
   socket_base::receive_low_watermark receive_low_watermark4;
   tcp_sock.get_option(receive_low_watermark4, ec);
-#if defined(WIN32) || defined(__sun) || defined(__hpux)
- BOOST_CHECK(!!ec); // Not supported on Windows, Solaris or HP-UX.
+#if defined(WIN32) || defined(__sun)
+ BOOST_CHECK(!!ec); // Not supported on Windows or Solaris.
 #else
   BOOST_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
   BOOST_CHECK(receive_low_watermark4.value() == 8192);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk