Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80521 - in trunk: boost/interprocess/detail libs/interprocess/proj libs/interprocess/test
From: igaztanaga_at_[hidden]
Date: 2012-09-13 18:06:17


Author: igaztanaga
Date: 2012-09-13 18:06:16 EDT (Thu, 13 Sep 2012)
New Revision: 80521
URL: http://svn.boost.org/trac/boost/changeset/80521

Log:
Fixed forwarding error in Visual 2010
Text files modified:
   trunk/boost/interprocess/detail/preprocessor.hpp | 144 ++++++++++++++++++++++++++++-----------
   trunk/libs/interprocess/proj/to-do.txt | 14 +++
   trunk/libs/interprocess/test/allocator_v1.hpp | 8 +
   trunk/libs/interprocess/test/memory_algorithm_test_template.hpp | 6 -
   4 files changed, 127 insertions(+), 45 deletions(-)

Modified: trunk/boost/interprocess/detail/preprocessor.hpp
==============================================================================
--- trunk/boost/interprocess/detail/preprocessor.hpp (original)
+++ trunk/boost/interprocess/detail/preprocessor.hpp 2012-09-13 18:06:16 EDT (Thu, 13 Sep 2012)
@@ -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) \
+ //!
 
-#else
+ #endif //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); \
-//!
-
-#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_INC(z, n, data) \
+ BOOST_PP_CAT(++m_p, n) \
+ //!
 
-#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,23 +174,25 @@
 
 #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) ) \
+ //!
 
-#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) \
+ //!
 
-#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)
 
 #include <boost/interprocess/detail/config_end.hpp>
 

Modified: trunk/libs/interprocess/proj/to-do.txt
==============================================================================
--- trunk/libs/interprocess/proj/to-do.txt (original)
+++ trunk/libs/interprocess/proj/to-do.txt 2012-09-13 18:06:16 EDT (Thu, 13 Sep 2012)
@@ -249,3 +249,17 @@
 
 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;

Modified: trunk/libs/interprocess/test/allocator_v1.hpp
==============================================================================
--- trunk/libs/interprocess/test/allocator_v1.hpp (original)
+++ trunk/libs/interprocess/test/allocator_v1.hpp 2012-09-13 18:06:16 EDT (Thu, 13 Sep 2012)
@@ -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 @@
    //!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)

Modified: trunk/libs/interprocess/test/memory_algorithm_test_template.hpp
==============================================================================
--- trunk/libs/interprocess/test/memory_algorithm_test_template.hpp (original)
+++ trunk/libs/interprocess/test/memory_algorithm_test_template.hpp 2012-09-13 18:06:16 EDT (Thu, 13 Sep 2012)
@@ -679,8 +679,7 @@
 
          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 @@
             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;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk