Boost logo

Boost-Commit :

From: phil_at_[hidden]
Date: 2008-05-09 05:29:33


Author: pbouchard
Date: 2008-05-09 05:29:32 EDT (Fri, 09 May 2008)
New Revision: 45246
URL: http://svn.boost.org/trac/boost/changeset/45246

Log:
Now uses global heap boundaries under gcc and confirmed new bug.
Added:
   sandbox/shifted_ptr/libs/smart_ptr/example/build_test3-mingw.sh (contents, props changed)
Text files modified:
   sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp | 78 +++++++++++++++++++++++++++------------
   sandbox/shifted_ptr/boost/shifted_ptr.hpp | 10 ++--
   sandbox/shifted_ptr/libs/smart_ptr/example/shifted_ptr_test3.cpp | 2 -
   3 files changed, 58 insertions(+), 32 deletions(-)

Modified: sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp
==============================================================================
--- sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp (original)
+++ sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp 2008-05-09 05:29:32 EDT (Fri, 09 May 2008)
@@ -66,13 +66,64 @@
 
 
 /**
+ Segment boundaries.
+*/
+
+struct segment : std::pair<const void *, const void *>
+{
+ typedef std::pair<const void *, const void *> base;
+
+ segment(const void * p = (const void *)(std::numeric_limits<unsigned>::max)(), const void * q = (const void *)(std::numeric_limits<unsigned>::min)()) : base((const void *)(p), (const void *)(q))
+ {
+ }
+
+ void include(const void * p)
+ {
+ if (p < static_cast<const void *>(first)) first = p;
+ if (p > static_cast<const void *>(second)) second = p;
+ }
+
+ bool contains(const void * p)
+ {
+ return ! (static_cast<char const *>(p) < first || static_cast<char const *>(p) > second);
+ }
+};
+
+
+/**
+ Auto stack boundaries.
+*/
+
+struct stack_segment : segment
+{
+ stack_segment()
+ {
+#if defined(__GNUC__)
+ include(__builtin_frame_address(4));
+#else
+#error Compiler not yet supported.
+#endif
+ }
+
+ bool contains(const void * p)
+ {
+#if defined(__GNUC__)
+ include(__builtin_frame_address(0));
+#else
+#error Compiler not yet supported.
+#endif
+
+ return segment::contains(p);
+ }
+} stack_;
+
+
+/**
         Root class of all pointees.
 */
 
 class owned_base : public sp_counted_base
 {
- typedef std::pair<char *, char *> segment;
-
         intrusive_stack ptrs_;
         intrusive_list inits_;
         
@@ -85,17 +136,11 @@
                 inits_.push_back(& init_tag_);
         }
 
- static bool contains(const segment & heap, void const * p)
- {
- return ! (static_cast<char const *>(p) < heap.first || static_cast<char const *>(p) > heap.second);
- }
-
         intrusive_stack * ptrs() { return & ptrs_; }
         intrusive_list * inits() { return & inits_; }
         intrusive_list::node * set_tag() { return & set_tag_; }
         intrusive_list::node * init_tag() { return & init_tag_; }
 
- static segment heap;
 #ifndef BOOST_SH_DISABLE_THREADS
         static thread_specific_stack last;
 #else
@@ -104,8 +149,6 @@
 };
 
 
-owned_base::segment owned_base::heap((char *)(std::numeric_limits<unsigned>::max)(), (char *)(std::numeric_limits<unsigned>::min)());
-
 #ifndef BOOST_SH_DISABLE_THREADS
 thread_specific_stack owned_base::last;
 #else
@@ -139,21 +182,6 @@
 
                 virtual void * get_deleter( std::type_info const & ti ) { return 0; } // dummy
 
- static void * operator new (size_t n)
- {
- char * p = static_cast<char *>(::operator new (n));
-
- if (p < static_cast<char *>(heap.first)) heap.first = p;
- if (p + n > static_cast<char *>(heap.second)) heap.second = p + n;
-
- return p;
- }
-
- static void operator delete (void * p)
- {
- ::operator delete (p);
- }
-
         public:
                 class roofof
                 {

Modified: sandbox/shifted_ptr/boost/shifted_ptr.hpp
==============================================================================
--- sandbox/shifted_ptr/boost/shifted_ptr.hpp (original)
+++ sandbox/shifted_ptr/boost/shifted_ptr.hpp 2008-05-09 05:29:32 EDT (Fri, 09 May 2008)
@@ -149,7 +149,7 @@
 
                 shifted_ptr() : ps_(0)
                 {
- if (! owned_base::contains(owned_base::heap, this))
+ if (stack_.contains(this))
                                 ps_ = new set();
                         else
                                 owned_base::last->top()->ptrs()->push(& pn_);
@@ -158,7 +158,7 @@
                 template <typename V>
                         shifted_ptr(owned<V> * p) : U<T>(p)
                         {
- if (! owned_base::contains(owned_base::heap, this))
+ if (stack_.contains(this))
                                 {
                                         ps_ = new set();
 
@@ -174,7 +174,7 @@
                 template <typename V>
                         shifted_ptr(shifted_ptr<V> const & p) : U<T>(p)
                         {
- if (! owned_base::contains(owned_base::heap, this))
+ if (stack_.contains(this))
                                         ps_ = new set();
                                 else
                                         owned_base::last->top()->ptrs()->push(& pn_);
@@ -184,7 +184,7 @@
 
                         shifted_ptr(shifted_ptr<T> const & p) : U<T>(p)
                         {
- if (! owned_base::contains(owned_base::heap, this))
+ if (stack_.contains(this))
                                         ps_ = new set();
                                 else
                                         owned_base::last->top()->ptrs()->push(& pn_);
@@ -235,7 +235,7 @@
         private:
                 void release(bool d = false)
                 {
- if (! owned_base::contains(owned_base::heap, this))
+ if (stack_.contains(this))
                         {
                                 if (ps_->release())
                                 {

Added: sandbox/shifted_ptr/libs/smart_ptr/example/build_test3-mingw.sh
==============================================================================
--- (empty file)
+++ sandbox/shifted_ptr/libs/smart_ptr/example/build_test3-mingw.sh 2008-05-09 05:29:32 EDT (Fri, 09 May 2008)
@@ -0,0 +1 @@
+g++ shifted_ptr_test3.cpp -I ../../.. /local/lib/boost_unit_test_framework-mt.lib -Wl,--enable-runtime-pseudo-reloc

Modified: sandbox/shifted_ptr/libs/smart_ptr/example/shifted_ptr_test3.cpp
==============================================================================
--- sandbox/shifted_ptr/libs/smart_ptr/example/shifted_ptr_test3.cpp (original)
+++ sandbox/shifted_ptr/libs/smart_ptr/example/shifted_ptr_test3.cpp 2008-05-09 05:29:32 EDT (Fri, 09 May 2008)
@@ -81,13 +81,11 @@
 
 BOOST_AUTO_TEST_CASE(test_shifted_ptr) {
     count = 0;
-/*
     {
         shifted_ptr<vector> v = new_sh<vector>();
         v->elements.push_back(v);
     }
     BOOST_CHECK_EQUAL(count, 0);
-*/
 
     count = 0;
     {


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