Fixed forwarding error in Visual 2010

[SVN r80521]
This commit is contained in:
Ion Gaztañaga
2012-09-13 22:06:16 +00:00
parent e5d655952d
commit 5b1ad64bf9
4 changed files with 127 additions and 45 deletions

View File

@@ -57,21 +57,10 @@
#ifndef BOOST_NO_RVALUE_REFERENCES
#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
#define BOOST_INTERPROCESS_PP_PARAM_INIT(z, n, data) \
BOOST_PP_CAT(m_p, n) (BOOST_PP_CAT(p, n)) \
//!
#else //#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
#define BOOST_INTERPROCESS_PP_PARAM_INIT(z, n, data) \
BOOST_PP_CAT(m_p, n) (::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) )) \
//!
#endif //#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
#else //#ifndef BOOST_NO_RVALUE_REFERENCES
#define BOOST_INTERPROCESS_PP_PARAM_INIT(z, n, data) \
@@ -79,31 +68,104 @@
//!
#endif
#define BOOST_INTERPROCESS_PP_PARAM_INC(z, n, data) \
BOOST_PP_CAT(++m_p, n) \
//!
#ifndef BOOST_NO_RVALUE_REFERENCES
#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
#define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data) \
BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \
//!
namespace boost {
namespace interprocess {
namespace ipcdetail {
template<class T>
struct ref_holder;
template<class T>
struct ref_holder<T &>
{
ref_holder(T &t)
: t_(t)
{}
T &t_;
T & get() { return t_; }
T & get_lvalue() { return t_; }
};
template<class T>
struct ref_holder<const T>
{
ref_holder(const T &t)
: t_(t)
{}
const T &t_;
const T & get() { return t_; }
const T & get_lvalue() { return t_; }
};
template<class T>
struct ref_holder<const T &&>
{
ref_holder(const T &t)
: t_(t)
{}
const T &t_;
const T & get() { return t_; }
const T & get_lvalue() { return t_; }
};
template<class T>
struct ref_holder
{
ref_holder(T &&t)
: t_(t)
{}
T &t_;
T && get() { return ::boost::move(t_); }
T & get_lvalue() { return t_; }
};
template<class T>
struct ref_holder<T &&>
{
ref_holder(T &&t)
: t(t)
{}
T &t;
T && get() { return ::boost::move(t_); }
T & get_lvalue() { return t_; }
};
} //namespace ipcdetail {
} //namespace interprocess {
} //namespace boost {
#define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data) \
::boost::interprocess::ipcdetail::ref_holder<BOOST_PP_CAT(P, n)> BOOST_PP_CAT(m_p, n); \
//!
#define BOOST_INTERPROCESS_PP_PARAM_INC(z, n, data) \
BOOST_PP_CAT(++m_p, n).get_lvalue() \
//!
#else //BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG
#define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data)\
BOOST_PP_CAT(P, n) && BOOST_PP_CAT(m_p, n); \
//!
#define BOOST_INTERPROCESS_PP_PARAM_INC(z, n, data) \
BOOST_PP_CAT(++m_p, n) \
//!
#endif //defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
#else
#define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data) \
BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \
//!
#define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data) \
BOOST_PP_CAT(P, n) && BOOST_PP_CAT(m_p, n); \
//!
#define BOOST_INTERPROCESS_PP_PARAM_INC(z, n, data) \
BOOST_PP_CAT(++m_p, n) \
//!
#endif //defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
#else
#define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data) \
BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \
//!
#endif
#define BOOST_INTERPROCESS_PP_PARAM_FORWARD(z, n, data) \
@@ -112,24 +174,26 @@
#if !defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
#include <boost/container/detail/stored_ref.hpp>
#define BOOST_INTERPROCESS_PP_MEMBER_FORWARD(z, n, data) BOOST_PP_CAT(this->m_p, n).get() \
//!
#define BOOST_INTERPROCESS_PP_MEMBER_FORWARD(z, n, data) \
::boost::container::container_detail::stored_ref< BOOST_PP_CAT(P, n) >::forward( BOOST_PP_CAT(m_p, n) ) \
//!
#define BOOST_INTERPROCESS_PP_MEMBER_IT_FORWARD(z, n, data) \
BOOST_PP_CAT(*m_p, n).get_lvalue() \
//!
#else
#define BOOST_INTERPROCESS_PP_MEMBER_FORWARD(z, n, data) \
::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(m_p, n) ) \
//!
#define BOOST_INTERPROCESS_PP_MEMBER_FORWARD(z, n, data) \
::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(m_p, n) ) \
//!
#define BOOST_INTERPROCESS_PP_MEMBER_IT_FORWARD(z, n, data) \
BOOST_PP_CAT(*m_p, n) \
//!
#endif //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
#define BOOST_INTERPROCESS_PP_MEMBER_IT_FORWARD(z, n, data) \
BOOST_PP_CAT(*m_p, n) \
//!
#include <boost/interprocess/detail/config_end.hpp>
#else

View File

@@ -249,3 +249,17 @@ MyRobustMutexLockFile()
ipcdetail::intermodule_singleton<MyRobustMutexLockFile>::get();
Add unsigned overflow checking with shortcut as explained here:
https://github.com/ivmai/bdwgc/commit/83231d0ab5ed60015797c3d1ad9056295ac3b2bb
# define GC_SIZE_MAX (~(size_t)0)
#endif
+#define GC_SQRT_SIZE_MAX ((1U << (WORDSZ / 2)) - 1)
+
void * calloc(size_t n, size_t lb)
{
- if (lb && n > GC_SIZE_MAX / lb)
+ if ((lb | n) > GC_SQRT_SIZE_MAX /* fast initial test */
+ && lb && n > GC_SIZE_MAX / lb)
return NULL;

View File

@@ -29,6 +29,7 @@
#include <algorithm>
#include <cstddef>
#include <stdexcept>
#include <boost/static_assert.hpp>
//!\file
//!Describes an allocator_v1 that allocates portions of fixed size
@@ -118,7 +119,12 @@ class allocator_v1
//!Allocates memory for an array of count elements.
//!Throws boost::interprocess::bad_alloc if there is no enough memory
pointer allocate(size_type count, cvoid_ptr hint = 0)
{ (void)hint; return pointer(static_cast<value_type*>(mp_mngr->allocate(count*sizeof(value_type)))); }
{
if(size_overflows<sizeof(T)>(count)){
throw bad_alloc();
}
(void)hint; return pointer(static_cast<T*>(mp_mngr->allocate(count*sizeof(T))));
}
//!Deallocates memory previously allocated. Never throws
void deallocate(const pointer &ptr, size_type)

View File

@@ -679,8 +679,7 @@ bool test_many_equal_allocation(Allocator &a)
typename multiallocation_chain::size_type n = chain.size();
while(!chain.empty()){
buffers.push_back(ipcdetail::to_raw_pointer(chain.front()));
chain.pop_front();
buffers.push_back(ipcdetail::to_raw_pointer(chain.pop_front()));
}
if(n != std::size_t((i+1)*2))
return false;
@@ -788,8 +787,7 @@ bool test_many_different_allocation(Allocator &a)
break;
typename multiallocation_chain::size_type n = chain.size();
while(!chain.empty()){
buffers.push_back(ipcdetail::to_raw_pointer(chain.front()));
chain.pop_front();
buffers.push_back(ipcdetail::to_raw_pointer(chain.pop_front()));
}
if(n != ArraySize)
return false;