Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76593 - in sandbox/big_number: boost/multiprecision boost/multiprecision/detail libs/multiprecision/test
From: john_at_[hidden]
Date: 2012-01-20 12:15:24


Author: johnmaddock
Date: 2012-01-20 12:15:22 EST (Fri, 20 Jan 2012)
New Revision: 76593
URL: http://svn.boost.org/trac/boost/changeset/76593

Log:
Fix Linux 64 failures
Text files modified:
   sandbox/big_number/boost/multiprecision/detail/mp_number_base.hpp | 4 ++--
   sandbox/big_number/boost/multiprecision/fixed_int.hpp | 10 +++++-----
   sandbox/big_number/boost/multiprecision/gmp.hpp | 9 +++++++--
   sandbox/big_number/boost/multiprecision/mpfr.hpp | 4 ++--
   sandbox/big_number/boost/multiprecision/tommath.hpp | 17 +++++++++++------
   sandbox/big_number/libs/multiprecision/test/test_float_io.cpp | 2 +-
   6 files changed, 28 insertions(+), 18 deletions(-)

Modified: sandbox/big_number/boost/multiprecision/detail/mp_number_base.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/detail/mp_number_base.hpp (original)
+++ sandbox/big_number/boost/multiprecision/detail/mp_number_base.hpp 2012-01-20 12:15:22 EST (Fri, 20 Jan 2012)
@@ -439,14 +439,14 @@
 
    if(fixed || (!scientific && (my_exp >= -4) && (my_exp < digits)))
    {
- if(1 + my_exp > str.size())
+ if(1 + my_exp > static_cast<boost::intmax_t>(str.size()))
       {
          // Just pad out the end with zeros:
          str.append(static_cast<std::string::size_type>(1 + my_exp - str.size()), '0');
          if(showpoint || fixed)
             str.append(".");
       }
- else if(my_exp + 1 < str.size())
+ else if(my_exp + 1 < static_cast<boost::intmax_t>(str.size()))
       {
          if(my_exp < 0)
          {

Modified: sandbox/big_number/boost/multiprecision/fixed_int.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/fixed_int.hpp (original)
+++ sandbox/big_number/boost/multiprecision/fixed_int.hpp 2012-01-20 12:15:22 EST (Fri, 20 Jan 2012)
@@ -34,7 +34,7 @@
    BOOST_STATIC_CONSTANT(limb_type, max_limb_value = ~static_cast<limb_type>(0u));
    BOOST_STATIC_CONSTANT(limb_type, upper_limb_mask = (Bits % limb_bits ? (1 << (Bits % limb_bits)) - 1 : max_limb_value));
    BOOST_STATIC_CONSTANT(limb_type, upper_limb_not_mask = ~upper_limb_mask);
- BOOST_STATIC_CONSTANT(limb_type, sign_bit_mask = 1 << ((Bits % limb_bits ? Bits % limb_bits : limb_bits) - 1));
+ BOOST_STATIC_CONSTANT(limb_type, sign_bit_mask = 1u << ((Bits % limb_bits ? Bits % limb_bits : limb_bits) - 1));
    typedef boost::array<limb_type, limb_count> data_type;
 
    fixed_int(){}
@@ -53,7 +53,7 @@
    fixed_int& operator = (limb_type i)
    {
       m_value[limb_count - 1] = i;
- for(int j = limb_count - 2; j >= 0; --j)
+ for(int j = static_cast<int>(limb_count) - 2; j >= 0; --j)
          m_value[j] = 0;
       m_value[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
       return *this;
@@ -62,7 +62,7 @@
    {
       m_value[limb_count - 1] = i;
       // sign extend:
- for(int j = limb_count - 2; j >= 0; --j)
+ for(int j = static_cast<int>(limb_count) - 2; j >= 0; --j)
          m_value[j] = i < 0 ? max_limb_value : 0;
       m_value[0] &= fixed_int<Bits, Signed>::upper_limb_mask;
       return *this;
@@ -400,7 +400,7 @@
       + 1uLL + static_cast<double_limb_type>(~o);
    result.data()[fixed_int<Bits, Signed>::limb_count - 1] = static_cast<limb_type>(carry);
    carry >>= fixed_int<Bits, Signed>::limb_bits;
- for(int i = fixed_int<Bits, Signed>::limb_count - 2; i >= 0; --i)
+ for(int i = static_cast<int>(fixed_int<Bits, Signed>::limb_count) - 2; i >= 0; --i)
    {
       carry += static_cast<double_limb_type>(result.data()[i]) + 0xFFFFFFFF;
       result.data()[i] = static_cast<limb_type>(carry);
@@ -713,7 +713,7 @@
       r = x.data()[fixed_int<Bits, Signed>::limb_count - 1] % y.data()[fixed_int<Bits, Signed>::limb_count - 1];
       return;
    }
- else if(r_order == fixed_int<Bits, Signed>::limb_count - 2)
+ else if(r_order == static_cast<int>(fixed_int<Bits, Signed>::limb_count) - 2)
    {
       double_limb_type a, b;
       a = (static_cast<double_limb_type>(r.data()[r_order]) << fixed_int<Bits, Signed>::limb_bits) | r.data()[r_order + 1];

Modified: sandbox/big_number/boost/multiprecision/gmp.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/gmp.hpp (original)
+++ sandbox/big_number/boost/multiprecision/gmp.hpp 2012-01-20 12:15:22 EST (Fri, 20 Jan 2012)
@@ -1790,6 +1790,11 @@
    typedef boost::multiprecision::mp_number<boost::multiprecision::gmp_float<Digits10> > number_type;
 public:
    BOOST_STATIC_CONSTEXPR bool is_specialized = true;
+ //
+ // min and max values chosen so as to not cause segfaults when calling
+ // mpf_get_str on 64-bit Linux builds. Possibly we could use larger
+ // exponent values elsewhere.
+ //
    BOOST_STATIC_CONSTEXPR number_type (min)() BOOST_MP_NOEXCEPT
    {
       initializer.do_nothing();
@@ -1798,7 +1803,7 @@
       {
          value.first = true;
          value.second = 1;
- mpf_div_2exp(value.second.backend().data(), value.second.backend().data(), LONG_MAX);
+ mpf_div_2exp(value.second.backend().data(), value.second.backend().data(), (std::numeric_limits<mp_exp_t>::max)() / 64 + 1);
       }
       return value.second;
    }
@@ -1810,7 +1815,7 @@
       {
          value.first = true;
          value.second = 1;
- mpf_mul_2exp(value.second.backend().data(), value.second.backend().data(), LONG_MAX - 1);
+ mpf_mul_2exp(value.second.backend().data(), value.second.backend().data(), (std::numeric_limits<mp_exp_t>::max)() / 64 + 1);
       }
       return value.second;
    }

Modified: sandbox/big_number/boost/multiprecision/mpfr.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/mpfr.hpp (original)
+++ sandbox/big_number/boost/multiprecision/mpfr.hpp 2012-01-20 12:15:22 EST (Fri, 20 Jan 2012)
@@ -800,12 +800,12 @@
 }
 #ifdef _MPFR_H_HAVE_INTMAX_T
 template <unsigned digits10>
-inline void convert_to(boost::uintmax_t* result, const mpfr_float_backend<digits10>& val)
+inline void convert_to(unsigned long long* result, const mpfr_float_backend<digits10>& val)
 {
    *result = mpfr_get_uj(val.data(), GMP_RNDN);
 }
 template <unsigned digits10>
-inline void convert_to(boost::intmax_t* result, const mpfr_float_backend<digits10>& val)
+inline void convert_to(long long* result, const mpfr_float_backend<digits10>& val)
 {
    *result = mpfr_get_sj(val.data(), GMP_RNDN);
 }

Modified: sandbox/big_number/boost/multiprecision/tommath.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/tommath.hpp (original)
+++ sandbox/big_number/boost/multiprecision/tommath.hpp 2012-01-20 12:15:22 EST (Fri, 20 Jan 2012)
@@ -33,9 +33,9 @@
 
 struct tommath_int
 {
- typedef mpl::list<long, long long> signed_types;
- typedef mpl::list<unsigned long, unsigned long long> unsigned_types;
- typedef mpl::list<long double> float_types;
+ typedef mpl::list<boost::int32_t, long long> signed_types;
+ typedef mpl::list<boost::uint32_t, unsigned long long> unsigned_types;
+ typedef mpl::list<long double> float_types;
 
    tommath_int()
    {
@@ -78,15 +78,20 @@
          detail::check_tommath_result(mp_neg(&m_data, &m_data));
       return *this;
    }
- tommath_int& operator = (unsigned long i)
+ //
+ // Note that although mp_set_int takes an unsigned long as an argument
+ // it only sets the first 32-bits to the result, and ignores the rest.
+ // So use uint32_t as the largest type to pass to this function.
+ //
+ tommath_int& operator = (boost::uint32_t i)
    {
       detail::check_tommath_result((mp_set_int(&m_data, i)));
       return *this;
    }
- tommath_int& operator = (long i)
+ tommath_int& operator = (boost::int32_t i)
    {
       bool neg = i < 0;
- *this = static_cast<unsigned long>(std::abs(i));
+ *this = static_cast<boost::uint32_t>(std::abs(i));
       if(neg)
          detail::check_tommath_result(mp_neg(&m_data, &m_data));
       return *this;

Modified: sandbox/big_number/libs/multiprecision/test/test_float_io.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/test_float_io.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/test_float_io.cpp 2012-01-20 12:15:22 EST (Fri, 20 Jan 2012)
@@ -93,7 +93,7 @@
    }};
 
    boost::array<boost::array<const char*, 13 * 9>, 40> string_data = {{
-#include "libs/multiprecision/libs/string_data.ipp"
+#include "libs/multiprecision/test/string_data.ipp"
    }};
 
    double num = 123456789.0;


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