update boost

This commit is contained in:
2023-11-24 12:56:13 -06:00
parent cfc99971af
commit 19d727037a
9260 changed files with 849256 additions and 299957 deletions

View File

@@ -26,7 +26,7 @@ It also provides automatic destruction of non-deallocated objects.
#endif
// The following code might be put into some Boost.Config header in a later revision
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
# pragma option push -w-inl
#endif
@@ -280,7 +280,7 @@ object_pool<T, UserAllocator>::~object_pool()
} // namespace boost
// The following code might be put into some Boost.Config header in a later revision
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
# pragma option pop
#endif

View File

@@ -26,6 +26,8 @@
#include <boost/pool/poolfwd.hpp>
// std::numeric_limits
#include <boost/limits.hpp>
// boost::integer::static_lcm
#include <boost/integer/common_factor_ct.hpp>
// boost::simple_segregated_storage
@@ -355,6 +357,12 @@ class pool: protected simple_segregated_storage < typename UserAllocator::size_t
return s;
}
size_type max_chunks() const
{ //! Calculated maximum number of memory chunks that can be allocated in a single call by this Pool.
size_type POD_size = integer::static_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type);
return (std::numeric_limits<size_type>::max() - POD_size) / alloc_size();
}
static void * & nextof(void * const ptr)
{ //! \returns Pointer dereferenced.
//! (Provided and used for the sake of code readability :)
@@ -375,6 +383,8 @@ class pool: protected simple_segregated_storage < typename UserAllocator::size_t
//! the first time that object needs to allocate system memory.
//! The default is 32. This parameter may not be 0.
//! \param nmax_size is the maximum number of chunks to allocate in one block.
set_next_size(nnext_size);
set_max_size(nmax_size);
}
~pool()
@@ -398,8 +408,8 @@ class pool: protected simple_segregated_storage < typename UserAllocator::size_t
}
void set_next_size(const size_type nnext_size)
{ //! Set number of chunks to request from the system the next time that object needs to allocate system memory. This value should never be set to 0.
//! \returns nnext_size.
next_size = start_size = nnext_size;
BOOST_USING_STD_MIN();
next_size = start_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(nnext_size, max_chunks());
}
size_type get_max_size() const
{ //! \returns max_size.
@@ -407,7 +417,8 @@ class pool: protected simple_segregated_storage < typename UserAllocator::size_t
}
void set_max_size(const size_type nmax_size)
{ //! Set max_size.
max_size = nmax_size;
BOOST_USING_STD_MIN();
max_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(nmax_size, max_chunks());
}
size_type get_requested_size() const
{ //! \returns the requested size passed into the constructor.
@@ -708,9 +719,9 @@ void * pool<UserAllocator>::malloc_need_resize()
BOOST_USING_STD_MIN();
if(!max_size)
next_size <<= 1;
set_next_size(next_size << 1);
else if( next_size*partition_size/requested_size < max_size)
next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size));
// initialize it,
store().add_block(node.begin(), node.element_size(), partition_size);
@@ -748,9 +759,9 @@ void * pool<UserAllocator>::ordered_malloc_need_resize()
BOOST_USING_STD_MIN();
if(!max_size)
next_size <<= 1;
set_next_size(next_size << 1);
else if( next_size*partition_size/requested_size < max_size)
next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size));
// initialize it,
// (we can use "add_block" here because we know that
@@ -792,6 +803,8 @@ void * pool<UserAllocator>::ordered_malloc(const size_type n)
{ //! Gets address of a chunk n, allocating new memory if not already available.
//! \returns Address of chunk n if allocated ok.
//! \returns 0 if not enough memory for n chunks.
if (n > max_chunks())
return 0;
const size_type partition_size = alloc_size();
const size_type total_req_size = n * requested_size;
@@ -840,9 +853,9 @@ void * pool<UserAllocator>::ordered_malloc(const size_type n)
BOOST_USING_STD_MIN();
if(!max_size)
next_size <<= 1;
set_next_size(next_size << 1);
else if( next_size*partition_size/requested_size < max_size)
next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size));
// insert it into the list,
// handle border case.

View File

@@ -94,7 +94,7 @@ STLport (with any compiler), ver. 4.0 and earlier.
// The following code will be put into Boost.Config in a later revision
#if defined(_RWSTD_VER) || defined(__SGI_STL_PORT) || \
BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582))
#define BOOST_NO_PROPER_STL_DEALLOCATE
#endif

View File

@@ -328,6 +328,19 @@ void * simple_segregated_storage<SizeType>::try_malloc_n(
void * & start, size_type n, const size_type partition_size)
{
void * iter = nextof(start);
if (n == 1)
{
void * next = nextof(iter);
if (next != static_cast<char *>(iter) + partition_size)
{
start = iter;
return 0;
}
else
{
return iter;
}
}
while (--n != 0)
{
void * next = nextof(iter);