diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk index 46ad7c8..3c1eb6f 100644 --- a/doc/interprocess.qbk +++ b/doc/interprocess.qbk @@ -6719,23 +6719,24 @@ thank them: [section:release_notes_boost_1_52_00 Boost 1.52 Release] * Added `shrink_by` and `advise` functions in `mapped_region`. -* Reimplemented `message_queue` with a circular buffer index (the +* [*ABI breaking]Reimplemented `message_queue` with a circular buffer index (the old behavior used an ordered array, leading to excessive copies). This should greatly increase performance but breaks ABI. Old behaviour/ABI can be used undefining macro `BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX` in `boost/interprocess/detail/workaround.hpp` * Improved `message_queue` insertion time avoiding priority search for common cases (both array and circular buffer configurations). * Implemented `sharable_mutex` and `interproces_condition_any`. +* Improved `offset_ptr` performance. +* Added integer overflow checks. [endsect] - [section:release_notes_boost_1_51_00 Boost 1.51 Release] * Synchronous and asynchronous flushing for `mapped_region::flush`. -* Source & ABI breaking: Removed `get_offset` method from `mapped_region` as +* [*Source & ABI breaking]: Removed `get_offset` method from `mapped_region` as it has no practical utility and `m_offset` member was not for anything else. -* Source & ABI breaking: Removed `flush` from `managed_shared_memory`. +* [*Source & ABI breaking]: Removed `flush` from `managed_shared_memory`. as it is unspecified according to POSIX: [@http://pubs.opengroup.org/onlinepubs/009695399/functions/msync.html ['"The effect of msync() on a shared memory object or a typed memory object is unspecified"] ]. diff --git a/example/doc_managed_multiple_allocation.cpp b/example/doc_managed_multiple_allocation.cpp index 4e9024e..2192d15 100644 --- a/example/doc_managed_multiple_allocation.cpp +++ b/example/doc_managed_multiple_allocation.cpp @@ -64,8 +64,7 @@ int main() //Initialize our data while(!chain.empty()){ - void *buf = chain.front(); - chain.pop_front(); + void *buf = chain.pop_front(); allocated_buffers.push_back(buf); //The iterator must be incremented before overwriting memory //because otherwise, the iterator is invalidated. diff --git a/include/boost/interprocess/detail/utilities.hpp b/include/boost/interprocess/detail/utilities.hpp index 1d1b42f..3b486dd 100644 --- a/include/boost/interprocess/detail/utilities.hpp +++ b/include/boost/interprocess/detail/utilities.hpp @@ -189,7 +189,7 @@ class pointer_size_t_caster template inline bool sum_overflows(SizeType a, SizeType b) -{ return SizeType(-1) - a > b; } +{ return SizeType(-1) - a < b; } //Anti-exception node eraser template diff --git a/include/boost/interprocess/detail/win32_api.hpp b/include/boost/interprocess/detail/win32_api.hpp index f46665d..b367bba 100644 --- a/include/boost/interprocess/detail/win32_api.hpp +++ b/include/boost/interprocess/detail/win32_api.hpp @@ -241,17 +241,16 @@ struct wchar_variant } value; }; - struct IUnknown_BIPC - { - public: - virtual long __stdcall QueryInterface( - /* [in] */ const GUID_BIPC &riid, - /* [iid_is][out] */ void **ppvObject) = 0; +struct IUnknown_BIPC +{ + public: + virtual long __stdcall QueryInterface( + const GUID_BIPC &riid, // [in] + void **ppvObject) = 0; // [iid_is][out] - virtual unsigned long __stdcall AddRef( void) = 0; - - virtual unsigned long __stdcall Release( void) = 0; - }; + virtual unsigned long __stdcall AddRef (void) = 0; + virtual unsigned long __stdcall Release(void) = 0; +}; struct IWbemClassObject_BIPC : public IUnknown_BIPC { @@ -359,7 +358,6 @@ struct IWbemClassObject_BIPC : public IUnknown_BIPC }; - struct IWbemContext_BIPC : public IUnknown_BIPC { public: @@ -587,8 +585,6 @@ public: }; - - struct interprocess_overlapped { unsigned long *internal; @@ -663,7 +659,7 @@ struct system_info { unsigned short wProcessorRevision; }; -typedef struct _interprocess_memory_basic_information +struct interprocess_memory_basic_information { void * BaseAddress; void * AllocationBase; @@ -672,16 +668,16 @@ typedef struct _interprocess_memory_basic_information unsigned long State; unsigned long Protect; unsigned long Type; -} interprocess_memory_basic_information; +}; -typedef struct _interprocess_acl +struct interprocess_acl { unsigned char AclRevision; unsigned char Sbz1; unsigned short AclSize; unsigned short AceCount; unsigned short Sbz2; -} interprocess_acl; +}; typedef struct _interprocess_security_descriptor { diff --git a/include/boost/interprocess/mem_algo/detail/mem_algo_common.hpp b/include/boost/interprocess/mem_algo/detail/mem_algo_common.hpp index 7cf01cf..203686b 100644 --- a/include/boost/interprocess/mem_algo/detail/mem_algo_common.hpp +++ b/include/boost/interprocess/mem_algo/detail/mem_algo_common.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,37 @@ namespace boost { namespace interprocess { namespace ipcdetail { +template +class basic_multiallocation_chain + : public boost::container::container_detail:: + basic_multiallocation_chain +{ + BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_multiallocation_chain) + typedef boost::container::container_detail:: + basic_multiallocation_chain base_t; + public: + + basic_multiallocation_chain() + : base_t() + {} + + basic_multiallocation_chain(BOOST_RV_REF(basic_multiallocation_chain) other) + : base_t(::boost::move(static_cast(other))) + {} + + basic_multiallocation_chain& operator=(BOOST_RV_REF(basic_multiallocation_chain) other) + { + this->base_t::operator=(::boost::move(static_cast(other))); + return *this; + } + + void *pop_front() + { + return boost::interprocess::ipcdetail::to_raw_pointer(this->base_t::pop_front()); + } +}; + + //!This class implements several allocation functions shared by different algorithms //!(aligned allocation, multiple allocation...). template diff --git a/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp b/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp index 637d7be..f864114 100644 --- a/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp +++ b/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp @@ -88,8 +88,7 @@ class rbtree_best_fit typedef MutexFamily mutex_family; //!Pointer type to be used with the rest of the Interprocess framework typedef VoidPointer void_pointer; - typedef boost::container::container_detail:: - basic_multiallocation_chain multiallocation_chain; + typedef ipcdetail::basic_multiallocation_chain multiallocation_chain; typedef typename boost::intrusive::pointer_traits::difference_type difference_type; typedef typename boost::make_unsigned::type size_type;