forked from boostorg/smart_ptr
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c839ee7e42 | |||
| b179f44d79 | |||
| dff0529ad5 |
@@ -34,55 +34,61 @@ namespace detail
|
||||
|
||||
inline void atomic_increment( register long * pw )
|
||||
{
|
||||
register int a;
|
||||
|
||||
asm
|
||||
{
|
||||
loop:
|
||||
|
||||
lwarx r4, 0, r3
|
||||
addi r4, r4, 1
|
||||
stwcx. r4, 0, r3
|
||||
lwarx a, 0, pw
|
||||
addi a, a, 1
|
||||
stwcx. a, 0, pw
|
||||
bne- loop
|
||||
}
|
||||
}
|
||||
|
||||
inline long atomic_decrement( register long * pw )
|
||||
{
|
||||
register int a;
|
||||
|
||||
asm
|
||||
{
|
||||
sync
|
||||
|
||||
loop:
|
||||
|
||||
lwarx r4, 0, r3
|
||||
addi r4, r4, -1
|
||||
stwcx. r4, 0, r3
|
||||
lwarx a, 0, pw
|
||||
addi a, a, -1
|
||||
stwcx. a, 0, pw
|
||||
bne- loop
|
||||
|
||||
mr r3, r4
|
||||
|
||||
isync
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
inline long atomic_conditional_increment( register long * pw )
|
||||
{
|
||||
register int a;
|
||||
|
||||
asm
|
||||
{
|
||||
loop:
|
||||
|
||||
lwarx r4, 0, r3
|
||||
cmpwi r4, 0
|
||||
lwarx a, 0, pw
|
||||
cmpwi a, 0
|
||||
beq store
|
||||
|
||||
addi r4, r4, 1
|
||||
addi a, a, 1
|
||||
|
||||
store:
|
||||
|
||||
stwcx. r4, 0, r3
|
||||
stwcx. a, 0, pw
|
||||
bne- loop
|
||||
|
||||
mr r3, r4
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
|
||||
@@ -32,11 +32,11 @@ namespace boost
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline void atomic_increment( long * pw )
|
||||
inline void atomic_increment( int * pw )
|
||||
{
|
||||
// ++*pw;
|
||||
|
||||
long tmp;
|
||||
int tmp;
|
||||
|
||||
__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;
|
||||
|
||||
long rv;
|
||||
int rv;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
@@ -76,12 +76,12 @@ inline long atomic_decrement( long * pw )
|
||||
return rv;
|
||||
}
|
||||
|
||||
inline long atomic_conditional_increment( long * pw )
|
||||
inline int atomic_conditional_increment( int * pw )
|
||||
{
|
||||
// if( *pw != 0 ) ++*pw;
|
||||
// return *pw;
|
||||
|
||||
long rv;
|
||||
int rv;
|
||||
|
||||
__asm__
|
||||
(
|
||||
@@ -109,8 +109,8 @@ private:
|
||||
sp_counted_base( sp_counted_base const & );
|
||||
sp_counted_base & operator= ( sp_counted_base const & );
|
||||
|
||||
long use_count_; // #shared
|
||||
long weak_count_; // #weak + (#shared != 0)
|
||||
int use_count_; // #shared
|
||||
int weak_count_; // #weak + (#shared != 0)
|
||||
|
||||
public:
|
||||
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
|
||||
long use_count() const // nothrow
|
||||
{
|
||||
return static_cast<long const volatile &>( use_count_ );
|
||||
return static_cast<int const volatile &>( use_count_ );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user