Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71487 - in sandbox/mm_ptr/boost: . detail
From: phil_at_[hidden]
Date: 2011-04-25 13:31:04


Author: pbouchard
Date: 2011-04-25 13:31:03 EDT (Mon, 25 Apr 2011)
New Revision: 71487
URL: http://svn.boost.org/trac/boost/changeset/71487

Log:
* Renamed files
Added:
   sandbox/mm_ptr/boost/detail/mm_base.hpp (contents, props changed)
   sandbox/mm_ptr/boost/detail/roofof.hpp (contents, props changed)
Removed:
   sandbox/mm_ptr/boost/detail/sh_utility.h
Text files modified:
   sandbox/mm_ptr/boost/detail/intrusive_list.hpp | 2 +-
   sandbox/mm_ptr/boost/detail/intrusive_stack.hpp | 2 +-
   sandbox/mm_ptr/boost/detail/mm_ptr_base.hpp | 8 ++++----
   sandbox/mm_ptr/boost/mm_ptr.hpp | 6 +++---
   4 files changed, 9 insertions(+), 9 deletions(-)

Modified: sandbox/mm_ptr/boost/detail/intrusive_list.hpp
==============================================================================
--- sandbox/mm_ptr/boost/detail/intrusive_list.hpp (original)
+++ sandbox/mm_ptr/boost/detail/intrusive_list.hpp 2011-04-25 13:31:03 EDT (Mon, 25 Apr 2011)
@@ -18,7 +18,7 @@
 #define BOOST_INTRUSIVE_LIST_HPP_INCLUDED
 
 
-#include <boost/detail/sh_utility.h>
+#include <boost/detail/roofof.hpp>
 
 
 namespace boost

Modified: sandbox/mm_ptr/boost/detail/intrusive_stack.hpp
==============================================================================
--- sandbox/mm_ptr/boost/detail/intrusive_stack.hpp (original)
+++ sandbox/mm_ptr/boost/detail/intrusive_stack.hpp 2011-04-25 13:31:03 EDT (Mon, 25 Apr 2011)
@@ -18,7 +18,7 @@
 #define BOOST_INTRUSIVE_STACK_HPP_INCLUDED
 
 
-#include <boost/detail/sh_utility.h>
+#include <boost/detail/roofof.hpp>
 
 
 namespace boost

Added: sandbox/mm_ptr/boost/detail/mm_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/mm_ptr/boost/detail/mm_base.hpp 2011-04-25 13:31:03 EDT (Mon, 25 Apr 2011)
@@ -0,0 +1,334 @@
+/**
+ @file
+ Boost detail/sh_mm_base_nt.hpp header file.
+
+ @note
+ Copyright (c) 2008 Phil Bouchard <phil_at_[hidden]>.
+
+ Distributed under the Boost Software License, Version 1.0.
+
+ See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt
+
+ See http://www.boost.org/libs/smart_ptr/doc/index.html for documentation.
+*/
+
+
+#ifndef BOOST_DETAIL_MM_BASE_HPP_INCLUDED
+#define BOOST_DETAIL_MM_BASE_HPP_INCLUDED
+
+// MS compatible compilers support #pragma once
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <stack>
+#include <limits>
+
+// Bypassing linkage by default
+#define BOOST_SH_DISABLE_THREADS
+
+#include <boost/thread.hpp>
+#include <boost/thread/tss.hpp>
+#include <boost/pool/pool.hpp>
+#include <boost/pool/pool_alloc.hpp>
+#include <boost/numeric/interval.hpp>
+#include <boost/type_traits/is_array.hpp>
+#include <boost/type_traits/remove_extent.hpp>
+#include <boost/type_traits/has_trivial_destructor.hpp>
+#include <boost/preprocessor/control/expr_if.hpp>
+#include <boost/preprocessor/arithmetic/inc.hpp>
+#include <boost/preprocessor/punctuation/comma_if.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+
+#include <boost/detail/intrusive_list.hpp>
+#include <boost/detail/intrusive_stack.hpp>
+#include <boost/detail/roofof.hpp>
+
+
+namespace boost
+{
+
+namespace detail
+{
+
+namespace sh
+{
+
+
+class mm_header;
+class mm_base;
+
+
+/**
+ Allocator wrapper tracking allocations.
+
+ Pool where all pointee objects are allocated and tracks memory blocks for later enlisting & marking the @c mm_header the pointee object belongs to.
+*/
+
+struct pool : boost::pool<>
+{
+ typedef std::list< numeric::interval<long>, fast_pool_allocator< numeric::interval<long> > > pool_lii; /**< Syntax helper. */
+
+#ifndef BOOST_SH_DISABLE_THREADS
+ thread_specific_ptr<pool_lii> plii_; /**< Thread specific list of memory boundaries. */
+#else
+ std::auto_ptr<pool_lii> plii_; /**< List of memory boundaries. */
+#endif
+
+
+ /**
+ Initialization of a pool instance.
+ */
+
+ pool() : boost::pool<>(1)
+ {
+ plii_.reset(new pool_lii());
+ }
+
+
+ /**
+ Tracks the memory boundaries where a pointer belongs to. Also gets rid of the boundaries that were allocated before the pointer was allocated.
+
+ @param p Pointer that is being tracked.
+ @return Pointer to the pointee object where @c p belongs to.
+ */
+
+ mm_base * top(void * p)
+ {
+ pool_lii::reverse_iterator i;
+
+ for (i = plii_->rbegin(); i != plii_->rend(); i ++)
+ if (in((long)(p), * i))
+ break;
+
+ plii_->erase(i.base(), plii_->end());
+
+ return (mm_base *)(plii_->rbegin()->lower());
+ }
+
+
+ /**
+ Pointee object allocator and stacking of the newly allocated memory boundary.
+
+ @param s Size of the memory block to allocate.
+ @return Address of the newly allocated block.
+ */
+
+ void * allocate(std::size_t s)
+ {
+ void * p = ordered_malloc(s);
+
+ plii_->push_back(numeric::interval<long>((long) p, long((char *)(p) + s)));
+
+ return p;
+ }
+
+
+ /**
+ Pointee object deallocator and removal of the boundaries that were allocated before the pointer was allocated.
+
+ @param p Address of the memory block to deallocate.
+ @param s Size of the memory block.
+ */
+
+ void deallocate(void * p, std::size_t s)
+ {
+ pool_lii::reverse_iterator i;
+
+ for (i = plii_->rbegin(); i != plii_->rend(); i ++)
+ if (in((long)(p), * i))
+ break;
+
+ plii_->erase(i.base(), plii_->end());
+ ordered_free(p, s);
+ }
+};
+
+
+/**
+ Root class of all pointee objects.
+*/
+
+class mm_base : public sp_counted_base
+{
+public:
+ bool init_; /**< Flag marking initialization of the pointee object to its @c mm_header . */
+
+ intrusive_stack ptrs_; /**< Stack of all @c mm_ptr s on the heap that will later need to be initlialized to a specific @c mm_header . */
+ intrusive_list inits_; /**< List of all pointee objects that will later need to be initlialized to a specific @c mm_header .*/
+
+ intrusive_list::node mm_tag_; /**< Tag used to enlist to @c mm_header::elements_ . */
+ intrusive_list::node init_tag_; /**< Tag used to enlist to @c mm_base::inits_ . */
+
+
+ mm_base() : init_(false)
+ {
+ inits_.push_back(& init_tag_);
+ }
+
+ static pool pool_; /**< Pool where all pointee objects are allocated from. */
+
+protected:
+ virtual void dispose() {} /**< dummy */
+ virtual void * get_deleter( std::type_info const & ti ) { return 0; } /**< dummy */
+};
+
+
+pool mm_base::pool_;
+
+
+#define TEMPLATE_DECL(z, n, text) BOOST_PP_COMMA_IF(n) typename T ## n
+#define ARGUMENT_DECL(z, n, text) BOOST_PP_COMMA_IF(n) T ## n const & t ## n
+#define PARAMETER_DECL(z, n, text) BOOST_PP_COMMA_IF(n) t ## n
+
+#define CONSTRUCT_OWNED(z, n, text) \
+ template <BOOST_PP_REPEAT(n, TEMPLATE_DECL, 0)> \
+ text(BOOST_PP_REPEAT(n, ARGUMENT_DECL, 0)) : elem_(BOOST_PP_REPEAT(n, PARAMETER_DECL, 0)) {}
+
+/**
+ Object wrapper.
+*/
+
+template <typename T>
+ class mm : public mm_base
+ {
+ typedef T data_type;
+
+ T elem_; /**< Pointee object. @note Needs alignas<long>. */
+
+ public:
+ class roofof;
+ friend class roofof;
+
+ mm() : elem_()
+ {
+ }
+
+ BOOST_PP_REPEAT_FROM_TO(1, 10, CONSTRUCT_OWNED, mm)
+
+
+ /**
+ @return Pointee object address.
+ */
+
+ data_type * element() { return & elem_; }
+ operator data_type & () { return * element(); }
+ operator data_type const & () const { return * element(); }
+
+ virtual ~mm()
+ {
+ dispose();
+ }
+
+ public:
+ /**
+ Cast operator used by @c mm_ptr_common::header() .
+ */
+
+ class roofof
+ {
+ mm * p_; /**< Address of the @c mm the element belong to. */
+
+ public:
+ /**
+ Casts from a @c data_type to its parent @c mm object.
+
+ @param p Address of a @c data_type member object to cast from.
+ */
+
+ roofof(data_type * p) : p_(sh::roofof((data_type mm::*)(& mm::elem_), p)) {}
+
+
+ /**
+ @return Address of the parent @c mm object.
+ */
+
+ operator mm * () const { return p_; }
+ };
+
+
+ /**
+ Allocates a new @c mm using the pool.
+
+ @param s Size of the @c mm .
+ @return Pointer of the new memory block.
+ */
+
+ void * operator new (size_t s)
+ {
+ return pool_.allocate(s);
+ }
+
+
+ /**
+ Deallocates a @c mm from the pool.
+
+ @param p Address of the @c mm to deallocate.
+ */
+
+ void operator delete (void * p)
+ {
+ pool_.deallocate(p, sizeof(mm));
+ }
+ };
+
+
+template <>
+ class mm<void> : public mm_base
+ {
+ typedef void data_type;
+
+ long elem_; /**< Pointee placeholder. @note Aligned. */
+
+ mm();
+
+ public:
+ class roofof;
+ friend class roofof;
+
+ data_type * element() { return & elem_; }
+
+ virtual ~mm() {}
+ virtual void dispose() {}
+
+ virtual void * get_deleter( std::type_info const & ti ) {}
+
+ public:
+ /**
+ Cast operator used by @c mm_ptr_common::header() .
+ */
+
+ class roofof
+ {
+ mm * p_; /**< Address of the @c mm the element belong to. */
+
+ public:
+ /**
+ Casts from a @c data_type to its parent @c mm object.
+
+ @param p Address of a @c data_type member object to cast from.
+ */
+
+ roofof(data_type * p) : p_(sh::roofof((long mm::*)(& mm::elem_), static_cast<long *>(p))) {}
+
+
+ /**
+ @return Address of the parent @c mm object.
+ */
+
+ operator mm * () const { return p_; }
+ };
+ };
+
+
+} // namespace sh
+
+} // namespace detail
+
+} // namespace boost
+
+
+#endif // #ifndef BOOST_DETAIL_SH_OWNED_BASE_NT_HPP_INCLUDED

Modified: sandbox/mm_ptr/boost/detail/mm_ptr_base.hpp
==============================================================================
--- sandbox/mm_ptr/boost/detail/mm_ptr_base.hpp (original)
+++ sandbox/mm_ptr/boost/detail/mm_ptr_base.hpp 2011-04-25 13:31:03 EDT (Mon, 25 Apr 2011)
@@ -15,12 +15,12 @@
 */
 
 
-#ifndef BOOST_SHIFTED_PTR_HPP
-#define BOOST_SHIFTED_PTR_HPP
+#ifndef BOOST_DETAIL_MM_PTR_BASE_HPP
+#define BOOST_DETAIL_MM_PTR_BASE_HPP
 
 
-#include <boost/detail/sh_utility.h>
-#include <boost/detail/sh_mm_base.hpp>
+#include <boost/detail/roofof.hpp>
+#include <boost/detail/mm_base.hpp>
 
 
 namespace boost

Added: sandbox/mm_ptr/boost/detail/roofof.hpp
==============================================================================
--- (empty file)
+++ sandbox/mm_ptr/boost/detail/roofof.hpp 2011-04-25 13:31:03 EDT (Mon, 25 Apr 2011)
@@ -0,0 +1,100 @@
+/**
+ @file
+ Boost sh_utility.h header file.
+
+ @note
+ Copyright (c) 2008 Phil Bouchard <phil_at_[hidden]>.
+
+ Distributed under the Boost Software License, Version 1.0.
+
+ See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt
+
+ See http://www.boost.org/libs/smart_ptr/doc/index.html for documentation.
+*/
+
+
+#ifndef BOOST_DETAIL_ROOFOF_HPP_INCLUDED
+#define BOOST_DETAIL_ROOFOF_HPP_INCLUDED
+
+
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/type_traits/remove_volatile.hpp>
+#include <boost/type_traits/is_polymorphic.hpp>
+#include <boost/type_traits/type_with_alignment.hpp>
+
+
+namespace boost
+{
+
+namespace detail
+{
+
+namespace sh
+{
+
+
+/**
+ Block address helper.
+
+ Returns the absolute address of a non-polymorphic object.
+
+ @note
+ Expects template value given by @sa is_polymorphic<>::value.
+*/
+
+template <bool>
+ struct rootof
+ {
+ template <typename U>
+ static void * get(U * a_p)
+ {
+ typedef typename remove_const<typename remove_volatile<U>::type>::type unqualified_type;
+
+ return static_cast<void *>(const_cast<unqualified_type *>(a_p));
+ }
+ };
+
+
+/**
+ Block address helper.
+
+ Returns the absolute address of a polymorphic object.
+*/
+
+template <>
+ struct rootof<true>
+ {
+ template <typename U>
+ static void * get(U * a_p)
+ {
+ typedef typename remove_const<typename remove_volatile<U>::type>::type unqualified_type;
+
+ return dynamic_cast<void *>(const_cast<unqualified_type *>(a_p));
+ }
+ };
+
+
+/**
+ Class member upshift.
+
+ Finds the address of a class given member credentials.
+*/
+
+template <typename T, typename U>
+ T * roofof(U T::* q, U * p)
+ {
+ typedef typename remove_const<typename remove_volatile<U>::type>::type unqualified_type;
+
+ return static_cast<T *>(static_cast<void *>(static_cast<char *>(static_cast<void *>(const_cast<unqualified_type *>(p))) - ptrdiff_t(static_cast<char *>(static_cast<void *>(const_cast<unqualified_type *>(& ((T *)(0)->* q)))) - (char *)(0))));
+ }
+
+
+} // namespace sh
+
+} // namespace detail
+
+} // namespace boost
+
+
+#endif // #ifndef BOOST_DETAIL_SH_UTILITY_H_INCLUDED

Deleted: sandbox/mm_ptr/boost/detail/sh_utility.h
==============================================================================
--- sandbox/mm_ptr/boost/detail/sh_utility.h 2011-04-25 13:31:03 EDT (Mon, 25 Apr 2011)
+++ (empty file)
@@ -1,100 +0,0 @@
-/**
- @file
- Boost sh_utility.h header file.
-
- @note
- Copyright (c) 2008 Phil Bouchard <phil_at_[hidden]>.
-
- Distributed under the Boost Software License, Version 1.0.
-
- See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt
-
- See http://www.boost.org/libs/smart_ptr/doc/index.html for documentation.
-*/
-
-
-#ifndef BOOST_DETAIL_SH_UTILITY_H_INCLUDED
-#define BOOST_DETAIL_SH_UTILITY_H_INCLUDED
-
-
-#include <boost/type_traits/remove_const.hpp>
-#include <boost/type_traits/remove_volatile.hpp>
-#include <boost/type_traits/is_polymorphic.hpp>
-#include <boost/type_traits/type_with_alignment.hpp>
-
-
-namespace boost
-{
-
-namespace detail
-{
-
-namespace sh
-{
-
-
-/**
- Block address helper.
-
- Returns the absolute address of a non-polymorphic object.
-
- @note
- Expects template value given by @sa is_polymorphic<>::value.
-*/
-
-template <bool>
- struct rootof
- {
- template <typename U>
- static void * get(U * a_p)
- {
- typedef typename remove_const<typename remove_volatile<U>::type>::type unqualified_type;
-
- return static_cast<void *>(const_cast<unqualified_type *>(a_p));
- }
- };
-
-
-/**
- Block address helper.
-
- Returns the absolute address of a polymorphic object.
-*/
-
-template <>
- struct rootof<true>
- {
- template <typename U>
- static void * get(U * a_p)
- {
- typedef typename remove_const<typename remove_volatile<U>::type>::type unqualified_type;
-
- return dynamic_cast<void *>(const_cast<unqualified_type *>(a_p));
- }
- };
-
-
-/**
- Class member upshift.
-
- Finds the address of a class given member credentials.
-*/
-
-template <typename T, typename U>
- T * roofof(U T::* q, U * p)
- {
- typedef typename remove_const<typename remove_volatile<U>::type>::type unqualified_type;
-
- return static_cast<T *>(static_cast<void *>(static_cast<char *>(static_cast<void *>(const_cast<unqualified_type *>(p))) - ptrdiff_t(static_cast<char *>(static_cast<void *>(const_cast<unqualified_type *>(& ((T *)(0)->* q)))) - (char *)(0))));
- }
-
-
-} // namespace sh
-
-} // namespace detail
-
-} // namespace boost
-
-
-#endif // #ifndef BOOST_DETAIL_SH_UTILITY_H_INCLUDED

Modified: sandbox/mm_ptr/boost/mm_ptr.hpp
==============================================================================
--- sandbox/mm_ptr/boost/mm_ptr.hpp (original)
+++ sandbox/mm_ptr/boost/mm_ptr.hpp 2011-04-25 13:31:03 EDT (Mon, 25 Apr 2011)
@@ -18,8 +18,8 @@
 */
 
 
-#ifndef BOOST_DETAIL_SH_RTCMM_H_INCLUDED
-#define BOOST_DETAIL_SH_RTCMM_H_INCLUDED
+#ifndef BOOST_DETAIL_MM_PTR_INCLUDED
+#define BOOST_DETAIL_MM_PTR_INCLUDED
 
 
 #if defined(_MSC_VER)
@@ -36,7 +36,7 @@
 
 #include <boost/detail/intrusive_list.hpp>
 #include <boost/detail/intrusive_stack.hpp>
-#include <boost/detail/sh_utility.h>
+#include <boost/detail/roofof.hpp>
 #include <boost/detail/mm_ptr_base.hpp>
 
 


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