mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-10-05 12:11:07 +02:00
Compare commits
5 Commits
master
...
boost-1.33
Author | SHA1 | Date | |
---|---|---|---|
|
876ccab92a | ||
|
b179f44d79 | ||
|
dff0529ad5 | ||
|
72c5cc395a | ||
|
9945f4e158 |
@@ -34,55 +34,61 @@ namespace detail
|
|||||||
|
|
||||||
inline void atomic_increment( register long * pw )
|
inline void atomic_increment( register long * pw )
|
||||||
{
|
{
|
||||||
|
register int a;
|
||||||
|
|
||||||
asm
|
asm
|
||||||
{
|
{
|
||||||
loop:
|
loop:
|
||||||
|
|
||||||
lwarx r4, 0, r3
|
lwarx a, 0, pw
|
||||||
addi r4, r4, 1
|
addi a, a, 1
|
||||||
stwcx. r4, 0, r3
|
stwcx. a, 0, pw
|
||||||
bne- loop
|
bne- loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline long atomic_decrement( register long * pw )
|
inline long atomic_decrement( register long * pw )
|
||||||
{
|
{
|
||||||
|
register int a;
|
||||||
|
|
||||||
asm
|
asm
|
||||||
{
|
{
|
||||||
sync
|
sync
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
|
|
||||||
lwarx r4, 0, r3
|
lwarx a, 0, pw
|
||||||
addi r4, r4, -1
|
addi a, a, -1
|
||||||
stwcx. r4, 0, r3
|
stwcx. a, 0, pw
|
||||||
bne- loop
|
bne- loop
|
||||||
|
|
||||||
mr r3, r4
|
|
||||||
|
|
||||||
isync
|
isync
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline long atomic_conditional_increment( register long * pw )
|
inline long atomic_conditional_increment( register long * pw )
|
||||||
{
|
{
|
||||||
|
register int a;
|
||||||
|
|
||||||
asm
|
asm
|
||||||
{
|
{
|
||||||
loop:
|
loop:
|
||||||
|
|
||||||
lwarx r4, 0, r3
|
lwarx a, 0, pw
|
||||||
cmpwi r4, 0
|
cmpwi a, 0
|
||||||
beq store
|
beq store
|
||||||
|
|
||||||
addi r4, r4, 1
|
addi a, a, 1
|
||||||
|
|
||||||
store:
|
store:
|
||||||
|
|
||||||
stwcx. r4, 0, r3
|
stwcx. a, 0, pw
|
||||||
bne- loop
|
bne- loop
|
||||||
|
|
||||||
mr r3, r4
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
class sp_counted_base
|
class sp_counted_base
|
||||||
|
@@ -32,11 +32,11 @@ namespace boost
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
inline void atomic_increment( long * pw )
|
inline void atomic_increment( int * pw )
|
||||||
{
|
{
|
||||||
// ++*pw;
|
// ++*pw;
|
||||||
|
|
||||||
long tmp;
|
int tmp;
|
||||||
|
|
||||||
__asm__
|
__asm__
|
||||||
(
|
(
|
||||||
@@ -52,11 +52,11 @@ inline void atomic_increment( long * pw )
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline long atomic_decrement( long * pw )
|
inline int atomic_decrement( int * pw )
|
||||||
{
|
{
|
||||||
// return --*pw;
|
// return --*pw;
|
||||||
|
|
||||||
long rv;
|
int rv;
|
||||||
|
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
(
|
(
|
||||||
@@ -76,12 +76,12 @@ inline long atomic_decrement( long * pw )
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline long atomic_conditional_increment( long * pw )
|
inline int atomic_conditional_increment( int * pw )
|
||||||
{
|
{
|
||||||
// if( *pw != 0 ) ++*pw;
|
// if( *pw != 0 ) ++*pw;
|
||||||
// return *pw;
|
// return *pw;
|
||||||
|
|
||||||
long rv;
|
int rv;
|
||||||
|
|
||||||
__asm__
|
__asm__
|
||||||
(
|
(
|
||||||
@@ -109,8 +109,8 @@ private:
|
|||||||
sp_counted_base( sp_counted_base const & );
|
sp_counted_base( sp_counted_base const & );
|
||||||
sp_counted_base & operator= ( sp_counted_base const & );
|
sp_counted_base & operator= ( sp_counted_base const & );
|
||||||
|
|
||||||
long use_count_; // #shared
|
int use_count_; // #shared
|
||||||
long weak_count_; // #weak + (#shared != 0)
|
int weak_count_; // #weak + (#shared != 0)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ public:
|
|||||||
|
|
||||||
long use_count() const // nothrow
|
long use_count() const // nothrow
|
||||||
{
|
{
|
||||||
return static_cast<long const volatile &>( use_count_ );
|
return static_cast<int const volatile &>( use_count_ );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -621,7 +621,7 @@ p3.reset(new int(2)); // undefined, multiple writes
|
|||||||
day a highly configurable smart pointer may be invented that is also very easy
|
day a highly configurable smart pointer may be invented that is also very easy
|
||||||
to use and very hard to misuse. Until then, <B>shared_ptr</B> is the smart
|
to use and very hard to misuse. Until then, <B>shared_ptr</B> is the smart
|
||||||
pointer of choice for a wide range of applications. (Those interested in policy
|
pointer of choice for a wide range of applications. (Those interested in policy
|
||||||
based smart pointers should read <A href="http://cseng.aw.com/book/0,,0201704315,00.html">
|
based smart pointers should read <A href="http://www.awprofessional.com/bookstore/product.asp?isbn=0201704315&rl=1">
|
||||||
Modern C++ Design</A> by Andrei Alexandrescu.)<BR>
|
Modern C++ Design</A> by Andrei Alexandrescu.)<BR>
|
||||||
</P>
|
</P>
|
||||||
<P><B>Q.</B> I am not convinced. Default parameters can be used where appropriate
|
<P><B>Q.</B> I am not convinced. Default parameters can be used where appropriate
|
||||||
|
Reference in New Issue
Block a user