From 733b5d5ae2c5d625211e2985ac25728ac3f54883 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Mon, 21 Mar 2016 15:45:20 +0900 Subject: Imported Upstream version 1.58.0 Change-Id: If0072143aa26874812e0db6872e1efb10a3e5e94 Signed-off-by: DongHun Kwak --- boost/interprocess/segment_manager.hpp | 84 +++++++++++++++++----------------- 1 file changed, 43 insertions(+), 41 deletions(-) (limited to 'boost/interprocess/segment_manager.hpp') diff --git a/boost/interprocess/segment_manager.hpp b/boost/interprocess/segment_manager.hpp index 87c0041cf4..d00f17716b 100644 --- a/boost/interprocess/segment_manager.hpp +++ b/boost/interprocess/segment_manager.hpp @@ -11,19 +11,24 @@ #ifndef BOOST_INTERPROCESS_SEGMENT_MANAGER_HPP #define BOOST_INTERPROCESS_SEGMENT_MANAGER_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif +# +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include -#include +#include #include #include #include +#include #include #include #include @@ -34,10 +39,12 @@ #include #include #include +// container/detail +#include +#include +// std #include //std::size_t -#include //char_traits -#include //std::nothrow -#include //std::pair +#include #include #ifndef BOOST_NO_EXCEPTIONS #include @@ -117,7 +124,7 @@ class segment_manager_base //!Allocates nbytes bytes. This function is only used in //!single-segment management. Never throws - void * allocate (size_type nbytes, std::nothrow_t) + void * allocate (size_type nbytes, const std::nothrow_t &) { return MemoryAlgorithm::allocate(nbytes); } #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) @@ -147,13 +154,13 @@ class segment_manager_base //!Allocates n_elements of elem_bytes bytes. //!Non-throwing version. chain.size() is not increased on failure. - void allocate_many(std::nothrow_t, size_type elem_bytes, size_type n_elements, multiallocation_chain &chain) + void allocate_many(const std::nothrow_t &, size_type elem_bytes, size_type n_elements, multiallocation_chain &chain) { MemoryAlgorithm::allocate_many(elem_bytes, n_elements, chain); } //!Allocates n_elements, each one of //!element_lengths[i]*sizeof_element bytes. //!Non-throwing version. chain.size() is not increased on failure. - void allocate_many(std::nothrow_t, const size_type *elem_sizes, size_type n_elements, size_type sizeof_element, multiallocation_chain &chain) + void allocate_many(const std::nothrow_t &, const size_type *elem_sizes, size_type n_elements, size_type sizeof_element, multiallocation_chain &chain) { MemoryAlgorithm::allocate_many(elem_sizes, n_elements, sizeof_element, chain); } //!Deallocates all elements contained in chain. @@ -175,7 +182,7 @@ class segment_manager_base //!Allocates nbytes bytes. This function is only used in //!single-segment management. Never throws - void * allocate_aligned (size_type nbytes, size_type alignment, std::nothrow_t) + void * allocate_aligned (size_type nbytes, size_type alignment, const std::nothrow_t &) { return MemoryAlgorithm::allocate_aligned(nbytes, alignment); } //!Allocates nbytes bytes. This function is only used in @@ -191,28 +198,23 @@ class segment_manager_base #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) template - std::pair - allocation_command (boost::interprocess::allocation_type command, size_type limit_size, - size_type preferred_size,size_type &received_size, - T *reuse_ptr = 0) + T *allocation_command (boost::interprocess::allocation_type command, size_type limit_size, + size_type &prefer_in_recvd_out_size, T *&reuse) { - std::pair ret = MemoryAlgorithm::allocation_command - ( command | boost::interprocess::nothrow_allocation, limit_size, preferred_size, received_size - , reuse_ptr); - if(!(command & boost::interprocess::nothrow_allocation) && !ret.first) + T *ret = MemoryAlgorithm::allocation_command + (command | boost::interprocess::nothrow_allocation, limit_size, prefer_in_recvd_out_size, reuse); + if(!(command & boost::interprocess::nothrow_allocation) && !ret) throw bad_alloc(); return ret; } - std::pair - raw_allocation_command (boost::interprocess::allocation_type command, size_type limit_objects, - size_type preferred_objects,size_type &received_objects, - void *reuse_ptr = 0, size_type sizeof_object = 1) + void *raw_allocation_command (boost::interprocess::allocation_type command, size_type limit_objects, + size_type &prefer_in_recvd_out_size, void *&reuse, size_type sizeof_object = 1) { - std::pair ret = MemoryAlgorithm::raw_allocation_command - ( command | boost::interprocess::nothrow_allocation, limit_objects, preferred_objects, received_objects - , reuse_ptr, sizeof_object); - if(!(command & boost::interprocess::nothrow_allocation) && !ret.first) + void *ret = MemoryAlgorithm::raw_allocation_command + ( command | boost::interprocess::nothrow_allocation, limit_objects, + prefer_in_recvd_out_size, reuse, sizeof_object); + if(!(command & boost::interprocess::nothrow_allocation) && !ret) throw bad_alloc(); return ret; } @@ -266,7 +268,7 @@ class segment_manager_base , 0); //Allocate memory - void *ptr_struct = this->allocate(block_info.total_size(), std::nothrow_t()); + void *ptr_struct = this->allocate(block_info.total_size(), nothrow<>::get()); //Check if there is enough memory if(!ptr_struct){ @@ -282,7 +284,7 @@ class segment_manager_base ipcdetail::mem_algo_deallocator mem(ptr_struct, *this); //Now construct the header - block_header_t * hdr = new(ptr_struct) block_header_t(block_info); + block_header_t * hdr = ::new(ptr_struct, boost_container_new_t()) block_header_t(block_info); void *ptr = 0; //avoid gcc warning ptr = hdr->value(); @@ -457,14 +459,14 @@ class segment_manager //!object template typename construct_proxy::type - construct(char_ptr_holder_t name, std::nothrow_t) + construct(char_ptr_holder_t name, const std::nothrow_t &) { return typename construct_proxy::type (this, name, false, false); } //!Returns no throwing "search or construct" //!proxy object template typename construct_proxy::type - find_or_construct(char_ptr_holder_t name, std::nothrow_t) + find_or_construct(char_ptr_holder_t name, const std::nothrow_t &) { return typename construct_proxy::type (this, name, true, false); } //!Returns throwing "construct from iterators" proxy object @@ -484,14 +486,14 @@ class segment_manager //!proxy object template typename construct_iter_proxy::type - construct_it(char_ptr_holder_t name, std::nothrow_t) + construct_it(char_ptr_holder_t name, const std::nothrow_t &) { return typename construct_iter_proxy::type (this, name, false, false); } //!Returns no throwing "search or construct from iterators" //!proxy object template typename construct_iter_proxy::type - find_or_construct_it(char_ptr_holder_t name, std::nothrow_t) + find_or_construct_it(char_ptr_holder_t name, const std::nothrow_t &) { return typename construct_iter_proxy::type (this, name, true, false); } //!Calls object function blocking recursive interprocess_mutex and guarantees that @@ -728,7 +730,7 @@ class segment_manager //!and the object count. On failure the first member of the //!returned pair is 0. template - std::pair priv_find__impl (const ipcdetail::unique_instance_t* name, bool lock) + std::pair priv_find_impl (const ipcdetail::unique_instance_t* name, bool lock) { ipcdetail::placement_destroy table; size_type size; @@ -741,7 +743,7 @@ class segment_manager { void *ret; //Security overflow check - if(num > ((std::size_t)-1)/table.size){ + if(num > ((std::size_t)-1)/table.size){ if(dothrow) throw bad_alloc(); else @@ -1019,7 +1021,7 @@ class segment_manager //Check if the distance between the name pointer and the memory pointer //is correct (this can detect incorrect type in destruction) - std::size_t num = ctrl_data->m_value_bytes/table.size; + std::size_t num = ctrl_data->m_value_bytes/table.size; void *values = ctrl_data->value(); //Sanity check @@ -1127,14 +1129,14 @@ class segment_manager } else{ buffer_ptr = this->allocate - (block_info.template total_size_with_header(), std::nothrow_t()); + (block_info.template total_size_with_header(), nothrow<>::get()); if(!buffer_ptr) return 0; } //Now construct the intrusive hook plus the header - intrusive_value_type * intrusive_hdr = new(buffer_ptr) intrusive_value_type(); - block_header_t * hdr = new(intrusive_hdr->get_block_header())block_header_t(block_info); + intrusive_value_type * intrusive_hdr = ::new(buffer_ptr, boost_container_new_t()) intrusive_value_type(); + block_header_t * hdr = ::new(intrusive_hdr->get_block_header(), boost_container_new_t())block_header_t(block_info); void *ptr = 0; //avoid gcc warning ptr = hdr->value(); @@ -1251,11 +1253,11 @@ class segment_manager buffer_ptr = this->allocate(total_size); } else{ - buffer_ptr = this->allocate(total_size, std::nothrow_t()); + buffer_ptr = this->allocate(total_size, nothrow<>::get()); if(!buffer_ptr) return 0; } - index_it *idr = new(buffer_ptr) index_it(it); + index_it *idr = ::new(buffer_ptr, boost_container_new_t()) index_it(it); hdr = block_header_t::template from_first_header(idr); } else{ @@ -1263,14 +1265,14 @@ class segment_manager buffer_ptr = this->allocate(block_info.total_size()); } else{ - buffer_ptr = this->allocate(block_info.total_size(), std::nothrow_t()); + buffer_ptr = this->allocate(block_info.total_size(), nothrow<>::get()); if(!buffer_ptr) return 0; } hdr = static_cast(buffer_ptr); } - hdr = new(hdr)block_header_t(block_info); + hdr = ::new(hdr, boost_container_new_t())block_header_t(block_info); void *ptr = 0; //avoid gcc warning ptr = hdr->value(); -- cgit v1.2.3