|
| 1 | +Edited filepath to reflect the file tree within ceph |
| 2 | + |
| 3 | +Link: https://620468.bugs.gentoo.org/attachment.cgi?id=475060&action=diff&format=raw&headers=1 |
| 4 | +--- a/src/boost/boost/pool/pool.hpp |
| 5 | ++++ a/src/boost/boost/pool/pool.hpp |
| 6 | +@@ -26,6 +26,8 @@ |
| 7 | + |
| 8 | + #include <boost/pool/poolfwd.hpp> |
| 9 | + |
| 10 | ++// std::numeric_limits |
| 11 | ++#include <boost/limits.hpp> |
| 12 | + // boost::integer::static_lcm |
| 13 | + #include <boost/integer/common_factor_ct.hpp> |
| 14 | + // boost::simple_segregated_storage |
| 15 | +@@ -355,6 +357,15 @@ class pool: protected simple_segregated_storage < typename UserAllocator::size_t |
| 16 | + return s; |
| 17 | + } |
| 18 | + |
| 19 | ++ size_type max_chunks() const |
| 20 | ++ { //! Calculated maximum number of memory chunks that can be allocated in a single call by this Pool. |
| 21 | ++ size_type partition_size = alloc_size(); |
| 22 | ++ size_type POD_size = integer::static_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type); |
| 23 | ++ size_type max_chunks = (std::numeric_limits<size_type>::max() - POD_size) / alloc_size(); |
| 24 | ++ |
| 25 | ++ return max_chunks; |
| 26 | ++ } |
| 27 | ++ |
| 28 | + static void * & nextof(void * const ptr) |
| 29 | + { //! \returns Pointer dereferenced. |
| 30 | + //! (Provided and used for the sake of code readability :) |
| 31 | +@@ -375,6 +386,8 @@ class pool: protected simple_segregated_storage < typename UserAllocator::size_t |
| 32 | + //! the first time that object needs to allocate system memory. |
| 33 | + //! The default is 32. This parameter may not be 0. |
| 34 | + //! \param nmax_size is the maximum number of chunks to allocate in one block. |
| 35 | ++ set_next_size(nnext_size); |
| 36 | ++ set_max_size(nmax_size); |
| 37 | + } |
| 38 | + |
| 39 | + ~pool() |
| 40 | +@@ -398,8 +411,8 @@ class pool: protected simple_segregated_storage < typename UserAllocator::size_t |
| 41 | + } |
| 42 | + void set_next_size(const size_type nnext_size) |
| 43 | + { //! 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. |
| 44 | +- //! \returns nnext_size. |
| 45 | +- next_size = start_size = nnext_size; |
| 46 | ++ BOOST_USING_STD_MIN(); |
| 47 | ++ next_size = start_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(nnext_size, max_chunks()); |
| 48 | + } |
| 49 | + size_type get_max_size() const |
| 50 | + { //! \returns max_size. |
| 51 | +@@ -407,7 +420,8 @@ class pool: protected simple_segregated_storage < typename UserAllocator::size_t |
| 52 | + } |
| 53 | + void set_max_size(const size_type nmax_size) |
| 54 | + { //! Set max_size. |
| 55 | +- max_size = nmax_size; |
| 56 | ++ BOOST_USING_STD_MIN(); |
| 57 | ++ max_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(nmax_size, max_chunks()); |
| 58 | + } |
| 59 | + size_type get_requested_size() const |
| 60 | + { //! \returns the requested size passed into the constructor. |
| 61 | +@@ -708,9 +722,9 @@ void * pool<UserAllocator>::malloc_need_resize() |
| 62 | + |
| 63 | + BOOST_USING_STD_MIN(); |
| 64 | + if(!max_size) |
| 65 | +- next_size <<= 1; |
| 66 | ++ set_next_size(next_size << 1); |
| 67 | + else if( next_size*partition_size/requested_size < max_size) |
| 68 | +- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size); |
| 69 | ++ set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size)); |
| 70 | + |
| 71 | + // initialize it, |
| 72 | + store().add_block(node.begin(), node.element_size(), partition_size); |
| 73 | +@@ -748,9 +762,9 @@ void * pool<UserAllocator>::ordered_malloc_need_resize() |
| 74 | + |
| 75 | + BOOST_USING_STD_MIN(); |
| 76 | + if(!max_size) |
| 77 | +- next_size <<= 1; |
| 78 | ++ set_next_size(next_size << 1); |
| 79 | + else if( next_size*partition_size/requested_size < max_size) |
| 80 | +- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size); |
| 81 | ++ set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size)); |
| 82 | + |
| 83 | + // initialize it, |
| 84 | + // (we can use "add_block" here because we know that |
| 85 | +@@ -792,6 +806,8 @@ void * pool<UserAllocator>::ordered_malloc(const size_type n) |
| 86 | + { //! Gets address of a chunk n, allocating new memory if not already available. |
| 87 | + //! \returns Address of chunk n if allocated ok. |
| 88 | + //! \returns 0 if not enough memory for n chunks. |
| 89 | ++ if (n > max_chunks()) |
| 90 | ++ return 0; |
| 91 | + |
| 92 | + const size_type partition_size = alloc_size(); |
| 93 | + const size_type total_req_size = n * requested_size; |
| 94 | +@@ -840,9 +856,9 @@ void * pool<UserAllocator>::ordered_malloc(const size_type n) |
| 95 | + |
| 96 | + BOOST_USING_STD_MIN(); |
| 97 | + if(!max_size) |
| 98 | +- next_size <<= 1; |
| 99 | ++ set_next_size(next_size << 1); |
| 100 | + else if( next_size*partition_size/requested_size < max_size) |
| 101 | +- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size); |
| 102 | ++ set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size)); |
| 103 | + |
| 104 | + // insert it into the list, |
| 105 | + // handle border case. |
0 commit comments