updated boost on windows

This commit is contained in:
Bassem Girgis
2019-08-13 21:48:48 -05:00
parent 7d77d485fd
commit b40a3bee82
5162 changed files with 473027 additions and 116452 deletions

View File

@@ -417,8 +417,12 @@ BOOST_MP_FORCEINLINE typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<Mi
static const limb_type one = 1;
if(!result.sign() && (result.limbs()[0] < cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::max_limb_value))
++result.limbs()[0];
else if(result.sign() && result.limbs()[0])
else if (result.sign() && result.limbs()[0])
{
--result.limbs()[0];
if (!result.limbs()[0])
result.sign(false);
}
else
eval_add(result, one);
}
@@ -429,7 +433,7 @@ BOOST_MP_FORCEINLINE typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<Mi
static const limb_type one = 1;
if(!result.sign() && result.limbs()[0])
--result.limbs()[0];
else if(result.sign() && (result.limbs()[0] < cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::max_limb_value))
else if (result.sign() && (result.limbs()[0] < cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::max_limb_value))
++result.limbs()[0];
else
eval_subtract(result, one);

View File

@@ -435,7 +435,7 @@ inline typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBit
if(!s)
return;
#if defined(BOOST_LITTLE_ENDIAN) && defined(BOOST_MP_USE_LIMB_SHIFT)
#if BOOST_ENDIAN_LITTLE_BYTE && defined(BOOST_MP_USE_LIMB_SHIFT)
static const limb_type limb_shift_mask = cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits - 1;
static const limb_type byte_shift_mask = CHAR_BIT - 1;
if((s & limb_shift_mask) == 0)
@@ -446,7 +446,7 @@ inline typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBit
{
left_shift_byte(result, s);
}
#elif defined(BOOST_LITTLE_ENDIAN)
#elif BOOST_ENDIAN_LITTLE_BYTE
static const limb_type byte_shift_mask = CHAR_BIT - 1;
if((s & byte_shift_mask) == 0)
{
@@ -562,14 +562,14 @@ inline typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBit
if(!s)
return;
#if defined(BOOST_LITTLE_ENDIAN) && defined(BOOST_MP_USE_LIMB_SHIFT)
#if BOOST_ENDIAN_LITTLE_BYTE && defined(BOOST_MP_USE_LIMB_SHIFT)
static const limb_type limb_shift_mask = cpp_int_backend<MinBits1, MaxBits1, signed_magnitude, Checked1, Allocator1>::limb_bits - 1;
static const limb_type byte_shift_mask = CHAR_BIT - 1;
if((s & limb_shift_mask) == 0)
right_shift_limb(result, s);
else if((s & byte_shift_mask) == 0)
right_shift_byte(result, s);
#elif defined(BOOST_LITTLE_ENDIAN)
#elif BOOST_ENDIAN_LITTLE_BYTE
static const limb_type byte_shift_mask = CHAR_BIT - 1;
if((s & byte_shift_mask) == 0)
right_shift_byte(result, s);
@@ -595,14 +595,14 @@ inline typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBit
if(is_neg)
eval_increment(result);
#if defined(BOOST_LITTLE_ENDIAN) && defined(BOOST_MP_USE_LIMB_SHIFT)
#if BOOST_ENDIAN_LITTLE_BYTE && defined(BOOST_MP_USE_LIMB_SHIFT)
static const limb_type limb_shift_mask = cpp_int_backend<MinBits1, MaxBits1, signed_magnitude, Checked1, Allocator1>::limb_bits - 1;
static const limb_type byte_shift_mask = CHAR_BIT - 1;
if((s & limb_shift_mask) == 0)
right_shift_limb(result, s);
else if((s & byte_shift_mask) == 0)
right_shift_byte(result, s);
#elif defined(BOOST_LITTLE_ENDIAN)
#elif BOOST_ENDIAN_LITTLE_BYTE
static const limb_type byte_shift_mask = CHAR_BIT - 1;
if((s & byte_shift_mask) == 0)
right_shift_byte(result, s);

View File

@@ -61,8 +61,7 @@ namespace boost {
// Check for overflow bits:
//
bit_location = sizeof(local_limb_type) * CHAR_BIT - bit_location;
bits >>= bit_location;
if(bits)
if((bit_location < sizeof(bits)*CHAR_BIT) && (bits >>= bit_location))
val.resize(2, 2); // May throw!
}
}
@@ -170,7 +169,7 @@ namespace boost {
import_bits(
number<cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>& val, T* i, T* j, unsigned chunk_size = 0, bool msv_first = true)
{
#ifdef BOOST_LITTLE_ENDIAN
#if BOOST_ENDIAN_LITTLE_BYTE
if(((chunk_size % CHAR_BIT) == 0) && !msv_first)
return detail::import_bits_fast(val, i, j, chunk_size);
#endif

View File

@@ -28,6 +28,8 @@ void check_in_range(const CppInt& val, const mpl::int_<checked>&)
typedef typename boost::multiprecision::detail::canonical<R, CppInt>::type cast_type;
if(val.sign())
{
if(boost::is_signed<R>::value == false)
BOOST_THROW_EXCEPTION(std::range_error("Attempt to assign a negative value to an unsigned type."));
if(val.compare(static_cast<cast_type>((std::numeric_limits<R>::min)())) < 0)
BOOST_THROW_EXCEPTION(std::overflow_error("Could not convert to the target type - -value is out of range."));
}
@@ -59,17 +61,71 @@ inline Integer negate_integer(Integer i, const mpl::false_&) BOOST_NOEXCEPT
template <class R, unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1>
inline typename enable_if_c<is_integral<R>::value && !is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value, void>::type
eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& backend) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value))
eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& backend)
{
typedef mpl::int_<Checked1> checked_type;
check_in_range<R>(backend, checked_type());
*result = static_cast<R>(backend.limbs()[0]);
unsigned shift = cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits;
for(unsigned i = 1; (i < backend.size()) && (shift < static_cast<unsigned>(std::numeric_limits<R>::digits)); ++i)
if (std::numeric_limits<R>::digits < cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits)
{
*result += static_cast<R>(backend.limbs()[i]) << shift;
shift += cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits;
if ((backend.sign() && boost::is_signed<R>::value) && (1 + static_cast<boost::multiprecision::limb_type>((std::numeric_limits<R>::max)()) <= backend.limbs()[0]))
{
*result = (std::numeric_limits<R>::min)();
return;
}
else if (boost::is_signed<R>::value && !backend.sign() && static_cast<boost::multiprecision::limb_type>((std::numeric_limits<R>::max)()) <= backend.limbs()[0])
{
*result = (std::numeric_limits<R>::max)();
return;
}
else
*result = static_cast<R>(backend.limbs()[0]);
}
else
*result = static_cast<R>(backend.limbs()[0]);
unsigned shift = cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits;
unsigned i = 1;
if (std::numeric_limits<R>::digits > cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits)
{
while ((i < backend.size()) && (shift < static_cast<unsigned>(std::numeric_limits<R>::digits - cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits)))
{
*result += static_cast<R>(backend.limbs()[i]) << shift;
shift += cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits;
++i;
}
//
// We have one more limb to extract, but may not need all the bits, so treat this as a special case:
//
if (i < backend.size())
{
static const limb_type mask = std::numeric_limits<R>::digits - shift == cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits ?
~static_cast<limb_type>(0) : (static_cast<limb_type>(1u) << (std::numeric_limits<R>::digits - shift)) - 1;
*result += (static_cast<R>(backend.limbs()[i]) & mask) << shift;
if ((static_cast<R>(backend.limbs()[i]) & static_cast<limb_type>(~mask)) || (i + 1 < backend.size()))
{
// Overflow:
if (backend.sign())
{
check_is_negative(boost::is_signed<R>());
*result = (std::numeric_limits<R>::min)();
}
else if(boost::is_signed<R>::value)
*result = (std::numeric_limits<R>::max)();
return;
}
}
}
else if (backend.size() > 1)
{
// Overflow:
if (backend.sign())
{
check_is_negative(boost::is_signed<R>());
*result = (std::numeric_limits<R>::min)();
}
else if(boost::is_signed<R>::value)
*result = (std::numeric_limits<R>::max)();
return;
}
if(backend.sign())
{
@@ -551,6 +607,7 @@ inline typename enable_if_c<
{
if(val.isneg())
{
check_is_negative(mpl::bool_<boost::is_signed<R>::value || (number_category<R>::value == number_kind_floating_point)>());
if(static_cast<common_type>(*val.limbs()) > -static_cast<common_type>((std::numeric_limits<R>::min)()))
conversion_overflow(typename cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::checked_type());
*result = (std::numeric_limits<R>::min)();
@@ -558,7 +615,7 @@ inline typename enable_if_c<
else
{
conversion_overflow(typename cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::checked_type());
*result = (std::numeric_limits<R>::max)();
*result = boost::is_signed<R>::value ? (std::numeric_limits<R>::max)() : static_cast<R>(*val.limbs());
}
}
else
@@ -566,7 +623,7 @@ inline typename enable_if_c<
*result = static_cast<R>(*val.limbs());
if(val.isneg())
{
check_is_negative(mpl::bool_<is_signed_number<R>::value || (number_category<R>::value == number_kind_floating_point)>());
check_is_negative(mpl::bool_<boost::is_signed<R>::value || (number_category<R>::value == number_kind_floating_point)>());
*result = negate_integer(*result, mpl::bool_<is_signed_number<R>::value || (number_category<R>::value == number_kind_floating_point)>());
}
}
@@ -584,7 +641,7 @@ inline typename enable_if_c<
if(std::numeric_limits<R>::is_specialized && (static_cast<common_type>(*val.limbs()) > static_cast<common_type>((std::numeric_limits<R>::max)())))
{
conversion_overflow(typename cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::checked_type());
*result = (std::numeric_limits<R>::max)();
*result = boost::is_signed<R>::value ? (std::numeric_limits<R>::max)() : static_cast<R>(*val.limbs());
}
else
*result = static_cast<R>(*val.limbs());

View File

@@ -64,10 +64,10 @@ inline typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBit
template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1>
inline void resize_for_carry(cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& /*result*/, unsigned /*required*/){}
template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1>
inline void resize_for_carry(cpp_int_backend<MinBits1, MaxBits1, SignType1, checked, void>& result, unsigned required)
template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, class Allocator1>
inline void resize_for_carry(cpp_int_backend<MinBits1, MaxBits1, SignType1, checked, Allocator1>& result, unsigned required)
{
if(result.size() != required)
if(result.size() < required)
result.resize(required, required);
}
@@ -136,7 +136,8 @@ inline typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBit
for(unsigned i = 0; i < as; ++i)
{
unsigned inner_limit = cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::variable ? bs : (std::min)(result.size() - i, bs);
for(unsigned j = 0; j < inner_limit; ++j)
unsigned j;
for(j = 0; j < inner_limit; ++j)
{
BOOST_ASSERT(i+j < result.size());
#if (!defined(__GLIBCXX__) && !defined(__GLIBCPP__)) || !BOOST_WORKAROUND(BOOST_GCC_VERSION, <= 50100)
@@ -156,9 +157,16 @@ inline typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBit
carry >>= cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits;
BOOST_ASSERT(carry <= (cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::max_limb_value));
}
resize_for_carry(result, as + bs); // May throw if checking is enabled
if(i + bs < result.size())
pr[i + bs] = static_cast<limb_type>(carry);
if(carry)
{
resize_for_carry(result, i + j + 1); // May throw if checking is enabled
if(i + j < result.size())
#ifdef __MSVC_RUNTIME_CHECKS
pr[i + j] = static_cast<limb_type>(carry & ~static_cast<limb_type>(0));
#else
pr[i + j] = static_cast<limb_type>(carry);
#endif
}
carry = 0;
}
result.normalize();
@@ -197,7 +205,7 @@ BOOST_MP_FORCEINLINE typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<Mi
}
else
{
#if defined(BOOST_LITTLE_ENDIAN) && !defined(BOOST_MP_TEST_NO_LE)
#if BOOST_ENDIAN_LITTLE_BYTE && !defined(BOOST_MP_TEST_NO_LE)
cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> t(val);
#else
cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> t;
@@ -258,7 +266,7 @@ inline typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBit
result.negate();
return;
}
#if defined(BOOST_LITTLE_ENDIAN) && !defined(BOOST_MP_TEST_NO_LE)
#if BOOST_ENDIAN_LITTLE_BYTE && !defined(BOOST_MP_TEST_NO_LE)
cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> t(val);
#else
cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> t;

View File

@@ -44,11 +44,12 @@ void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::false_ const&,
// Non-trivial.
// Non binary.
using boost::serialization::make_nvp;
bool s;
ar & s;
ar & make_nvp("sign", s);
std::size_t limb_count;
std::size_t byte_count;
ar & byte_count;
ar & make_nvp("byte-count", byte_count);
limb_count = byte_count / sizeof(limb_type) + ((byte_count % sizeof(limb_type)) ? 1 : 0);
val.resize(limb_count, limb_count);
limb_type* pl = val.limbs();
@@ -58,7 +59,7 @@ void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::false_ const&,
for(std::size_t j = 0; (j < sizeof(limb_type)) && byte_count; ++j)
{
unsigned char byte;
ar & byte;
ar & make_nvp("byte", byte);
pl[i] |= static_cast<limb_type>(byte) << (j * CHAR_BIT);
--byte_count;
}
@@ -74,12 +75,13 @@ void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::false_ const&,
// Non-trivial.
// Non binary.
using boost::serialization::make_nvp;
bool s = val.sign();
ar & s;
ar & make_nvp("sign", s);
limb_type* pl = val.limbs();
std::size_t limb_count = val.size();
std::size_t byte_count = limb_count * sizeof(limb_type);
ar & byte_count;
ar & make_nvp("byte-count", byte_count);
for(std::size_t i = 0; i < limb_count; ++i)
{
@@ -87,7 +89,7 @@ void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::false_ const&,
for(std::size_t j = 0; j < sizeof(limb_type); ++j)
{
unsigned char byte = static_cast<unsigned char>((l >> (j * CHAR_BIT)) & ((1u << CHAR_BIT) - 1));
ar & byte;
ar & make_nvp("byte", byte);
}
}
}
@@ -97,15 +99,16 @@ void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::true_ const&,
// Load.
// Trivial.
// Non binary.
using boost::serialization::make_nvp;
bool s;
typename Int::local_limb_type l = 0;
ar & s;
ar & make_nvp("sign", s);
std::size_t byte_count;
ar & byte_count;
ar & make_nvp("byte-count", byte_count);
for(std::size_t i = 0; i < byte_count; ++i)
{
unsigned char b;
ar & b;
ar & make_nvp("byte", b);
l |= static_cast<typename Int::local_limb_type>(b) << (i * CHAR_BIT);
}
*val.limbs() = l;
@@ -118,15 +121,16 @@ void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::true_ const&, m
// Store.
// Trivial.
// Non binary.
using boost::serialization::make_nvp;
bool s = val.sign();
typename Int::local_limb_type l = *val.limbs();
ar & s;
ar & make_nvp("sign", s);
std::size_t limb_count = sizeof(l);
ar & limb_count;
ar & make_nvp("byte-count", limb_count);
for(std::size_t i = 0; i < limb_count; ++i)
{
unsigned char b = static_cast<unsigned char>(static_cast<typename Int::local_limb_type>(l >> (i * CHAR_BIT)) & static_cast<typename Int::local_limb_type>((1u << CHAR_BIT) - 1));
ar & b;
ar & make_nvp("byte", b);
}
}
template <class Archive, class Int>