forked from boostorg/smart_ptr
Constraints fixed for g++ 3.4, atomic_increment added
[SVN r27958]
This commit is contained in:
@@ -45,13 +45,27 @@ inline long atomic_exchange_and_add( long * pw, long dv )
|
|||||||
"lock\n\t"
|
"lock\n\t"
|
||||||
"xadd %1, %0":
|
"xadd %1, %0":
|
||||||
"=m"( *pw ), "=r"( r ): // outputs (%0, %1)
|
"=m"( *pw ), "=r"( r ): // outputs (%0, %1)
|
||||||
"0"( *pw ), "1"( dv ): // inputs (%0, %1)
|
"m"( *pw ), "1"( dv ): // inputs (%2, %3 == %1)
|
||||||
"memory", "cc" // clobbers
|
"memory", "cc" // clobbers
|
||||||
);
|
);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void atomic_increment( long * pw )
|
||||||
|
{
|
||||||
|
//atomic_exchange_and_add( pw, 1 );
|
||||||
|
|
||||||
|
__asm__
|
||||||
|
(
|
||||||
|
"lock\n\t"
|
||||||
|
"incl %0":
|
||||||
|
"=m"( *pw ): // output (%0)
|
||||||
|
"m"( *pw ): // input (%1)
|
||||||
|
"cc" // clobbers
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
inline long atomic_conditional_increment( long * pw )
|
inline long atomic_conditional_increment( long * pw )
|
||||||
{
|
{
|
||||||
// long r = *pw;
|
// long r = *pw;
|
||||||
@@ -72,7 +86,7 @@ inline long atomic_conditional_increment( long * pw )
|
|||||||
"jne 0b\n\t"
|
"jne 0b\n\t"
|
||||||
"1:":
|
"1:":
|
||||||
"=m"( *pw ), "=&eax"( r ): // outputs (%0, %1)
|
"=m"( *pw ), "=&eax"( r ): // outputs (%0, %1)
|
||||||
"0"( *pw ): // input (%0)
|
"m"( *pw ): // input (%2)
|
||||||
"ebx", "memory", "cc" // clobbers
|
"ebx", "memory", "cc" // clobbers
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -115,7 +129,7 @@ public:
|
|||||||
|
|
||||||
void add_ref_copy()
|
void add_ref_copy()
|
||||||
{
|
{
|
||||||
atomic_exchange_and_add( &use_count_, +1 );
|
atomic_increment( &use_count_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool add_ref_lock() // true on success
|
bool add_ref_lock() // true on success
|
||||||
@@ -134,7 +148,7 @@ public:
|
|||||||
|
|
||||||
void weak_add_ref() // nothrow
|
void weak_add_ref() // nothrow
|
||||||
{
|
{
|
||||||
atomic_exchange_and_add( &weak_count_, +1 );
|
atomic_increment( &weak_count_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
void weak_release() // nothrow
|
void weak_release() // nothrow
|
||||||
|
Reference in New Issue
Block a user